Catch empty star response

This commit is contained in:
Warwick Harris 2021-08-31 08:52:05 +10:00
parent ed3f7da8b5
commit 7564e75f63
1 changed files with 53 additions and 43 deletions

50
main.py
View File

@ -1409,38 +1409,43 @@ def walk_index(folder_id=None):
"""
Request Subsonic's index and iterate each item.
"""
response = connection.getIndexes(folder_id)
try:
for index in response["indexes"]["index"]:
for artist in index["artist"]:
yield artist
except KeyError:
yield from ()
def walk_playlists():
"""
Request Subsonic's playlists and iterate over each item.
"""
response = connection.getPlaylists()
try:
for child in response["playlists"]["playlist"]:
yield child
except KeyError:
yield from ()
def walk_playlist(playlist_id):
"""
Request Subsonic's playlist items and iterate over each item.
"""
response = connection.getPlaylist(playlist_id)
try:
for child in response["playlist"]["entry"]:
yield child
except KeyError:
yield from ()
def walk_folders():
response = connection.getMusicFolders()
try:
for child in response["musicFolders"]["musicFolder"]:
yield child
except KeyError:
yield from ()
def walk_directory(directory_id):
"""
@ -1464,32 +1469,36 @@ def walk_artist(artist_id):
"""
response = connection.getArtist(artist_id)
try:
for child in response["artist"]["album"]:
yield child
except KeyError:
yield from ()
def walk_artists():
"""
(ID3 tags)
Request all artists and iterate over each item.
"""
response = connection.getArtists()
try:
for index in response["artists"]["index"]:
for artist in index["artist"]:
yield artist
except KeyError:
yield from ()
def walk_genres():
"""
(ID3 tags)
Request all genres and iterate over each item.
"""
response = connection.getGenres()
try:
for genre in response["genres"]["genre"]:
yield genre
except KeyError:
yield from ()
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)
Request an album and iterate over each item.
"""
response = connection.getAlbum(album_id)
try:
for song in response["album"]["song"]:
yield song
except KeyError:
yield from ()
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.
"""
response = connection.getRandomSongs(
size=size, genre=genre, fromYear=fromYear, toYear=toYear)
try:
for song in response["randomSongs"]["song"]:
yield song
except KeyError:
yield from ()
def walk_tracks_starred():
"""
Request Subsonic's starred songs and iterate over each item.
"""
response = connection.getStarred()
try:
for song in response["starred"]["song"]:
yield song
except KeyError:
yield from ()
# Start plugin from within Kodi.
if __name__ == "__main__":