diff --git a/CHANGELOG.md b/CHANGELOG.md index 729541b..a0cdb89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + + - Support for `playlist_cover_image` + ## [2.7.1] - 2020-01-20 ### Changed diff --git a/spotipy/client.py b/spotipy/client.py index 893fcb5..7ba58e9 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -406,16 +406,24 @@ class Spotify(object): limit=limit, offset=offset, fields=fields, market=market) + def playlist_cover_image(self, playlist_id): + """ Get cover of a playlist. + + Parameters: + - playlist_id - the id of the playlist + """ + plid = self._get_id('playlist', playlist_id) + return self._get("playlists/%s/images" % (plid)) + def playlist_upload_cover_image(self, playlist_id, image_b64): - """ - Replace the image used to represent a specific playlist + """ Replace the image used to represent a specific playlist - Parameters: - - playlist_id - the id of the playlist - - image_b64 - image data as a Base64 encoded JPEG image string - (maximum payload size is 256 KB) + Parameters: + - playlist_id - the id of the playlist + - image_b64 - image data as a Base64 encoded JPEG image string + (maximum payload size is 256 KB) """ plid = self._get_id('playlist', playlist_id) return self._put("playlists/{}/images".format(plid), diff --git a/tests/test_auth.py b/tests/test_auth.py index 438e88f..bbddf0e 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -314,6 +314,17 @@ class AuthTestSpotipy(unittest.TestCase): new_b64 = self.get_as_base64(pl1['images'][0]['url']) self.assertTrue(old_b64 != new_b64) + def test_playlist_cover_image(self): + pl = self.get_or_create_spotify_playlist('spotipy-testing-playlist-1') + plid = pl['uri'] + res = self.spotify.playlist_cover_image(plid) + + self.assertTrue(len(res) > 0) + first_image = res[0] + self.assertTrue('width' in first_image) + self.assertTrue('height' in first_image) + self.assertTrue('url' in first_image) + def test_user_follows_and_unfollows_artist(self): # Initially follows 1 artist res = self.spotify.current_user_followed_artists()