lotsOfTracks.append(songList[i]) lotsOfArtists = [] for i, key in enumerate(user.get_artists()): if (i != 0) and (i % 50 == 0): fiftyArtists = ",".join(lotsOfArtists) fiftyArtists = fiftyArtists.strip() fiftyArtists = fiftyArtists.replace(" ", "") lotsOfArtists[:] = [] response = session.get('https://api.spotify.com/v1/artists?ids=%s' % fiftyArtists, headers=header) currentArtists = response.json() for currentArtist in currentArtists["artists"]: genres = currentArtist["genres"] user.add_genre(genres, currentArtist["id"]) else: lotsOfArtists.append(key) listOfPlaylists = [] offset = 0 response = session.get( 'https://api.spotify.com/v1/users/%s/playlists?offset=%d&limit=50' % (user_id, offset), headers=header) currentPlaylists = response.json() while len(currentPlaylists["items"]) > 0: offset += 50 for playlist in currentPlaylists["items"]: playlistName = playlist["name"] playlistId = playlist["id"]