mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-05 07:27:47 +00:00
25 lines
597 B
Python
25 lines
597 B
Python
# shows a user's saved tracks (need to be authenticated via oauth)
|
|
|
|
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()
|
|
|
|
token = util.prompt_for_user_token(username, scope)
|
|
|
|
if token:
|
|
sp = spotipy.Spotify(auth=token)
|
|
results = sp.current_user_saved_tracks()
|
|
for item in results['items']:
|
|
track = item['track']
|
|
print(track['name'] + ' - ' + track['artists'][0]['name'])
|
|
else:
|
|
print("Can't get token for", username)
|