mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 17:23:53 +00:00
Fix show_my_saved_tracks example, closes #70
This commit is contained in:
parent
dda55b25df
commit
44911f7285
@ -12,13 +12,21 @@ else:
|
||||
print("Usage: %s username" % (sys.argv[0],))
|
||||
sys.exit()
|
||||
|
||||
|
||||
def show_tracks(results):
|
||||
for item in results['items']:
|
||||
track = item['track']
|
||||
print("%32.32s %s" % (track['artists'][0]['name'], track['name']))
|
||||
|
||||
|
||||
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'])
|
||||
show_tracks(results)
|
||||
while results['next']:
|
||||
results = sp.next(results)
|
||||
show_tracks(results)
|
||||
else:
|
||||
print("Can't get token for", username)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user