mirror of
https://github.com/gordielachance/plugin.audio.subsonic
synced 2025-02-17 20:21:06 +01:00
Catch empty star response
This commit is contained in:
parent
ed3f7da8b5
commit
7564e75f63
96
main.py
96
main.py
@ -1409,45 +1409,50 @@ def walk_index(folder_id=None):
|
|||||||
"""
|
"""
|
||||||
Request Subsonic's index and iterate each item.
|
Request Subsonic's index and iterate each item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = connection.getIndexes(folder_id)
|
response = connection.getIndexes(folder_id)
|
||||||
|
try:
|
||||||
|
for index in response["indexes"]["index"]:
|
||||||
|
for artist in index["artist"]:
|
||||||
|
yield artist
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
for index in response["indexes"]["index"]:
|
|
||||||
for artist in index["artist"]:
|
|
||||||
yield artist
|
|
||||||
|
|
||||||
def walk_playlists():
|
def walk_playlists():
|
||||||
"""
|
"""
|
||||||
Request Subsonic's playlists and iterate over each item.
|
Request Subsonic's playlists and iterate over each item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = connection.getPlaylists()
|
response = connection.getPlaylists()
|
||||||
|
try:
|
||||||
for child in response["playlists"]["playlist"]:
|
for child in response["playlists"]["playlist"]:
|
||||||
yield child
|
yield child
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
def walk_playlist(playlist_id):
|
def walk_playlist(playlist_id):
|
||||||
"""
|
"""
|
||||||
Request Subsonic's playlist items and iterate over each item.
|
Request Subsonic's playlist items and iterate over each item.
|
||||||
"""
|
"""
|
||||||
response = connection.getPlaylist(playlist_id)
|
response = connection.getPlaylist(playlist_id)
|
||||||
|
try:
|
||||||
for child in response["playlist"]["entry"]:
|
for child in response["playlist"]["entry"]:
|
||||||
yield child
|
yield child
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
def walk_folders():
|
def walk_folders():
|
||||||
response = connection.getMusicFolders()
|
response = connection.getMusicFolders()
|
||||||
|
try:
|
||||||
for child in response["musicFolders"]["musicFolder"]:
|
for child in response["musicFolders"]["musicFolder"]:
|
||||||
yield child
|
yield child
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
def walk_directory(directory_id):
|
def walk_directory(directory_id):
|
||||||
"""
|
"""
|
||||||
Request a Subsonic music directory and iterate over each item.
|
Request a Subsonic music directory and iterate over each item.
|
||||||
"""
|
"""
|
||||||
response = connection.getMusicDirectory(directory_id)
|
response = connection.getMusicDirectory(directory_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for child in response["directory"]["child"]:
|
for child in response["directory"]["child"]:
|
||||||
if child.get("isDir"):
|
if child.get("isDir"):
|
||||||
@ -1464,32 +1469,36 @@ def walk_artist(artist_id):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
response = connection.getArtist(artist_id)
|
response = connection.getArtist(artist_id)
|
||||||
|
try:
|
||||||
for child in response["artist"]["album"]:
|
for child in response["artist"]["album"]:
|
||||||
yield child
|
yield child
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
def walk_artists():
|
def walk_artists():
|
||||||
"""
|
"""
|
||||||
(ID3 tags)
|
(ID3 tags)
|
||||||
Request all artists and iterate over each item.
|
Request all artists and iterate over each item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = connection.getArtists()
|
response = connection.getArtists()
|
||||||
|
try:
|
||||||
for index in response["artists"]["index"]:
|
for index in response["artists"]["index"]:
|
||||||
for artist in index["artist"]:
|
for artist in index["artist"]:
|
||||||
yield artist
|
yield artist
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
def walk_genres():
|
def walk_genres():
|
||||||
"""
|
"""
|
||||||
(ID3 tags)
|
(ID3 tags)
|
||||||
Request all genres and iterate over each item.
|
Request all genres and iterate over each item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = connection.getGenres()
|
response = connection.getGenres()
|
||||||
|
try:
|
||||||
for genre in response["genres"]["genre"]:
|
for genre in response["genres"]["genre"]:
|
||||||
yield genre
|
yield genre
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
def walk_albums(ltype, size=None, fromYear=None,toYear=None, genre=None, offset=None):
|
def walk_albums(ltype, size=None, fromYear=None,toYear=None, genre=None, offset=None):
|
||||||
"""
|
"""
|
||||||
@ -1518,34 +1527,35 @@ def walk_album(album_id):
|
|||||||
(ID3 tags)
|
(ID3 tags)
|
||||||
Request an album and iterate over each item.
|
Request an album and iterate over each item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = connection.getAlbum(album_id)
|
response = connection.getAlbum(album_id)
|
||||||
|
try:
|
||||||
for song in response["album"]["song"]:
|
for song in response["album"]["song"]:
|
||||||
yield song
|
yield song
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
def walk_tracks_random(size=None, genre=None, fromYear=None,toYear=None):
|
def walk_tracks_random(size=None, genre=None, fromYear=None,toYear=None):
|
||||||
"""
|
"""
|
||||||
Request random songs by genre and/or year and iterate over each song.
|
Request random songs by genre and/or year and iterate over each song.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = connection.getRandomSongs(
|
response = connection.getRandomSongs(
|
||||||
size=size, genre=genre, fromYear=fromYear, toYear=toYear)
|
size=size, genre=genre, fromYear=fromYear, toYear=toYear)
|
||||||
|
try:
|
||||||
for song in response["randomSongs"]["song"]:
|
for song in response["randomSongs"]["song"]:
|
||||||
yield song
|
yield song
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
def walk_tracks_starred():
|
def walk_tracks_starred():
|
||||||
"""
|
"""
|
||||||
Request Subsonic's starred songs and iterate over each item.
|
Request Subsonic's starred songs and iterate over each item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = connection.getStarred()
|
response = connection.getStarred()
|
||||||
|
try:
|
||||||
for song in response["starred"]["song"]:
|
for song in response["starred"]["song"]:
|
||||||
yield song
|
yield song
|
||||||
|
except KeyError:
|
||||||
|
yield from ()
|
||||||
|
|
||||||
# Start plugin from within Kodi.
|
# Start plugin from within Kodi.
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user