This commit is contained in:
Lukas Schulz 2020-12-19 23:15:59 +01:00
parent 42b6f185ae
commit c76f5481de

16
main.py
View file

@ -9,7 +9,8 @@ import threading
import requests
from io import BytesIO
import time
import urllib.request
#import urllib.request
import urllib2
@ -41,18 +42,13 @@ def get_track():
track = sp.currently_playing()
print(track['is_playing'])
print(track['item']['name'] + ' - ' + track['item']['artists'][0]['name'])
print('getting image')
#print('getting image')
#urlretrieve(track['item']['album']['images'][0]['url'], 'thumbnail.jpg')
#imageString = requests.get(track['item']['album']['images'][0]['url'])
image_url=track['item']['album']['images'][0]['url']
opener=urllib.request.build_opener()
opener.addheaders=[('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36')]
urllib.request.install_opener(opener)
filename = "thumbnail.jpg"
print('downloading image')
urllib.request.urlretrieve(image_url, filename)
print('opening image')
image = Image.open('thumbnail.jpg')
print('downloading and opening image')
image = Image.open(urllib2.urlopen(image_url))
#image = Image.open('thumbnail.jpg')
print('resizing image')
image = image.resize((32,32))
#return image