[GH-ISSUE #585] Playlist items always showing 7 items #351

Closed
opened 2026-02-27 23:22:08 +03:00 by kerem · 5 comments
Owner

Originally created by @iAmCLY on GitHub (Oct 10, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/585

Describe the bug
Everytime I tried to pull tracks from playlist its always give me up to 7 instead of the limit (100). I did check all playlist and give me 7 too. Any idea what I missed? I check the limit and it is 100.

Your code

result = sp.playlist_items(playlistID, additional_types=['track'])
                available_tracks = len(result)

Expected behavior
Give me more than 7

Originally created by @iAmCLY on GitHub (Oct 10, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/585 **Describe the bug** Everytime I tried to pull tracks from playlist its always give me up to 7 instead of the limit (100). I did check all playlist and give me 7 too. Any idea what I missed? I check the limit and it is 100. **Your code** ``` result = sp.playlist_items(playlistID, additional_types=['track']) available_tracks = len(result) ``` **Expected behavior** Give me more than 7
kerem 2026-02-27 23:22:08 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Quizz1Cal commented on GitHub (Oct 10, 2020):

This is definitely strange! Can you confirm that you are checking different playlists i.e. that playlistID is not always set to the same playlist, or perhaps check this with print([item['track']['name'] for item in result])? Some replicable code would be appreciated as well - currently, I'm fetching up to the specified limit.

<!-- gh-comment-id:706459917 --> @Quizz1Cal commented on GitHub (Oct 10, 2020): This is definitely strange! Can you confirm that you are checking different playlists i.e. that `playlistID` is not always set to the same playlist, or perhaps check this with `print([item['track']['name'] for item in result])`? Some replicable code would be appreciated as well - currently, I'm fetching up to the specified limit.
Author
Owner

@iAmCLY commented on GitHub (Oct 10, 2020):

I did check it and I try all of the available playlist and give me same results which 7 tracks only per playlist.

<!-- gh-comment-id:706467839 --> @iAmCLY commented on GitHub (Oct 10, 2020): I did check it and I try all of the available playlist and give me same results which 7 tracks only per playlist.
Author
Owner

@Quizz1Cal commented on GitHub (Oct 10, 2020):

I'm not entirely sure then, though I'll keep investigating for you - in the meantime, I have some tests I'd like you to try:

  1. Explicitly set limit=100 e.g. spotify.playlist_items(playlistID, additional_types=['track'], limit=100)
  2. Fetch the next component(s) returned as well.

As an example of 1) and 2):

result = spotify.playlist_items(playlistID, additional_types=['track'], limit=100)
all_tracks = []

while result:
    all_tracks.extend(result['items'])
    result = spotify.next(result)

available_tracks = len(all_tracks)

This code is necessary for long playlists above the set limit as multiple requests are necessary.

Let us know if doing either 1) or 2) yields any difference!

<!-- gh-comment-id:706474646 --> @Quizz1Cal commented on GitHub (Oct 10, 2020): I'm not entirely sure then, though I'll keep investigating for you - in the meantime, I have some tests I'd like you to try: 1. Explicitly set `limit=100` e.g. `spotify.playlist_items(playlistID, additional_types=['track'], limit=100)` 2. Fetch the `next` component(s) returned as well. As an example of 1) and 2): ```python result = spotify.playlist_items(playlistID, additional_types=['track'], limit=100) all_tracks = [] while result: all_tracks.extend(result['items']) result = spotify.next(result) available_tracks = len(all_tracks) ``` This code is necessary for long playlists above the set limit as multiple requests are necessary. Let us know if doing either 1) or 2) yields any difference!
Author
Owner

@stephanebruckert commented on GitHub (Oct 10, 2020):

result does not directly contain the items, try len(result['items']) instead

<!-- gh-comment-id:706509210 --> @stephanebruckert commented on GitHub (Oct 10, 2020): `result` does not directly contain the items, try `len(result['items'])` instead
Author
Owner

@iAmCLY commented on GitHub (Oct 10, 2020):

@stephanebruckert yes that solved the issue. Sorry my bad and thanks @Quizz1Cal too!

<!-- gh-comment-id:706622603 --> @iAmCLY commented on GitHub (Oct 10, 2020): @stephanebruckert yes that solved the issue. Sorry my bad and thanks @Quizz1Cal too!
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#351
No description provided.