[GH-ISSUE #1155] Playlist longer than 100 items fails to iterate with sample code #680

Closed
opened 2026-02-28 00:00:47 +03:00 by kerem · 4 comments
Owner

Originally created by @cbz on GitHub (Aug 13, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1155

The example code under "Show the contents of every playlist owned by a user:" fails when playlists are longer than 100 items.

Expected behaviour would be to print out all contents of each playlist.

In reality an exception is thrown when a playlist longer than a single page of results is encountered:

The following is seen:

{'next': None}
Traceback (most recent call last):
File "/tmp/sptest.py", line 40, in
show_tracks(tracks)
File "/tmp/sptest.py", line 9, in show_tracks
for i, item in enumerate(tracks['items']):

Environment:

  • OS: Ubuntu 20.04.6 LTS
  • Python version 3.12.0
  • spotipy version 2.24.0
Originally created by @cbz on GitHub (Aug 13, 2024). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1155 The example code under "Show the contents of every playlist owned by a user:" fails when playlists are longer than 100 items. Expected behaviour would be to print out all contents of each playlist. In reality an exception is thrown when a playlist longer than a single page of results is encountered: The following is seen: {'next': None} Traceback (most recent call last): File "/tmp/sptest.py", line 40, in <module> show_tracks(tracks) File "/tmp/sptest.py", line 9, in show_tracks for i, item in enumerate(tracks['items']): **Environment:** - OS: Ubuntu 20.04.6 LTS - Python version 3.12.0 - spotipy version 2.24.0
kerem 2026-02-28 00:00:47 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@dieser-niko commented on GitHub (Aug 22, 2024):

I'm guessing you mean this example: user_playlists_contents.py.

I ran it and it worked fine. Could you copy the entire error message? And if you have modified your script, please share it.

<!-- gh-comment-id:2304461184 --> @dieser-niko commented on GitHub (Aug 22, 2024): I'm guessing you mean this example: [user_playlists_contents.py](https://github.com/spotipy-dev/spotipy/blob/master/examples/user_playlists_contents.py). I ran it and it worked fine. Could you copy the entire error message? And if you have modified your script, please share it.
Author
Owner

@cbz commented on GitHub (Aug 22, 2024):

I'm using the second example here with the auth flow listed.

https://spotipy.readthedocs.io/en/2.11.1/#examples

The text in my original issue is the extent of the error message, and output at the point where a, a playlist longer than 100 items is encountered, and just after the first 100 (0-99) results have been printed out.

<!-- gh-comment-id:2305135950 --> @cbz commented on GitHub (Aug 22, 2024): I'm using the second example here with the auth flow listed. https://spotipy.readthedocs.io/en/2.11.1/#examples The text in my original issue is the extent of the error message, and output at the point where a, a playlist longer than 100 items is encountered, and just after the first 100 (0-99) results have been printed out.
Author
Owner

@cbz commented on GitHub (Aug 22, 2024):

Looks like the interface changed slightly such that the older code no longer worked, closing issue.

<!-- gh-comment-id:2305145672 --> @cbz commented on GitHub (Aug 22, 2024): Looks like the interface changed slightly such that the older code no longer worked, closing issue.
Author
Owner

@dieser-niko commented on GitHub (Aug 22, 2024):

Yeah, the documentation is somewhat outdated, sorry for that.

<!-- gh-comment-id:2305190337 --> @dieser-niko commented on GitHub (Aug 22, 2024): Yeah, the documentation is somewhat outdated, sorry for that.
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#680
No description provided.