2016-11-02 20:51:32 +00:00
|
|
|
# shows a user's saved tracks (need to be authenticated via oauth)
|
2014-07-23 14:04:07 +00:00
|
|
|
|
|
|
|
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:
|
2015-06-05 09:07:28 +00:00
|
|
|
print("Usage: %s username" % (sys.argv[0],))
|
2014-07-23 14:04:07 +00:00
|
|
|
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']
|
2015-06-05 09:07:28 +00:00
|
|
|
print(track['name'] + ' - ' + track['artists'][0]['name'])
|
2014-07-23 14:04:07 +00:00
|
|
|
else:
|
2015-06-05 09:07:28 +00:00
|
|
|
print("Can't get token for", username)
|