Added Search

This commit is contained in:
Silas Cutler 2017-04-02 09:06:49 -04:00
parent 10bb432a14
commit 9e7e542585
4 changed files with 56 additions and 1 deletions

39
main.py
View File

@ -103,7 +103,12 @@ def root(params):
'name': Addon().get_localized_string(30022), 'name': Addon().get_localized_string(30022),
'callback': 'list_playlists', 'callback': 'list_playlists',
'thumb': None 'thumb': None
} },
'search': {
'name': Addon().get_localized_string(30039),
'callback': 'search',
'thumb': None
},
} }
# Iterate through categories # Iterate through categories
@ -612,6 +617,38 @@ def list_playlists(params):
#view_mode = None, #a numeric code for a skin view mode. View mode codes are different in different skins except for 50 (basic listing). #view_mode = None, #a numeric code for a skin view mode. View mode codes are different in different skins except for 50 (basic listing).
#content = None #string - current plugin content, e.g. movies or episodes. #content = None #string - current plugin content, e.g. movies or episodes.
) )
@plugin.action()
#@plugin.cached(cachetime) #cache (in minutes)
def search(params):
dialog = xbmcgui.Dialog()
d = dialog.input(Addon().get_localized_string(30039), type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT)
if not d:
d = " "
# get connection
connection = get_connection()
if connection is False:
return
listing = []
# Get items
items = connection.search2(query=d)
# Iterate through items
for item in items.get('searchResult2').get('song'):
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()...')
return browse_indexes(params)
else:
return plugin.create_listing(listing)
@plugin.action() @plugin.action()
def play_track(params): def play_track(params):

View File

@ -152,3 +152,9 @@ msgstr ""
msgctxt "#30038" msgctxt "#30038"
msgid "Browse" msgid "Browse"
msgstr "" msgstr ""
msgctxt "#30039"
msgid "Search"
msgstr ""

View File

@ -151,3 +151,10 @@ msgstr "Pistes au hasard"
msgctxt "#30038" msgctxt "#30038"
msgid "Browse" msgid "Browse"
msgstr "Parcourir" msgstr "Parcourir"
msgctxt "#30039"
msgid "Chercher"
msgstr ""

View File

@ -151,3 +151,8 @@ msgstr "Zufällig lieder"
msgctxt "#30038" msgctxt "#30038"
msgid "Browse" msgid "Browse"
msgstr "Durchsuchen" msgstr "Durchsuchen"
msgctxt "#30039"
msgid "Suche"
msgstr ""