Merge pull request #47 from GioF71/feature/search-album

[Feature] Search Album
This commit is contained in:
warwickh 2023-02-03 08:25:49 +11:00 committed by GitHub
commit 4fffcd143e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 22 deletions

53
main.py
View File

@ -107,6 +107,11 @@ def root(params):
'callback': 'search', 'callback': 'search',
'thumb': None 'thumb': None
}, },
'searchalbum': {
'name': Addon().get_localized_string(30045),
'callback': 'search_album',
'thumb': None
},
} }
# Iterate through categories # Iterate through categories
@ -578,27 +583,61 @@ def search(params):
dialog = xbmcgui.Dialog() dialog = xbmcgui.Dialog()
d = dialog.input(Addon().get_localized_string(30039), type=xbmcgui.INPUT_ALPHANUM) d = dialog.input(Addon().get_localized_string(30039), type=xbmcgui.INPUT_ALPHANUM)
if not d:
d = " "
listing = []
if d:
# get connection # get connection
connection = get_connection() connection = get_connection()
if connection == False: if connection == False:
return return
listing = []
# Get items # Get items
items = connection.search2(query=d) items = connection.search2(query=d)
# Iterate through items # 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) entry = get_entry_track( item, params)
listing.append(entry) listing.append(entry)
if len(listing) == 1: if len(listing) == 0:
plugin.log('One single Media Folder found; do return listing from browse_indexes()...') 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) return browse_indexes(params)
else: else:
add_directory_items(create_listing(listing)) add_directory_items(create_listing(listing))

View File

@ -154,7 +154,7 @@ msgid "Browse"
msgstr "" msgstr ""
msgctxt "#30039" msgctxt "#30039"
msgid "Search" msgid "Search Songs"
msgstr "" msgstr ""
msgctxt "#30040" msgctxt "#30040"
@ -176,3 +176,7 @@ msgstr ""
msgctxt "#30044" msgctxt "#30044"
msgid "Scrobble to Last.FM" msgid "Scrobble to Last.FM"
msgstr "" msgstr ""
msgctxt "#30045"
msgid "Search Albums"
msgstr ""

View File

@ -153,8 +153,8 @@ msgid "Browse"
msgstr "Parcourir" msgstr "Parcourir"
msgctxt "#30039" msgctxt "#30039"
msgid "Search" msgid "Search Songs"
msgstr "Rechercher" msgstr "Rechercher Chansons"
msgctxt "#30040" msgctxt "#30040"
@ -176,3 +176,7 @@ msgstr ""
msgctxt "#30044" msgctxt "#30044"
msgid "Scrobble to Last.FM" msgid "Scrobble to Last.FM"
msgstr "" msgstr ""
msgctxt "#30045"
msgid "Search Albums"
msgstr "Rechercher Albums"

View File

@ -153,8 +153,8 @@ msgid "Browse"
msgstr "Durchsuchen" msgstr "Durchsuchen"
msgctxt "#30039" msgctxt "#30039"
msgid "Search" msgid "Search Songs"
msgstr "Suche" msgstr "Suche Lieder"
msgctxt "#30040" msgctxt "#30040"
msgid "useGET" msgid "useGET"
@ -175,3 +175,7 @@ msgstr ""
msgctxt "#30044" msgctxt "#30044"
msgid "Scrobble to Last.FM" msgid "Scrobble to Last.FM"
msgstr "" msgstr ""
msgctxt "#30045"
msgid "Search Albums"
msgstr "Suche Albums"