This commit is contained in:
Lukas Schulz 2020-12-20 01:14:55 +01:00
parent c3eb954243
commit 2112425979

View file

@ -32,6 +32,7 @@ screen = RGBMatrix(options = options)
song_name="" song_name=""
artist_name="" artist_name=""
is_playing = False
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)
@ -41,7 +42,8 @@ def get_track():
print('getting info') print('getting info')
sp = spotipy.Spotify(auth=token) sp = spotipy.Spotify(auth=token)
track = sp.currently_playing() track = sp.currently_playing()
print(track['is_playing']) global is_playing
is_playing = track['is_playing']
global song_name global song_name
song_name = track['item']['name'] song_name = track['item']['name']
global artist_name global artist_name
@ -83,7 +85,7 @@ def showImage(image, offset_x = 0, offset_y = 0):
def drawCanvas(): def drawCanvas():
canvas = Image.new('RGB', (192, 128), color = 'black') canvas = Image.new('RGB', (192, 128), color = 'black')
if(sp.currently_playing()['is_playing']): if(is_playing):
canvas.paste(get_track(),(0,96)) canvas.paste(get_track(),(0,96))
songinfo = ImageDraw.Draw(canvas) songinfo = ImageDraw.Draw(canvas)
songinfo_offset_x = 33 songinfo_offset_x = 33