From 2e54f2c138e836caf1161e16507fef82ff855fba Mon Sep 17 00:00:00 2001 From: Niko Date: Fri, 17 May 2024 12:35:23 +0200 Subject: [PATCH 1/5] Replaced argument "album_type" with "include_groups" in "Spotify.artist_albums" --- CHANGELOG.md | 1 + spotipy/client.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cc825f..50d812b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix `user_playlists_contents` example. - Updated links to Spotify in documentation - Fixed error obfuscation when Spotify class is being inherited and an error is raised in the Child's `__init__` +- Replaced `artist_albums(album_type=...)` with `artist_albums(include_groups=...)` due to an API change. ### Fixed - Fixed unused description parameter in playlist creation example diff --git a/spotipy/client.py b/spotipy/client.py index 7d81b1f..1d6de4a 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -405,22 +405,32 @@ class Spotify(object): return self._get("artists/?ids=" + ",".join(tlist)) def artist_albums( - self, artist_id, album_type=None, country=None, limit=20, offset=0 + self, artist_id, album_type=None, include_groups=None country=None, limit=20, offset=0 ): """ Get Spotify catalog information about an artist's albums Parameters: - artist_id - the artist ID, URI or URL - - album_type - 'album', 'single', 'appears_on', 'compilation' + - include_groups - the types of items to return. One or more of 'album', 'single', + 'appears_on', 'compilation'. If multiple types are desired, + pass in a comma separated string; e.g., 'album,single'. - country - limit the response to one particular country. - limit - the number of albums to return - offset - the index of the first album to return """ + if album_type: + warnings.warn( + "You're using `artist_albums(..., album_type='...')` which will be removed in future versions. " + "Please adjust your code accordingly by using `artist_albums(..., include_groups='...')` instead.", + DeprecationWarning, + ) + include_groups = album_type if include_groups is None else include_groups + trid = self._get_id("artist", artist_id) return self._get( "artists/" + trid + "/albums", - album_type=album_type, + include_groups=include_groups, country=country, limit=limit, offset=offset, From 0a8e7f635ec5e2ea877c7418597d5451a8806f68 Mon Sep 17 00:00:00 2001 From: Niko Date: Fri, 17 May 2024 12:37:54 +0200 Subject: [PATCH 2/5] Added missing comma to artist_albums --- spotipy/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotipy/client.py b/spotipy/client.py index 1d6de4a..743c116 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -405,7 +405,7 @@ class Spotify(object): return self._get("artists/?ids=" + ",".join(tlist)) def artist_albums( - self, artist_id, album_type=None, include_groups=None country=None, limit=20, offset=0 + self, artist_id, album_type=None, include_groups=None, country=None, limit=20, offset=0 ): """ Get Spotify catalog information about an artist's albums From f4c2b90a29a512287a49c16059eedee9b41ca19c Mon Sep 17 00:00:00 2001 From: Niko Date: Fri, 17 May 2024 12:41:57 +0200 Subject: [PATCH 3/5] Made sure that the line column is not over 99. --- spotipy/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spotipy/client.py b/spotipy/client.py index 743c116..dc71d64 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -421,8 +421,9 @@ class Spotify(object): if album_type: warnings.warn( - "You're using `artist_albums(..., album_type='...')` which will be removed in future versions. " - "Please adjust your code accordingly by using `artist_albums(..., include_groups='...')` instead.", + "You're using `artist_albums(..., album_type='...')` which will be removed in " + "future versions. Please adjust your code accordingly by using " + "`artist_albums(..., include_groups='...')` instead.", DeprecationWarning, ) include_groups = album_type if include_groups is None else include_groups From 52f2b923badd83c3d959bf848cf0d2b070a9dcbe Mon Sep 17 00:00:00 2001 From: Niko Date: Fri, 17 May 2024 12:46:23 +0200 Subject: [PATCH 4/5] Removing whitespace (new IDE, sorry) --- spotipy/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotipy/client.py b/spotipy/client.py index dc71d64..03abdec 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -427,7 +427,7 @@ class Spotify(object): DeprecationWarning, ) include_groups = album_type if include_groups is None else include_groups - + trid = self._get_id("artist", artist_id) return self._get( "artists/" + trid + "/albums", From 3b5708f5a03b07a51c79dda99f041662f04f0f3a Mon Sep 17 00:00:00 2001 From: Niko Date: Fri, 17 May 2024 14:38:19 +0200 Subject: [PATCH 5/5] Update spotipy/client.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stéphane Bruckert --- spotipy/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotipy/client.py b/spotipy/client.py index 03abdec..8a4d72f 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -426,7 +426,7 @@ class Spotify(object): "`artist_albums(..., include_groups='...')` instead.", DeprecationWarning, ) - include_groups = album_type if include_groups is None else include_groups + include_groups = include_groups or album_type trid = self._get_id("artist", artist_id) return self._get(