spotipy/examples/playlist_tracks.py
fathom9x bea781d28f
Fixed output of playlist_tracks example (#594)
Co-authored-by: Chris Danger <chris@The-Castle-Tower.local>
2020-10-23 17:35:16 +01:00

21 lines
634 B
Python

from spotipy.oauth2 import SpotifyClientCredentials
import spotipy
from pprint import pprint
sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
pl_id = 'spotify:playlist:5RIbzhG2QqdkaP24iXLnZX'
offset = 0
while True:
response = sp.playlist_items(pl_id,
offset=offset,
fields='items.track.id,total',
additional_types=['track'])
if len(response['items']) == 0:
break
pprint(response['items'])
offset = offset + len(response['items'])
print(offset, "/", response['total'])