Skip to content

Commit

Permalink
Even more fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Mar 29, 2021
1 parent 8553527 commit 5f7e6b3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions modules/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ async def update_loop():
globals.paused = True

if globals.shuffle_mode is None:
globals.shuffle_mode = media_info[0]["is_shuffle_active"]
if isinstance(media_info[0]["is_shuffle_active"], bool):
globals.shuffle_mode = media_info[0]["is_shuffle_active"]
else:
globals.shuffle_mode = False

if globals.repeat_mode is None:
globals.repeat_mode = media_info[0]["auto_repeat_mode"]
if isinstance(media_info[0]["auto_repeat_mode"], int) and media_info[0]["auto_repeat_mode"] in list(range(3)):
globals.repeat_mode = media_info[0]["auto_repeat_mode"]
else:
globals.repeat_mode = 0

if media_info[0]["is_shuffle_active"] != globals.prev_shuffle:
if isinstance(media_info[0]["is_shuffle_active"], bool):
Expand All @@ -48,13 +54,13 @@ async def update_loop():
globals.gui.repeat.set_state(0)
globals.prev_repeat = media_info[0]["auto_repeat_mode"]

cur_state = f'{media_info[1]["max_seek_time"]}{media_info[1]["min_seek_time"]}{media_info[2]["artist"]}{media_info[2]["is_spotify"]}{media_info[2]["title"]}'
cur_state = f'{media_info[1].get("max_seek_time")}{media_info[1].get("min_seek_time")}{media_info[2].get("artist")}{media_info[2].get("is_spotify")}{media_info[2].get("title")}'

if cur_state != globals.prev_state:
globals.gui.update_track_info(media_info[2]["title"], media_info[2]["artist"])
globals.gui.update_track_info(media_info[2].get("title"), media_info[2].get("artist"))

globals.gui.time_scrubber.setMinimum(media_info[1]["min_seek_time"])
globals.gui.time_scrubber.setMaximum(media_info[1]["max_seek_time"])
globals.gui.time_scrubber.setMinimum(media_info[1].get("min_seek_time") if isinstance(media_info[1].get("min_seek_time"), int) else 0)
globals.gui.time_scrubber.setMaximum(media_info[1].get("max_seek_time") if isinstance(media_info[1].get("max_seek_time"), int) else 600000)

thumbnail = await api.get_thumbnail(media_info[2])
if thumbnail[0]:
Expand Down

0 comments on commit 5f7e6b3

Please sign in to comment.