[GH-ISSUE #968] previews that were previously valid, now are null #581

Closed
opened 2026-02-27 23:23:28 +03:00 by kerem · 1 comment
Owner

Originally created by @ariutti on GitHub (Apr 24, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/968

Hi guy,
this is my first time making experiments with Spotify API via Spotipy.

Some days ago a used Spotipy to download all the data related to my account loved tracks.
I had already noticed that several tracks did not have a valid preview_url (about 18%). A few days later I did a new test to download my 'loved tracks' again, which had increased in the meantime.

I noticed in this second test that the percentage of tracks not having a preview had increased considerably (38%), unjustifiably: many of the tracks that had a valid preview, now no longer seem to have one (preview_url = null).

Why?

This is the link to the code snippet I'm using.


Here's an example for the track "Close to me" by The Cure (id: 4xiyq1iRdsxuU1BPUJ490Z).

When I first downloaded the track data (03-april-2023) i got this:

{"danceability": 0.724, "energy": 0.523, "key": 11, "loudness": -11.139, "mode": 1, "speechiness": 0.116, "acousticness": 0.0745, "instrumentalness": 0.703, "liveness": 0.0811, "valence": 0.965, "tempo": 185.075, "id": "4xiyq1iRdsxuU1BPUJ490Z", "analysis_url": "https://api.spotify.com/v1/audio-analysis/4xiyq1iRdsxuU1BPUJ490Z", "duration_ms": 203267, "time_signature": 4, "name": "Close To Me", "artist": ["The Cure"], "preview_url": "https://p.scdn.co/mp3-preview/391f80bf6008a2082fcb557293712b256bf5d051?cid=d15799fa66d145678638eaacc0278873"}

In my second test (22-04-2023), I got this instead (notice that I added inside the json some additional info taken form artists and the album like the genres and album title and album release year):

{"danceability": 0.724, "energy": 0.523, "key": 11, "loudness": -11.139, "mode": 1, "speechiness": 0.116, "acousticness": 0.0745, "instrumentalness": 0.703, "liveness": 0.0811, "valence": 0.965, "tempo": 185.075, "id": "4xiyq1iRdsxuU1BPUJ490Z", "analysis_url": "https://api.spotify.com/v1/audio-analysis/4xiyq1iRdsxuU1BPUJ490Z", "duration_ms": 203267, "time_signature": 4, "name": "Close To Me", "artist": ["The Cure"], "album": "the_head_on_the_door_(remastered)", "genres": ["new wave", "permanent wave", "rock", "uk post-punk"], "release_year": "1985", "preview_url": null}

As you see preview_url = null !!!

The thing which sound strange to me is that the preview_url I retrieved in the first place is still valid. if I visit the link, it works! So why spotipy/spotify API is not providing me with it?

Then I tried a new experiment (code below) and, to this day that I am writing this post, i get null for every market.
Am I doing something wrong?

TRACK_ID = "4xiyq1iRdsxuU1BPUJ490Z" # The Cure - close to me

import spotipy, time

from spotipy.oauth2 import SpotifyOAuth
scope = "user-library-read"
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))

