mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 01:03:53 +00:00
Add playlist_tracks example
This commit is contained in:
parent
db65b98790
commit
14268a8a2c
17
examples/playlist_tracks.py
Normal file
17
examples/playlist_tracks.py
Normal file
@ -0,0 +1,17 @@
|
||||
from spotipy.oauth2 import SpotifyClientCredentials
|
||||
import spotipy
|
||||
from pprint import pprint
|
||||
|
||||
sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
|
||||
|
||||
pl_id = 'spotify:playlist:5RIbzhG2QqdkaP24iXLnZX'
|
||||
response = sp.playlist_tracks(pl_id, fields='items.track.id,total')
|
||||
offset = 0
|
||||
|
||||
while len(response['items']) > 0:
|
||||
print(offset, "/", response['total'])
|
||||
response = sp.playlist_tracks(pl_id,
|
||||
offset=offset,
|
||||
fields='items.track.id,total')
|
||||
offset = offset + len(response['items'])
|
||||
pprint(response['items'])
|
||||
Loading…
Reference in New Issue
Block a user