yes.
This commit is contained in:
parent
e0518eb582
commit
bdf0cd8144
1 changed files with 9 additions and 2 deletions
11
main.py
11
main.py
|
@ -9,7 +9,9 @@ import threading
|
||||||
import requests
|
import requests
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import time
|
import time
|
||||||
from urllib.request import urlretrieve
|
import requests
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
client_id = cfg.client_id
|
client_id = cfg.client_id
|
||||||
|
@ -41,8 +43,13 @@ 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')
|
#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'])
|
||||||
|
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')
|
image = Image.open('thumbnail.jpg')
|
||||||
print('resizing image')
|
print('resizing image')
|
||||||
image = image.resize((32,32))
|
image = image.resize((32,32))
|
||||||
|
|
Loading…
Reference in a new issue