[Feature] Search Album
This commit is contained in:
parent
fa0c4ec165
commit
e59b65d5e0
55
main.py
55
main.py
|
@ -107,6 +107,11 @@ def root(params):
|
|||
'callback': 'search',
|
||||
'thumb': None
|
||||
},
|
||||
'searchalbum': {
|
||||
'name': Addon().get_localized_string(30045),
|
||||
'callback': 'search_album',
|
||||
'thumb': None
|
||||
},
|
||||
}
|
||||
|
||||
# Iterate through categories
|
||||
|
@ -578,27 +583,61 @@ def search(params):
|
|||
|
||||
dialog = xbmcgui.Dialog()
|
||||
d = dialog.input(Addon().get_localized_string(30039), type=xbmcgui.INPUT_ALPHANUM)
|
||||
if not d:
|
||||
d = " "
|
||||
|
||||
listing = []
|
||||
|
||||
if d:
|
||||
# get connection
|
||||
connection = get_connection()
|
||||
|
||||
if connection==False:
|
||||
if connection == False:
|
||||
return
|
||||
|
||||
listing = []
|
||||
|
||||
# Get items
|
||||
items = connection.search2(query=d)
|
||||
# Iterate through items
|
||||
for item in items.get('searchResult2').get('song'):
|
||||
songs = items.get('searchResult2').get('song')
|
||||
if songs:
|
||||
for item in songs:
|
||||
entry = get_entry_track( item, params)
|
||||
listing.append(entry)
|
||||
|
||||
if len(listing) == 1:
|
||||
plugin.log('One single Media Folder found; do return listing from browse_indexes()...')
|
||||
if len(listing) == 0:
|
||||
plugin.log('No songs found; do return listing from browse_indexes()...')
|
||||
return browse_indexes(params)
|
||||
else:
|
||||
add_directory_items(create_listing(listing))
|
||||
|
||||
|
||||
@plugin.action()
|
||||
def search_album(params):
|
||||
|
||||
dialog = xbmcgui.Dialog()
|
||||
d = dialog.input(Addon().get_localized_string(30045), type=xbmcgui.INPUT_ALPHANUM)
|
||||
|
||||
listing = []
|
||||
|
||||
if d:
|
||||
# get connection
|
||||
connection = get_connection()
|
||||
if connection==False:
|
||||
return
|
||||
# Get items, we are only looking for albums here
|
||||
# so artistCount and songCount is set to 0
|
||||
items = connection.search2(query=d, artistCount=0, songCount=0)
|
||||
# Iterate through items
|
||||
|
||||
album_list = items.get('searchResult2').get('album')
|
||||
if album_list:
|
||||
for item in items.get('searchResult2').get('album'):
|
||||
entry = get_entry_album( item, params)
|
||||
listing.append(entry)
|
||||
|
||||
# I believe it is ok to return an empty listing if
|
||||
# the search gave no result
|
||||
# maybe inform the user?
|
||||
if len(listing) == 0:
|
||||
plugin.log('No albums found; do return listing from browse_indexes()...')
|
||||
return browse_indexes(params)
|
||||
else:
|
||||
add_directory_items(create_listing(listing))
|
||||
|
|
|
@ -154,7 +154,7 @@ msgid "Browse"
|
|||
msgstr ""
|
||||
|
||||
msgctxt "#30039"
|
||||
msgid "Search"
|
||||
msgid "Search Songs"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30040"
|
||||
|
@ -176,3 +176,7 @@ msgstr ""
|
|||
msgctxt "#30044"
|
||||
msgid "Scrobble to Last.FM"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30045"
|
||||
msgid "Search Albums"
|
||||
msgstr ""
|
||||
|
|
|
@ -153,8 +153,8 @@ msgid "Browse"
|
|||
msgstr "Parcourir"
|
||||
|
||||
msgctxt "#30039"
|
||||
msgid "Search"
|
||||
msgstr "Rechercher"
|
||||
msgid "Search Songs"
|
||||
msgstr "Rechercher Chansons"
|
||||
|
||||
|
||||
msgctxt "#30040"
|
||||
|
@ -176,3 +176,7 @@ msgstr ""
|
|||
msgctxt "#30044"
|
||||
msgid "Scrobble to Last.FM"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30045"
|
||||
msgid "Search Albums"
|
||||
msgstr "Rechercher Albums"
|
||||
|
|
|
@ -153,8 +153,8 @@ msgid "Browse"
|
|||
msgstr "Durchsuchen"
|
||||
|
||||
msgctxt "#30039"
|
||||
msgid "Search"
|
||||
msgstr "Suche"
|
||||
msgid "Search Songs"
|
||||
msgstr "Suche Lieder"
|
||||
|
||||
msgctxt "#30040"
|
||||
msgid "useGET"
|
||||
|
@ -175,3 +175,7 @@ msgstr ""
|
|||
msgctxt "#30044"
|
||||
msgid "Scrobble to Last.FM"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30045"
|
||||
msgid "Search Albums"
|
||||
msgstr "Suche Albums"
|
||||
|
|
Loading…
Reference in New Issue