4 Commits

Author SHA1 Message Date
d122e8da0c Add internet radio item 2023-08-05 15:37:27 +10:00
4fffcd143e Merge pull request #47 from GioF71/feature/search-album
[Feature] Search Album
2023-02-03 08:25:49 +11:00
e59b65d5e0 [Feature] Search Album 2023-02-02 19:43:09 +01:00
fa0c4ec165 Update repo link 2022-09-18 18:39:33 +10:00
5 changed files with 138 additions and 23 deletions

View File

@ -20,7 +20,7 @@ Leia compatible version available in alternate branch
## Installation
From repository
[repository.warwickh-0.9.1.zip](https://github.com/warwickh/repository.warwickh/raw/master/matrix/zips/repository.warwickh/repository.warwickh-0.9.1.zip) (Please report any issues)
[repository.warwickh](https://github.com/warwickh/repository.warwickh/raw/master/matrix/zips/repository.warwickh) (Please report any issues)
From GitHub
* Click the code button and download

125
main.py
View File

@ -107,6 +107,16 @@ def root(params):
'callback': 'search',
'thumb': None
},
'searchalbum': {
'name': Addon().get_localized_string(30045),
'callback': 'search_album',
'thumb': None
},
'radio': {
'name': Addon().get_localized_string(30046),
'callback': 'browse_radio',
'thumb': None
},
}
# Iterate through categories
@ -238,6 +248,31 @@ def menu_tracks(params):
listing,
))
@plugin.action()
def browse_radio(params):
# get connection
connection = get_connection()
if connection==False:
return
listing = []
# Get items
items = walk_radio()
# Iterate through items
for item in items:
print(item)
entry = get_entry_radio(item,params)
listing.append(entry)
add_directory_items(create_listing(
listing,
sort_methods = get_sort_methods('playlists',params), #he list of integer constants representing virtual folder sort methods.
))
@plugin.action()
def browse_folders(params):
# get connection
@ -578,27 +613,61 @@ def search(params):
dialog = xbmcgui.Dialog()
d = dialog.input(Addon().get_localized_string(30039), type=xbmcgui.INPUT_ALPHANUM)
if not d:
d = " "
# get connection
connection = get_connection()
if connection==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 d:
# get connection
connection = get_connection()
if len(listing) == 1:
plugin.log('One single Media Folder found; do return listing from browse_indexes()...')
if connection == False:
return
# Get items
items = connection.search2(query=d)
# Iterate through items
songs = items.get('searchResult2').get('song')
if songs:
for item in songs:
entry = get_entry_track( item, params)
listing.append(entry)
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))
@ -841,6 +910,17 @@ def get_entry_album(item, params):
return entry
def get_entry_radio(item,params):
menu_id = params.get('menu_id')
entry = {
'label': item.get('name'),
'url': item.get('streamUrl'),
'is_playable': True
}
return entry
def get_entry_track(item,params):
menu_id = params.get('menu_id')
image = connection.getCoverArtUrl(item.get('coverArt'))
@ -1504,6 +1584,17 @@ def walk_tracks_random(size=None, genre=None, fromYear=None,toYear=None):
except KeyError:
yield from ()
def walk_radio():
"""
Request Subsonic's radio stations and iterate over each item.
"""
response = connection.getInternetRadioStations()
try:
for station in response["internetRadioStations"]["internetRadioStation"]:
yield station
except KeyError:
yield from ()
def walk_tracks_starred():
"""
Request Subsonic's starred songs and iterate over each item.

View File

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

View File

@ -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,11 @@ msgstr ""
msgctxt "#30044"
msgid "Scrobble to Last.FM"
msgstr ""
msgctxt "#30045"
msgid "Search Albums"
msgstr "Rechercher Albums"
msgctxt "#30046"
msgid "Radio"
msgstr "Radio"

View File

@ -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,11 @@ msgstr ""
msgctxt "#30044"
msgid "Scrobble to Last.FM"
msgstr ""
msgctxt "#30045"
msgid "Search Albums"
msgstr "Suche Albums"
msgctxt "#30046"
msgid "Radio"
msgstr "Radio"