From 41b09712e55954a1cc2f5b8080b4e1f31339e3d5 Mon Sep 17 00:00:00 2001 From: yiannisha Date: Sun, 24 Oct 2021 19:09:58 +0300 Subject: [PATCH] Can now download all of an artists songs fixes#88 --- src/album.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/album.py b/src/album.py index 12f86eb6..19004d11 100644 --- a/src/album.py +++ b/src/album.py @@ -35,7 +35,13 @@ def get_artist_albums(artist_id): """ Returns artist's albums """ resp = ZSpotify.invoke_url(f'{ARTIST_URL}/{artist_id}/albums') # Return a list each album's id - return [resp[ITEMS][i][ID] for i in range(len(resp[ITEMS]))] + album_ids = [resp[ITEMS][i][ID] for i in range(len(resp[ITEMS]))] + # Recursive requests to get all albums including singles an EPs + while resp['next'] is not None: + resp = ZSpotify.invoke_url(resp['next']) + album_ids.extend([resp[ITEMS][i][ID] for i in range(len(resp[ITEMS]))]) + + return album_ids def download_album(album):