mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
Support for playlist_cover_image (#431)
This commit is contained in:
parent
26db832e24
commit
349587ca32
@ -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
|
||||||
|
|||||||
@ -406,16 +406,24 @@ 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
|
||||||
- image_b64 - image data as a Base64 encoded JPEG image string
|
- image_b64 - image data as a Base64 encoded JPEG image string
|
||||||
(maximum payload size is 256 KB)
|
(maximum payload size is 256 KB)
|
||||||
"""
|
"""
|
||||||
plid = self._get_id('playlist', playlist_id)
|
plid = self._get_id('playlist', playlist_id)
|
||||||
return self._put("playlists/{}/images".format(plid),
|
return self._put("playlists/{}/images".format(plid),
|
||||||
|
|||||||
@ -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()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user