Upload Custom Playlist Cover with Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My Question or Issue
Hi! I'm having trouble with uploading custom image to playlist cover. Here's my code:
def add_playlist_cover(playlist_id, token):
with open('cover.jpg', 'rb') as f:
data = base64.b64encode(f.read())
auth_header = {"Authorization": f"Bearer {token}", 'Content-Type':'image/jpeg'}
url = f'https://api.spotify.com/v1/playlists/{playlist_id}/images'
r = requests.put(url, headers=auth_header, data=data)
print(r.json())
I've tried Content-Type as image/jpeg and as application/json and still got an error requests.exceptions.SSLError: HTTPSConnectionPool(host='api.spotify.com', port=443)
Can someone help me out? Thanks in advance
Labels:
- Labels:
-
api
-
api documentation
-
API Question
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page