[GH-ISSUE #365] Inconsistent return object of user_playlist_tracks #216

Closed
opened 2026-02-27 23:21:25 +03:00 by kerem · 2 comments
Owner

Originally created by @fulaphex on GitHub (Mar 30, 2019).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/365

If given a playlist_id user_playlist_tracks returns a paging object,
if given a full url it returns playlist object (full). Tested on this playlist.

Code snipper below demonstrates the difference:

import spotipy
from spotipy import util

token = util.prompt_for_user_token(
    username,
    client_id=_client_id,
    client_secret=_client_secret,
    redirect_uri=_redirect_uri,
)
sp = spotipy.Spotify(auth=token)

url = "https://open.spotify.com/user/didrik0510/playlist/7ehrAeEI4icxsqlvGX02gW?si=LaDb4nMATFqmeGVgvhHObQ"
id_ = "7ehrAeEI4icxsqlvGX02gW"
print(sp.user_playlist_tracks(username, url).keys())
print(sp.user_playlist_tracks(username, id_).keys())

Having it written in the documentation would be nice, with the explanation what input results in what output type.

Originally created by @fulaphex on GitHub (Mar 30, 2019). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/365 If given a playlist_id `user_playlist_tracks` returns a [paging object](https://developer.spotify.com/documentation/web-api/reference/object-model/#paging-object), if given a full url it returns [playlist object (full)](https://developer.spotify.com/documentation/web-api/reference/object-model/#playlist-object-full). Tested on [this](https://open.spotify.com/user/didrik0510/playlist/7ehrAeEI4icxsqlvGX02gW?si=LaDb4nMATFqmeGVgvhHObQ) playlist. Code snipper below demonstrates the difference: ```python import spotipy from spotipy import util token = util.prompt_for_user_token( username, client_id=_client_id, client_secret=_client_secret, redirect_uri=_redirect_uri, ) sp = spotipy.Spotify(auth=token) url = "https://open.spotify.com/user/didrik0510/playlist/7ehrAeEI4icxsqlvGX02gW?si=LaDb4nMATFqmeGVgvhHObQ" id_ = "7ehrAeEI4icxsqlvGX02gW" print(sp.user_playlist_tracks(username, url).keys()) print(sp.user_playlist_tracks(username, id_).keys()) ``` Having it written in the documentation would be nice, with the explanation what input results in what output type.
kerem 2026-02-27 23:21:25 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@ritiek commented on GitHub (Jan 4, 2020):

I had a similar problem in the past. I don't remember if this commit was enough for the fix but do check out if this helps https://github.com/plamere/spotipy/pull/324/commits/baf96493cc9b6aa51073c59a9f74edf6df444549.

<!-- gh-comment-id:570805707 --> @ritiek commented on GitHub (Jan 4, 2020): I had a similar problem in the past. I don't remember if this commit was enough for the fix but do check out if this helps https://github.com/plamere/spotipy/pull/324/commits/baf96493cc9b6aa51073c59a9f74edf6df444549.
Author
Owner

@ritiek commented on GitHub (Jan 13, 2020):

If given a playlist_id user_playlist_tracks returns a paging object,

This is the correct behaviour.

if given a full url it returns playlist object (full). Tested on this playlist.

This should return the same paging object as passing the playlist_id. But with the full HTTP URL, sp.user_playlist_tracks ends up mimicking sp.playlist which is an incorrect behaviour.

<!-- gh-comment-id:573690002 --> @ritiek commented on GitHub (Jan 13, 2020): > If given a playlist_id `user_playlist_tracks` returns a [paging object](https://developer.spotify.com/documentation/web-api/reference/object-model/#paging-object), This is the correct behaviour. > if given a full url it returns [playlist object (full)](https://developer.spotify.com/documentation/web-api/reference/object-model/#playlist-object-full). Tested on [this](https://open.spotify.com/user/didrik0510/playlist/7ehrAeEI4icxsqlvGX02gW?si=LaDb4nMATFqmeGVgvhHObQ) playlist. This should return the same paging object as passing the playlist_id. But with the full HTTP URL, `sp.user_playlist_tracks` ends up mimicking `sp.playlist` which is an incorrect behaviour.
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#216
No description provided.