country_codes = ['AD', 'AR', 'AU', 'AT', 'BE', 'BO', 'BR', 'BG', 'CA', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DK', 'DO', 'EC', 'SV', 'EE', 'FI', 'FR', 'DE', 'GR', 'GT', 'HN', 'HK', 'HU', 'IS', 'ID', 'IE', 'IT', 'JP', 'LV', 'LI', 'LT', 'LU', 'MY', 'MT', 'MX', 'MC', 'NL', 'NZ', 'NI', 'NO', 'PA', 'PY', 'PE', 'PH', 'PL', 'PT', 'SG', 'ES', 'SK', 'SE', 'CH', 'TW', 'TR', 'GB', 'US', 'UY']

for cc in country_codes:
	myTrack = sp.track(TRACK_ID, market=cc )

	name = myTrack['name']
	preview_url = myTrack['preview_url']

	if preview_url == None:
		print( "market {} - {} - preview is none".format(cc, name) )
	else:
		print( "market {} - {} - preview is: {}".format(cc, name, preview_url) )

	time.sleep(0.1)

Tank you so much for your support

Originally created by @ariutti on GitHub (Apr 24, 2023). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/968 Hi guy, this is my first time making experiments with Spotify API via Spotipy. Some days ago a used Spotipy to download all the data related to my account loved tracks. I had already noticed that several tracks did not have a valid `preview_url` (about 18%). A few days later I did a new test to download my 'loved tracks' again, which had increased in the meantime. I noticed in this second test that the percentage of tracks not having a preview had increased considerably (38%), unjustifiably: many of the tracks that had a valid preview, now no longer seem to have one (`preview_url = null`). Why? This is the [link](https://github.com/ariutti/spotify_myLikedSongs_viz/blob/main/python/02_fetch_likedSongs_list_w_spotipy.py) to the code snippet I'm using. *** Here's an example for the track "_Close to me_" by The Cure (id: `4xiyq1iRdsxuU1BPUJ490Z`). When I first downloaded the track data (03-april-2023) i got this: ``` {"danceability": 0.724, "energy": 0.523, "key": 11, "loudness": -11.139, "mode": 1, "speechiness": 0.116, "acousticness": 0.0745, "instrumentalness": 0.703, "liveness": 0.0811, "valence": 0.965, "tempo": 185.075, "id": "4xiyq1iRdsxuU1BPUJ490Z", "analysis_url": "https://api.spotify.com/v1/audio-analysis/4xiyq1iRdsxuU1BPUJ490Z", "duration_ms": 203267, "time_signature": 4, "name": "Close To Me", "artist": ["The Cure"], "preview_url": "https://p.scdn.co/mp3-preview/391f80bf6008a2082fcb557293712b256bf5d051?cid=d15799fa66d145678638eaacc0278873"} ``` In my second test (22-04-2023), I got this instead (notice that I added inside the json some additional info taken form artists and the album like the genres and album title and album release year): ``` {"danceability": 0.724, "energy": 0.523, "key": 11, "loudness": -11.139, "mode": 1, "speechiness": 0.116, "acousticness": 0.0745, "instrumentalness": 0.703, "liveness": 0.0811, "valence": 0.965, "tempo": 185.075, "id": "4xiyq1iRdsxuU1BPUJ490Z", "analysis_url": "https://api.spotify.com/v1/audio-analysis/4xiyq1iRdsxuU1BPUJ490Z", "duration_ms": 203267, "time_signature": 4, "name": "Close To Me", "artist": ["The Cure"], "album": "the_head_on_the_door_(remastered)", "genres": ["new wave", "permanent wave", "rock", "uk post-punk"], "release_year": "1985", "preview_url": null} ``` As you see `preview_url = null` !!! The thing which sound strange to me is that the _preview_url_ I retrieved in the first place is still valid. if I visit the [link](https://p.scdn.co/mp3-preview/391f80bf6008a2082fcb557293712b256bf5d051?cid=d15799fa66d145678638eaacc0278873), it works! So why spotipy/spotify API is not providing me with it? Then I tried a new experiment (code below) and, to this day that I am writing this post, i get null for every market. Am I doing something wrong? ``` TRACK_ID = "4xiyq1iRdsxuU1BPUJ490Z" # The Cure - close to me import spotipy, time from spotipy.oauth2 import SpotifyOAuth scope = "user-library-read" sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope)) country_codes = ['AD', 'AR', 'AU', 'AT', 'BE', 'BO', 'BR', 'BG', 'CA', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DK', 'DO', 'EC', 'SV', 'EE', 'FI', 'FR', 'DE', 'GR', 'GT', 'HN', 'HK', 'HU', 'IS', 'ID', 'IE', 'IT', 'JP', 'LV', 'LI', 'LT', 'LU', 'MY', 'MT', 'MX', 'MC', 'NL', 'NZ', 'NI', 'NO', 'PA', 'PY', 'PE', 'PH', 'PL', 'PT', 'SG', 'ES', 'SK', 'SE', 'CH', 'TW', 'TR', 'GB', 'US', 'UY'] for cc in country_codes: myTrack = sp.track(TRACK_ID, market=cc ) name = myTrack['name'] preview_url = myTrack['preview_url'] if preview_url == None: print( "market {} - {} - preview is none".format(cc, name) ) else: print( "market {} - {} - preview is: {}".format(cc, name, preview_url) ) time.sleep(0.1) ``` Tank you so much for your support
kerem 2026-02-27 23:23:28 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@stephanebruckert commented on GitHub (Apr 24, 2023):

As spotipy only returns what it receives from the API, this is going to be a question for Spotify for Developers. Note that it happened before so it would be great to raise it with Spotify https://github.com/spotipy-dev/spotipy/issues/592#issuecomment-715342394

I will close this but feel free to post a link to your new post to help anyone in the same situation.

<!-- gh-comment-id:1520653776 --> @stephanebruckert commented on GitHub (Apr 24, 2023): As spotipy only returns what it receives from the API, this is going to be a question for [Spotify for Developers](https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer). Note that it happened before so it would be great to raise it with Spotify https://github.com/spotipy-dev/spotipy/issues/592#issuecomment-715342394 I will close this but feel free to post a link to your new post to help anyone in the same situation.
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#581
No description provided.