Announcements

Help Wizard

Step 1

NEXT STEP

Upload Custom Playlist Cover with Python

Upload Custom Playlist Cover with Python

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

 

Reply
2 Replies

You can add `verify=False` inside the `requests.put()` and try if that works.

Did you ensure that the image is less than or equal to 256kb in size?

Suggested posts