From ff3268eb0453c1f5f773b6a5e61dbe7bc299e293 Mon Sep 17 00:00:00 2001 From: Lukas Schulz Date: Sat, 19 Dec 2020 21:13:22 +0100 Subject: [PATCH] yes. --- main.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..97fe387 --- /dev/null +++ b/main.py @@ -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)