Add internet radio item
This commit is contained in:
parent
4fffcd143e
commit
d122e8da0c
52
main.py
52
main.py
|
@ -112,6 +112,11 @@ def root(params):
|
|||
'callback': 'search_album',
|
||||
'thumb': None
|
||||
},
|
||||
'radio': {
|
||||
'name': Addon().get_localized_string(30046),
|
||||
'callback': 'browse_radio',
|
||||
'thumb': None
|
||||
},
|
||||
}
|
||||
|
||||
# Iterate through categories
|
||||
|
@ -243,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
|
||||
|
@ -880,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'))
|
||||
|
@ -1543,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.
|
||||
|
|
|
@ -180,3 +180,7 @@ msgstr ""
|
|||
msgctxt "#30045"
|
||||
msgid "Search Albums"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30046"
|
||||
msgid "Radio"
|
||||
msgstr "Radio"
|
||||
|
|
|
@ -180,3 +180,7 @@ msgstr ""
|
|||
msgctxt "#30045"
|
||||
msgid "Search Albums"
|
||||
msgstr "Rechercher Albums"
|
||||
|
||||
msgctxt "#30046"
|
||||
msgid "Radio"
|
||||
msgstr "Radio"
|
||||
|
|
|
@ -179,3 +179,7 @@ msgstr ""
|
|||
msgctxt "#30045"
|
||||
msgid "Search Albums"
|
||||
msgstr "Suche Albums"
|
||||
|
||||
msgctxt "#30046"
|
||||
msgid "Radio"
|
||||
msgstr "Radio"
|
||||
|
|
Loading…
Reference in New Issue