This commit is contained in:
Lukas Schulz 2020-12-19 22:27:06 +01:00
parent 6104c066cf
commit 0c78005c07

18
main.py
View file

@ -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) 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) sp = spotipy.Spotify(auth=token)
track = sp.currently_playing() track = sp.currently_playing()
print(track['is_playing']) print(track['is_playing'])
@ -39,8 +39,20 @@ if token:
imageString = requests.get(track['item']['album']['images'][0]['url']) imageString = requests.get(track['item']['album']['images'][0]['url'])
image = Image.open(BytesIO(imageString.content)) image = Image.open(BytesIO(imageString.content))
image = image.resize((32,32)) image = image.resize((32,32))
return image
#image.save("thumbnail.jpg","JPEG") #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) print("Can't get token for", username)
while(True): while(True):
screen.SetImage(image.convert('RGB')) screen.SetImage(get_track().convert('RGB'))
print("Text")