2014-06-21 22:19:04 +00:00
|
|
|
# shows a user's starred playlist
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import spotipy
|
2014-08-14 10:39:24 +00:00
|
|
|
import spotipy.util as util
|
2014-06-21 22:19:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
username = sys.argv[1]
|
|
|
|
else:
|
2015-06-05 09:07:28 +00:00
|
|
|
print("Whoops, need your username!")
|
|
|
|
print("usage: python user_playlists.py [username]")
|
2014-06-21 22:19:04 +00:00
|
|
|
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']
|
2015-06-05 09:07:28 +00:00
|
|
|
print(which, track['name' ], ' --', track['artists'][0]['name'])
|
2014-06-21 22:19:04 +00:00
|
|
|
which += 1
|
|
|
|
tracks = sp.next(tracks)
|
|
|
|
|
|
|
|
else:
|
2015-06-05 09:07:28 +00:00
|
|
|
print("Can't get token for", username)
|