Support for playlist_cover_image (#431)

This commit is contained in:
CyanBook 2020-01-26 14:20:20 +01:00 committed by Stéphane Bruckert
parent 26db832e24
commit 349587ca32
3 changed files with 29 additions and 6 deletions

View File

@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Added
- Support for `playlist_cover_image`
## [2.7.1] - 2020-01-20 ## [2.7.1] - 2020-01-20
### Changed ### Changed

View File

@ -406,11 +406,19 @@ class Spotify(object):
limit=limit, offset=offset, fields=fields, limit=limit, offset=offset, fields=fields,
market=market) 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, def playlist_upload_cover_image(self,
playlist_id, playlist_id,
image_b64): image_b64):
""" """ Replace the image used to represent a specific playlist
Replace the image used to represent a specific playlist
Parameters: Parameters:
- playlist_id - the id of the playlist - playlist_id - the id of the playlist

View File

@ -314,6 +314,17 @@ class AuthTestSpotipy(unittest.TestCase):
new_b64 = self.get_as_base64(pl1['images'][0]['url']) new_b64 = self.get_as_base64(pl1['images'][0]['url'])
self.assertTrue(old_b64 != new_b64) 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): def test_user_follows_and_unfollows_artist(self):
# Initially follows 1 artist # Initially follows 1 artist
res = self.spotify.current_user_followed_artists() res = self.spotify.current_user_followed_artists()