yes.
This commit is contained in:
parent
a6a86bbe8d
commit
846673157b
1 changed files with 6 additions and 6 deletions
12
main.py
12
main.py
|
@ -9,8 +9,7 @@ import threading
|
||||||
import requests
|
import requests
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import time
|
import time
|
||||||
import requests
|
import urllib.request
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,11 +44,12 @@ def get_track():
|
||||||
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']
|
||||||
|
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"
|
filename = "thumbnail.jpg"
|
||||||
r = requests.get(track['item']['album']['images'][0]['url'], stream = True)
|
urllib.request.urlretrieve(image_url, filename)
|
||||||
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