mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #1066] Example code does not work #629
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#629
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @aryan-gupta on GitHub (Dec 31, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1066
BUG
A script I wrote few months ago is not working. To debug this issue, I ran the example:
examples/user_playlists_contents.pywhich also failes with an error similar to my code.MY CODE
This code gets the list of tracks from all the playlists the user has.
user_playlists_shortis a list of two-tuples with first element being the name of the playlist and the second item being the playlist id. This fails with this error:ERROR:
The correct output should not error and the
tracksinside the while loop should contain the next paged results. However, probing the tracks variable, there is only one item, but should contain the next paged link and the current list of tracks.FULL MINIMAL EXAMPLE
This is the
examples/user_playlists_contents.pyexample with some modifications for the environment variables. This also errors out similar to my code.ERROR:
In this full minimal example, the same error happens. The while loop at the end, the tracks variable only contains the item below, however should contain both
nextandtracksitems.ENVIRONMENT:
@debfx commented on GitHub (Jan 1, 2024):
My guess is that fetching playlists and then paginating over one of the fields (tracks) somehow broke server side.
Doing pagination over
playlist_items()still works and IMHO is much cleaner.@Jack-Dane commented on GitHub (Jan 2, 2024):
@aryan-gupta it appears the problem is that the "next" request requires a different field present than the original playlist request.
This example works for me on playlists that require next when I change the fields kwarg:
This example is broken and does need to be updated, here is a brief description of why this fixes the issue:
The next request is using the endpoint
playlists/{playlist_id}/tracks(documentation) but the originalsp.playlistis using a different endpointplaylists/{playlist_id}documentation.These two endpoints return different data so you need to supply the additional
itemsfield so that the following/tracks, returned in the "next" key, will also have it. I couldn't find any documentation to support this, but it looks like any fields supplied in the playlist or track request will also be present in the next request.