This commit is contained in:
Lukas Schulz 2020-12-20 00:25:53 +01:00
parent 305e5a7c39
commit 87fc313ab2

View file

@ -29,6 +29,8 @@ options.gpio_slowdown = 4
options.brightness = 50
screen = RGBMatrix(options = options)
song_name=""
artist_name=""
token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
@ -39,6 +41,10 @@ def get_track():
sp = spotipy.Spotify(auth=token)
track = sp.currently_playing()
print(track['is_playing'])
global song_name
song_name = track['item']['name']
global artist_name
artist_name = track['item']['artists'][0]['name']
print(track['item']['name'] + ' - ' + track['item']['artists'][0]['name'])
print('getting image')
image_url = track['item']['album']['images'][0]['url']
@ -77,6 +83,8 @@ def showImage(image, offset_x = 0, offset_y = 0):
def drawCanvas():
canvas = Image.new('RGB', (192, 128), color = 'red')
canvas.paste(get_track(),(0,0))
songinfo = ImageDraw.Draw(canvas)
songinfo.text((10,10), song_name)
showImage(canvas)