I'm attempting to extract the track names and artists from a playlist using the code below (client credentials are blanked out for security):
import spotipy
from spotipy.oauth2 import SpotifyOAuth
from pprint import pprint
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id="blank", client_secret="blank",
redirect_uri="http://127.0.0.1:8888/callback", scope="user-library-read"))
ns6_uri = 'spotify:playlist:73CCgSZfERgYttjl8nOlDN'
offset = 0
while True:
results = sp.playlist_items(ns6_uri, offset=offset, fields='items.track.name,items.track.artists,total')
if len(results['items']) == 0:
break
print(results['items'])
offset = offset + len(results['items'])
print(offset, "/", results['total'])
The code just gives me a list of empty dictionaries, like [ { }, { }, { }, { }, ...]
I've tried using it without the fields parameter in the playlist_items( ) function, which accurately returns all of the tracks of the playlist with all of their attributes, so I think it may be something to do with this function, but I'm not sure. Any ideas?