yes.
This commit is contained in:
parent
39b75b7717
commit
ff3268eb04
1 changed files with 31 additions and 0 deletions
31
main.py
Normal file
31
main.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import sys
|
||||||
|
import spotipy
|
||||||
|
import spotipy.util as util
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
scope = 'user-read-currently-playing'
|
||||||
|
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
username = sys.argv[1]
|
||||||
|
else:
|
||||||
|
print("Usage: %s username" % (sys.argv[0],))
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
token = util.prompt_for_user_token(username, scope)
|
||||||
|
|
||||||
|
if token:
|
||||||
|
sp = spotipy.Spotify(auth=token)
|
||||||
|
track = sp.current_user_playing_track()
|
||||||
|
print(track['item']['name'] + ' - ' + track['item']['artists'][0]['name'])
|
||||||
|
imageString = requests.get(track['item']['album']['images'][0]['url'])
|
||||||
|
image = Image.open(BytesIO(imageString.content))
|
||||||
|
image = image.resize((32,32))
|
||||||
|
image.save("thumbnail.jpg","JPEG")
|
||||||
|
else:
|
||||||
|
print("Can't get token for", username)
|
Loading…
Reference in a new issue