From 016beb02be04f27765da37784aa18036c6ab0d22 Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Thu, 29 Oct 2020 20:25:32 +0100 Subject: [PATCH] Improved scheduling on init. --- src/scheduling/scheduler.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/scheduling/scheduler.py b/src/scheduling/scheduler.py index 91a3f44a..0c9a5763 100644 --- a/src/scheduling/scheduler.py +++ b/src/scheduling/scheduler.py @@ -131,16 +131,9 @@ class AuraScheduler(threading.Thread): # Load some stuff from the API in any case self.fetch_new_programme() - - # Called upon first boot only - if self.is_engine_ready: - if not self.is_initialized: - - # Queue the start items - self.is_initialized = True - self.on_scheduler_ready() - - # Queue all the other ones + + # Queue only when the engine is ready to play + if self.is_initialized == True: self.queue_programme() except Exception as e: @@ -169,7 +162,8 @@ class AuraScheduler(threading.Thread): """ Called when the engine is ready. """ - self.is_engine_ready = True + self.is_initialized = True + self.on_scheduler_ready() def on_scheduler_ready(self): @@ -271,7 +265,7 @@ class AuraScheduler(threading.Thread): return None # Check for scheduled playlist - current_playlist = current_timeslot.get_playlist() + current_playlist = current_timeslot.playlist if not current_playlist: msg = "There's no playlist assigned to the current timeslot. Most likely a fallback will make things okay again." self.logger.warning(SU.red(msg)) @@ -342,12 +336,13 @@ class AuraScheduler(threading.Thread): Retrieves the currently playing playlist. Returns: - (Playlist): The resolved playlist + (FallbackType, Playlist): The resolved playlist """ timeslot = self.get_active_timeslot() if timeslot: - return timeslot.get_playlist() - return None + # return timeslot.playlist + return self.fallback.resolve_playlist(timeslot) + return (None, None) @@ -393,7 +388,7 @@ class AuraScheduler(threading.Thread): if active_timeslot: planned_playlist = None if active_timeslot.playlist: - planned_playlist = active_timeslot.playlist[0] + planned_playlist = active_timeslot.playlist (fallback_type, resolved_playlist) = self.fallback.resolve_playlist(active_timeslot) @@ -555,7 +550,7 @@ class AuraScheduler(threading.Thread): self.fallback.queue_fallback_playlist(next_timeslot) if next_timeslot.playlist: - self.queue_playlist_entries(next_timeslot, next_timeslot.get_playlist().entries, False, True) + self.queue_playlist_entries(next_timeslot, next_timeslot.playlist.entries, False, True) # Queue the fade-out of the timeslot if not next_timeslot.fadeouttimer: @@ -574,7 +569,7 @@ class AuraScheduler(threading.Thread): # Queue the (rest of the) currently playing timeslot upon startup if current_timeslot: - current_playlist = current_timeslot.get_playlist() + current_playlist = current_timeslot.playlist if current_playlist: active_entry = self.get_active_entry() -- GitLab