mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 01:03:53 +00:00
* use newer string formatters (https://pyformat.info) * fix typo * went through the files again, additions from #1165 are also included * replace .format() with f strings
26 lines
658 B
Python
26 lines
658 B
Python
# Gets all the public playlists for the given
|
|
# user. Uses Client Credentials flow
|
|
#
|
|
|
|
import sys
|
|
import spotipy
|
|
from spotipy.oauth2 import SpotifyClientCredentials
|
|
|
|
client_credentials_manager = SpotifyClientCredentials()
|
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
|
|
|
user = 'spotify'
|
|
|
|
if len(sys.argv) > 1:
|
|
user = sys.argv[1]
|
|
|
|
playlists = sp.user_playlists(user)
|
|
|
|
while playlists:
|
|
for i, playlist in enumerate(playlists['items']):
|
|
print(f"{i + 1 + playlists['offset']:4d} {playlist['uri']} {playlist['name']}")
|
|
if playlists['next']:
|
|
playlists = sp.next(playlists)
|
|
else:
|
|
playlists = None
|