mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-05 07:27:47 +00:00
33 lines
723 B
Python
33 lines
723 B
Python
|
# shows a user's starred playlist
|
||
|
|
||
|
import sys
|
||
|
import spotipy
|
||
|
import util
|
||
|
import spotipy.oauth2 as oauth2
|
||
|
|
||
|
|
||
|
|
||
|
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)
|
||
|
results = sp.user_playlist(username)
|
||
|
tracks = results['tracks']
|
||
|
which = 1
|
||
|
while tracks:
|
||
|
for item in tracks['items']:
|
||
|
track = item['track']
|
||
|
print which, track['name' ], ' --', track['artists'][0]['name']
|
||
|
which += 1
|
||
|
tracks = sp.next(tracks)
|
||
|
|
||
|
else:
|
||
|
print "Can't get token for", username
|