Skip to content

Commit

Permalink
add deprecation warnings and FAQ to respond to Spotify's API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dieser-niko authored Dec 3, 2024
1 parent db3fb9a commit 852f67b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Add your changes below.
- Added `personalized_playlist.py`, `track_recommendations.py`, and `audio_features_analysis.py` to `/examples`.
- Discord badge in README
- Added `SpotifyBaseException` and moved all exceptions to `exceptions.py`
- Marked the following methods as deprecated:
- artist_related_artists
- recommendations
- audio_features
- audio_analysis
- featured_playlists
- category_playlists
- Added FAQ entry for inaccessible playlists

### Fixed
- Audiobook integration tests
Expand Down
6 changes: 6 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@ sp = spotipy.Spotify(
)
```
The error raised is a `spotipy.exceptions.SpotifyException`

### I get a 404 when trying to access a Spotify-owned playlist

Spotify has begun restricting access to algorithmic and Spotify-owned editorial playlists.
Only applications with an existing extended mode will still have access to these playlists.
Read more about this change here: [Introducing some changes to our Web API](https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api)
32 changes: 32 additions & 0 deletions spotipy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ def artist_related_artists(self, artist_id):
Parameters:
- artist_id - the artist ID, URI or URL
"""
warnings.warn(
"You're using `artist_related_artists(...)`, "
"which is marked as deprecated by Spotify."
DeprecationWarning,
)
trid = self._get_id("artist", artist_id)
return self._get("artists/" + trid + "/related-artists")

Expand Down Expand Up @@ -1587,6 +1592,11 @@ def featured_playlists(
(the first object). Use with limit to get the next set of
items.
"""
warnings.warn(
"You're using `featured_playlists(...)`, "
"which is marked as deprecated by Spotify."
DeprecationWarning,
)
return self._get(
"browse/featured-playlists",
locale=locale,
Expand Down Expand Up @@ -1671,6 +1681,11 @@ def category_playlists(
(the first object). Use with limit to get the next set of
items.
"""
warnings.warn(
"You're using `category_playlists(...)`, "
"which is marked as deprecated by Spotify."
DeprecationWarning,
)
return self._get(
"browse/categories/" + category_id + "/playlists",
country=country,
Expand Down Expand Up @@ -1708,6 +1723,12 @@ def recommendations(
attributes listed in the documentation, these values
provide filters and targeting on results.
"""
warnings.warn(
"You're using `recommendations(...)`, "
"which is marked as deprecated by Spotify."
DeprecationWarning,
)

params = dict(limit=limit)
if seed_artists:
params["seed_artists"] = ",".join(
Expand Down Expand Up @@ -1754,6 +1775,11 @@ def audio_analysis(self, track_id):
Parameters:
- track_id - a track URI, URL or ID
"""
warnings.warn(
"You're using `audio_analysis(...)`, "
"which is marked as deprecated by Spotify."
DeprecationWarning,
)
trid = self._get_id("track", track_id)
return self._get("audio-analysis/" + trid)

Expand All @@ -1762,6 +1788,12 @@ def audio_features(self, tracks=[]):
Parameters:
- tracks - a list of track URIs, URLs or IDs, maximum: 100 ids
"""
warnings.warn(
"You're using `audio_features(...)`, "
"which is marked as deprecated by Spotify."
DeprecationWarning,
)

if isinstance(tracks, str):
trackid = self._get_id("track", tracks)
results = self._get("audio-features/?ids=" + trackid)
Expand Down

0 comments on commit 852f67b

Please sign in to comment.