yes.
This commit is contained in:
parent
42b6f185ae
commit
c76f5481de
1 changed files with 6 additions and 10 deletions
16
main.py
16
main.py
|
@ -9,7 +9,8 @@ import threading
|
||||||
import requests
|
import requests
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import time
|
import time
|
||||||
import urllib.request
|
#import urllib.request
|
||||||
|
import urllib2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,18 +42,13 @@ def get_track():
|
||||||
track = sp.currently_playing()
|
track = sp.currently_playing()
|
||||||
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')
|
#urlretrieve(track['item']['album']['images'][0]['url'], 'thumbnail.jpg')
|
||||||
#imageString = requests.get(track['item']['album']['images'][0]['url'])
|
#imageString = requests.get(track['item']['album']['images'][0]['url'])
|
||||||
image_url=track['item']['album']['images'][0]['url']
|
image_url=track['item']['album']['images'][0]['url']
|
||||||
opener=urllib.request.build_opener()
|
print('downloading and opening image')
|
||||||
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')]
|
image = Image.open(urllib2.urlopen(image_url))
|
||||||
urllib.request.install_opener(opener)
|
#image = Image.open('thumbnail.jpg')
|
||||||
filename = "thumbnail.jpg"
|
|
||||||
print('downloading image')
|
|
||||||
urllib.request.urlretrieve(image_url, filename)
|
|
||||||
print('opening image')
|
|
||||||
image = Image.open('thumbnail.jpg')
|
|
||||||
print('resizing image')
|
print('resizing image')
|
||||||
image = image.resize((32,32))
|
image = image.resize((32,32))
|
||||||
#return image
|
#return image
|
||||||
|
|
Loading…
Reference in a new issue