2014-07-23 14:04:07 +00:00
|
|
|
|
|
|
|
# Adds tracks to a playlist
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import spotipy
|
2014-08-14 10:39:24 +00:00
|
|
|
import spotipy.util as util
|
2014-07-23 14:04:07 +00:00
|
|
|
|
|
|
|
scope = 'user-library-read'
|
|
|
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
username = sys.argv[1]
|
|
|
|
else:
|
|
|
|
print "Usage: %s username" % (sys.argv[0],)
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
token = util.prompt_for_user_token(username, scope)
|
|
|
|
|
|
|
|
if token:
|
|
|
|
sp = spotipy.Spotify(auth=token)
|
|
|
|
results = sp.current_user_saved_tracks()
|
2014-08-22 15:00:29 +00:00
|
|
|
for item in results['items']:
|
|
|
|
track = item['track']
|
|
|
|
print track['name'] + ' - ' + track['artists'][0]['name']
|
2014-07-23 14:04:07 +00:00
|
|
|
else:
|
|
|
|
print "Can't get token for", username
|