thunner icon indicating copy to clipboard operation
thunner copied to clipboard

empty playlists result in 'TypeError: list indices must be integers, not str'

Open ArthurMoore85 opened this issue 10 years ago • 0 comments

If a user has no playlists, the app will crash with the error TypeError: list indices must be integers, not str

This can be avoided by changing the line playlists = list_playlists(api,playlist_ids) with an if loop:

if len(playlist_ids) > 0:
            playlists = list_playlists(api,playlist_ids)
        else:
            playlists = [{'subtreeline': 0, 'name': 'pid', 'subtree': 0}]

This results however in the error:

s = (str(song['track']) if 'track' in song else 'x') + '. ' + song['name']
KeyError: 'name'

ArthurMoore85 avatar Oct 15 '15 12:10 ArthurMoore85