Type in your question below and we'll check to see what answers we can find...
Loading article...
Submitting...
If you couldn't find any answers in the previous step then we need to post your question in the community and wait for someone to respond. You'll be notified when that happens.
Simply add some detail to your question and refine the title if needed, choose the relevant category, then post.
Before we can post your question we need you to quickly make an account (or sign in if you already have one).
Don't worry - it's quick and painless! Just click below, and once you're logged in we'll bring you right back here and post your question. We'll remember what you've already typed in so you won't have to do it again.
Plan - Premium
Country - UK
Device - Levono laptop
Operating System - Windows 10
Category: API - Get a Playlist's Items
Code: GET https://api.spotify.cm/v1/playlists/{playlist_id}/tracks
My Question or Issue
I'm trying to extract the list of tracks from one of my playlists using the "Get Items from Playlist" API. As I analysed the information produced, I noticed that the number of tracks from the API (at 645) was different to the number of tracks on my playlist in Spotify (at 629).
I've looked at the tracks in the API and the vast majority are correct with a small number of additional tracks coming through incorrectly. My current theory is that these are old tracks that were once on the playlist that have since been removed. Therefore:
a) should removed tracks be included in the "Get a Playlist's Items" API and if they are, how could I identify which these are so I can remove them? (i.e. slightly different endpoint or a removed_on parameter)
b) if removed tracks are not included in this endpoint, then why do I have 16 extra tracks in my playlist?
I can send over my working if that will help to fix the bug.
Solved! Go to Solution.
I got an email saying you had replied but the post seems to be missing now. Anyway, I looked up the playlist you provided with the software I use (Mopidy) and I see:
SpotifyBackend-3 DEBUG 2020-07-10 11:11:37,507 Fetching Spotify playlist "'spotify:playlist:1ZRkhoyufuTIYFqk3yWeV9'"
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,366 'spotify:track:1ZWCocmKsR0qJ8HzlmrCMw' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,367 'spotify:track:2ZRvFR4YQeoLYjF860iRKC' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,371 'spotify:track:2RsZvc495oilGPSK6c84AR' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,376 'spotify:track:13gD7RyWE7ZOEoxfGAXm1B' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,376 'spotify:track:02aqb63uCgQ8qwyRjwHnI5' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,382 'spotify:local:Kideko+%26+George+Kwali::Crank+It:276' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,382 'spotify:local:Coldplay%2C+CID::Adventure+of+a+Lifetime+%28CID+remix%29:326' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,382 'spotify:local:Alan+Walker%2C+Tiesto::Faded+%28Tiesto%27s+Northern+Lights+Remix%29:187' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,384 'spotify:track:0mnPBLbAci8OPyEg0BA0Rs' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,384 'spotify:local:Brassica%2C+Bicep::Tears+I+can%27t+afford+%28Bicep+remix%29:475' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,386 'spotify:track:1KQ6i7aTI4nPTI43PMehGY' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,391 'spotify:track:1946aCEzhHVZ02TUux9Xwa' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,392 'spotify:track:7mpcmYoOCeI5gh5azJSnWY' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,397 'spotify:local:::Offaiah+-+Trouble:442' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,398 'spotify:local:SubSoul::Gorgon+City+-+Money:387' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,399 'spotify:track:6R7Ggyj4Qiq0ffrVRbOmeq' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,403 'spotify:track:27xwSksu152ZiGJfElj5ur' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,409 'spotify:local:Alan+Fitzpatrick::1992+%28Boxia+VIP%29:435' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,413 'spotify:track:5h11E5MJHwDQGQaFCejeab' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,422 'spotify:track:0a1wjQ6MTqu9nRfkOJ798L' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,423 'spotify:track:39VfFItzZejusmAWWdyFZv' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,432 'spotify:track:1TpQB1TLtBgcPa4mgOI5sC' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,433 'spotify:track:6wULoIik6M7mKiWJ6HBOch' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,456 'spotify:track:3Xw2crgz5RNxRxmQibOTsh' is not playable
So, clearly some of them are local tracks so they are only playback where the local track is available. It's clear from the API response that some of the others are not available in the GB market, take "1ZWCocmKsR0qJ8HzlmrCMw - Live Your Life - Original Mix" as an example:
"external_urls" : {
"spotify" : "https://open.spotify.com/track/1ZWCocmKsR0qJ8HzlmrCMw"
},
"href" : "https://api.spotify.com/v1/tracks/1ZWCocmKsR0qJ8HzlmrCMw",
"id" : "1ZWCocmKsR0qJ8HzlmrCMw",
"is_local" : false,
"is_playable" : false,
"name" : "Live Your Life - Original Mix",
"popularity" : 0,
"preview_url" : null,
"restrictions" : {
"reason" : "market"
},
The official client hides unplayable tracks by default. There is an option in the settings to control this, as I said before.
Thanks for the help @kingosticks4,
What impact would relinking have on the playlist APIs? Trying to understand how it would result in additional tracks coming through? If two tracks were linked to a song, would they both come through?
That link also discusses market availability and how to detect unplayable tracks, which might be what you are seeing. There's an option in the Spotify clients to hide unplayable tracks but they are always returned when using the API and its up to you to handle that. Your use of the market parameter effects the APIs behaviour so that's also important to understand.
Thanks for getting back to me on this. I've tried adding ?market=GB but this doesn't impact the results so I don't think it's to do with the availability in the market. Thanks though for your help.
So, to be clear, your code is expliclty handling unplayable tracks? The market parameter is just one part of doing that correctly.
The code is returning tracks that are not actually in the playlist. These are tracks that (as far as I can tell) are available in my market, just they shouldn't be appearing in this specific place.
Can you provide the playlist URI (made public) and provide the list of extra tracks? In answer to your original question, removed tracks are not returned (unless you requested a specific snapshot, but that's something different).
I got an email saying you had replied but the post seems to be missing now. Anyway, I looked up the playlist you provided with the software I use (Mopidy) and I see:
SpotifyBackend-3 DEBUG 2020-07-10 11:11:37,507 Fetching Spotify playlist "'spotify:playlist:1ZRkhoyufuTIYFqk3yWeV9'"
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,366 'spotify:track:1ZWCocmKsR0qJ8HzlmrCMw' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,367 'spotify:track:2ZRvFR4YQeoLYjF860iRKC' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,371 'spotify:track:2RsZvc495oilGPSK6c84AR' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,376 'spotify:track:13gD7RyWE7ZOEoxfGAXm1B' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,376 'spotify:track:02aqb63uCgQ8qwyRjwHnI5' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,382 'spotify:local:Kideko+%26+George+Kwali::Crank+It:276' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,382 'spotify:local:Coldplay%2C+CID::Adventure+of+a+Lifetime+%28CID+remix%29:326' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,382 'spotify:local:Alan+Walker%2C+Tiesto::Faded+%28Tiesto%27s+Northern+Lights+Remix%29:187' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,384 'spotify:track:0mnPBLbAci8OPyEg0BA0Rs' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,384 'spotify:local:Brassica%2C+Bicep::Tears+I+can%27t+afford+%28Bicep+remix%29:475' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,386 'spotify:track:1KQ6i7aTI4nPTI43PMehGY' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,391 'spotify:track:1946aCEzhHVZ02TUux9Xwa' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,392 'spotify:track:7mpcmYoOCeI5gh5azJSnWY' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,397 'spotify:local:::Offaiah+-+Trouble:442' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,398 'spotify:local:SubSoul::Gorgon+City+-+Money:387' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,399 'spotify:track:6R7Ggyj4Qiq0ffrVRbOmeq' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,403 'spotify:track:27xwSksu152ZiGJfElj5ur' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,409 'spotify:local:Alan+Fitzpatrick::1992+%28Boxia+VIP%29:435' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,413 'spotify:track:5h11E5MJHwDQGQaFCejeab' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,422 'spotify:track:0a1wjQ6MTqu9nRfkOJ798L' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,423 'spotify:track:39VfFItzZejusmAWWdyFZv' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,432 'spotify:track:1TpQB1TLtBgcPa4mgOI5sC' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,433 'spotify:track:6wULoIik6M7mKiWJ6HBOch' is not playable
SpotifyBackend-3 DEBUG 2020-07-10 11:11:38,456 'spotify:track:3Xw2crgz5RNxRxmQibOTsh' is not playable
So, clearly some of them are local tracks so they are only playback where the local track is available. It's clear from the API response that some of the others are not available in the GB market, take "1ZWCocmKsR0qJ8HzlmrCMw - Live Your Life - Original Mix" as an example:
"external_urls" : {
"spotify" : "https://open.spotify.com/track/1ZWCocmKsR0qJ8HzlmrCMw"
},
"href" : "https://api.spotify.com/v1/tracks/1ZWCocmKsR0qJ8HzlmrCMw",
"id" : "1ZWCocmKsR0qJ8HzlmrCMw",
"is_local" : false,
"is_playable" : false,
"name" : "Live Your Life - Original Mix",
"popularity" : 0,
"preview_url" : null,
"restrictions" : {
"reason" : "market"
},
The official client hides unplayable tracks by default. There is an option in the settings to control this, as I said before.
KingoSticks, you are a goddam hero!
I now understand what you mean. I'm still not sure how these songs have ended up on my playlist (don't recognise some of them and they don't appear in the spotify browser), especially as some of these are local files on my C: drive but some aren't even local files which confuses me even more.
Now I've been able to remove them from the API output by adding is_playable = 1.
Thanks again.
P
Hi!
The tracks that I'm trying to retrieve from a playlist state that they are playable, but still a different song appears when retrieving the IDs. How do you fix this?
Thanks in advance!
Hey there you, Yeah, you! 😁 Welcome - we're glad you joined the Spotify Community! While you here, let's have a fun game and get…