Skip to content

Commit

Permalink
backend: handle when there is nothing playing
Browse files Browse the repository at this point in the history
  • Loading branch information
craigcabrey committed Nov 17, 2018
1 parent f6d3b89 commit ec691cb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ def human_duration(self):
def get_index():
now_playing_track = sp.current_playback()

now_playing_track['artist'] = ', '.join(
artist['name'] for artist in now_playing_track['item']['artists']
)
if now_playing_track:
now_playing_track['artist'] = ', '.join(
artist['name'] for artist in now_playing_track['item']['artists']
)

for image in now_playing_track['item']['album']['images']:
if image['height'] == 300:
now_playing_track['album_art_url'] = image['url']
for image in now_playing_track['item']['album']['images']:
if image['height'] == 300:
now_playing_track['album_art_url'] = image['url']

return flask.render_template(
'index.html',
Expand Down

0 comments on commit ec691cb

Please sign in to comment.