Avoid errors in walk functions

This commit is contained in:
warwickh 2021-07-02 17:37:44 +10:00
parent bc30d36466
commit 6035ff49b8
1 changed files with 22 additions and 13 deletions

35
main.py
View File

@ -642,9 +642,12 @@ def search(params):
# Get items # Get items
items = connection.search2(query=d) items = connection.search2(query=d)
# Iterate through items # Iterate through items
for item in items.get('searchResult2').get('song'): try:
entry = get_entry_track( item, params) for item in items.get('searchResult2').get('song'):
listing.append(entry) entry = get_entry_track( item, params)
listing.append(entry)
except:
pass
if len(listing) == 1: if len(listing) == 1:
plugin.log('One single Media Folder found; do return listing from browse_indexes()...') plugin.log('One single Media Folder found; do return listing from browse_indexes()...')
@ -1416,25 +1419,31 @@ def walk_playlists():
""" """
response = connection.getPlaylists() response = connection.getPlaylists()
try:
for child in response["playlists"]["playlist"]: for child in response["playlists"]["playlist"]:
yield child yield child
except:
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:
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:
yield from ()
def walk_directory(directory_id): def walk_directory(directory_id):
""" """