This commit is contained in:
Lukas Schulz 2020-12-19 23:24:43 +01:00
parent c1b0447df6
commit 5769fbe25f

View file

@ -9,10 +9,6 @@ import threading
import requests import requests
from io import BytesIO from io import BytesIO
import time import time
import requests
import shutil
client_id = cfg.client_id client_id = cfg.client_id
client_secret = cfg.client_secret client_secret = cfg.client_secret
@ -43,9 +39,10 @@ def get_track():
print(track['is_playing']) print(track['is_playing'])
print(track['item']['name'] + ' - ' + track['item']['artists'][0]['name']) print(track['item']['name'] + ' - ' + track['item']['artists'][0]['name'])
print('getting image') print('getting image')
urlretrieve(track['item']['album']['images'][0]['url'], 'thumbnail.jpg') with urllib.request.urlopen(track['item']['album']['images'][0]['url']) as url:
f = io.BytesIO(url.read())
#imageString = requests.get(track['item']['album']['images'][0]['url']) #imageString = requests.get(track['item']['album']['images'][0]['url'])
image = Image.open('thumbnail.jpg') image = Image.open(f)
print('resizing image') print('resizing image')
image = image.resize((32,32)) image = image.resize((32,32))
#return image #return image