From 0c78005c0704c14253fb9b1fd20147c7aa6156c4 Mon Sep 17 00:00:00 2001 From: Lukas Schulz Date: Sat, 19 Dec 2020 22:27:06 +0100 Subject: [PATCH] yes. --- main.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 547314f..fb8b886 100644 --- a/main.py +++ b/main.py @@ -31,7 +31,7 @@ screen = RGBMatrix(options = options) #pygame.display.set_mode(self.size, self.f token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri) -if token: +async def get_track(): sp = spotipy.Spotify(auth=token) track = sp.currently_playing() print(track['is_playing']) @@ -39,8 +39,20 @@ if token: imageString = requests.get(track['item']['album']['images'][0]['url']) image = Image.open(BytesIO(imageString.content)) image = image.resize((32,32)) + return image #image.save("thumbnail.jpg","JPEG") -else: + +#if token: +# sp = spotipy.Spotify(auth=token) +# track = sp.currently_playing() +# print(track['is_playing']) +# 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) while(True): - screen.SetImage(image.convert('RGB')) + screen.SetImage(get_track().convert('RGB')) + print("Text")