Spotipy: Inconsistent return object of `user_playlist_tracks`

Created on 30 Mar 2019  路  2Comments  路  Source: plamere/spotipy

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.

bug

Most helpful comment

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.

All 2 comments

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StefanRickli picture StefanRickli  路  3Comments

gawaineo picture gawaineo  路  3Comments

JessicaMartini212887 picture JessicaMartini212887  路  5Comments

DylanMeeus picture DylanMeeus  路  4Comments

mcurranseijo picture mcurranseijo  路  3Comments