From bdf0cd8144125a468bce52d25f201795e3f698b7 Mon Sep 17 00:00:00 2001 From: Lukas Schulz Date: Sat, 19 Dec 2020 23:01:06 +0100 Subject: [PATCH] yes. --- main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index cbb6b6a..612d275 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,9 @@ import threading import requests from io import BytesIO import time -from urllib.request import urlretrieve +import requests +import shutil + client_id = cfg.client_id @@ -41,8 +43,13 @@ def get_track(): print(track['is_playing']) print(track['item']['name'] + ' - ' + track['item']['artists'][0]['name']) print('getting image') - urlretrieve(track['item']['album']['images'][0]['url'], 'thumbnail.jpg') + #urlretrieve(track['item']['album']['images'][0]['url'], 'thumbnail.jpg') #imageString = requests.get(track['item']['album']['images'][0]['url']) + filename = "thumbnail.jpg" + r = requests.get(track['item']['album']['images'][0]['url'], stream = True) + r.raw.decode_content = True + with open(filename,'wb') as f: + shutil.copyfileobj(r.raw, f) image = Image.open('thumbnail.jpg') print('resizing image') image = image.resize((32,32))