[GH-ISSUE #70] Incomplete output in example show_my_saved_tracks #33

Closed
opened 2026-02-27 23:20:29 +03:00 by kerem · 0 comments
Owner

Originally created by @dubzdubz on GitHub (Nov 9, 2015).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/70

This is a detail but maybe useful for beginners. In example show_my_saved_tracks, the output does not display all saved tracks but only some of them. To fix that, something similar to what's done in user_playlists_contents should be used, eg

results = sp.current_user_saved_tracks()
show_tracks(results)
while results['next']:
  results = sp.next(results)
  show_tracks(results)

with

def show_tracks(results):
    for i, item in enumerate(results['items']):
        track = item['track']
        print("   %d %32.32s %s" % (i, track['artists'][0]['name'], track['name']))
Originally created by @dubzdubz on GitHub (Nov 9, 2015). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/70 This is a detail but maybe useful for beginners. In example `show_my_saved_tracks`, the output does not display all saved tracks but only some of them. To fix that, something similar to what's done in `user_playlists_contents` should be used, eg ``` python results = sp.current_user_saved_tracks() show_tracks(results) while results['next']: results = sp.next(results) show_tracks(results) ``` with ``` python def show_tracks(results): for i, item in enumerate(results['items']): track = item['track'] print(" %d %32.32s %s" % (i, track['artists'][0]['name'], track['name'])) ```
kerem 2026-02-27 23:20:29 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#33
No description provided.