spotipy-experiments/get_user_auth.py
2018-04-24 23:37:46 -05:00

18 lines
413 B
Python
Executable File

import sys
import spotipy
import spotipy.util as util
scope = 'user-library-read'
if len(sys.argv) > 1:
username = sys.argv[1]
else:
print "Usage: %s username" % (sys.argv[0],)
sys.exit()
sp = util.authorize_api(username, scope, 'server')
results = sp.current_user_saved_tracks()
for item in results['items']:
track = item['track']
print track['name'] + ' - ' + track['artists'][0]['name']