Hi, thanks for this awesome tool!
I noticed it only extracts the first 100 songs from any given playlists into the .csv file, since it does not go through the different spotipy pages.
Adding the following lines in the def write_csv
did the trick for me:
data = playlist['tracks']
results = data['items']
while data['next']:
data = sp.next(data)
results.extend(data['items'])
print(len(playlist['tracks']['items']))
for item in playlist['tracks']['items']:
track = item['track']
if (track['id'] is not None):
track_id = track['id'].encode('utf-8')
song_name = track['name'].encode('utf-8')
primary_artist = track['artists'][0]['name'].encode('utf-8') # Just the primary/first artist
album = track['album']['name'].encode('utf-8')
metadata[track_id] = {'name': song_name, 'artist': primary_artist, 'album': album}
Now it traverses through the different pages, I have tested this for playlists which contained over 1500 songs.
However, it is still not possible to generate another playlist with more than 100 songs, since the Spotfiy API won't let you add more than 100 songs at once, so that has to be split up as well.