spotipy/examples/user_playlists.py
Sebastien (Work) 0eeeeb4a50 Remove unused imports
All imported modules that were note used in examples
    have been removed.
2017-10-23 22:50:05 +01:00

26 lines
549 B
Python

# shows a user's playlists (need to be authenticated via oauth)
import sys
import spotipy
import spotipy.util as util
if len(sys.argv) > 1:
username = sys.argv[1]
else:
print("Whoops, need your username!")
print("usage: python user_playlists.py [username]")
sys.exit()
token = util.prompt_for_user_token(username)
if token:
sp = spotipy.Spotify(auth=token)
playlists = sp.user_playlists(username)
for playlist in playlists['items']:
print(playlist['name'])
else:
print("Can't get token for", username)