Skip to content
Snippets Groups Projects
Commit 063894aa authored by David Trattnig's avatar David Trattnig
Browse files

refactor: update fallback event, improve type info

parent 3d82b014
No related branches found
No related tags found
1 merge request!35ORM-less scheduling
...@@ -48,6 +48,8 @@ from aura_engine.resources import ( ...@@ -48,6 +48,8 @@ from aura_engine.resources import (
ResourceUtil, ResourceUtil,
) )
from aura_engine.scheduling.domain import PlaylistItem from aura_engine.scheduling.domain import PlaylistItem
from aura_engine.scheduling.scheduler import AuraScheduler
from aura_engine.scheduling.timetable import TimetableService
class Engine: class Engine:
...@@ -59,7 +61,7 @@ class Engine: ...@@ -59,7 +61,7 @@ class Engine:
logger: logging.Logger logger: logging.Logger
config: confuse.Configuration config: confuse.Configuration
engine_time_offset = 0.0 engine_time_offset = 0.0
scheduler = None scheduler: AuraScheduler = None
event_dispatcher = None event_dispatcher = None
client = None client = None
playout = None playout = None
...@@ -144,9 +146,9 @@ class Engine: ...@@ -144,9 +146,9 @@ class Engine:
state = DotDict(LU.json_to_dict(state)) state = DotDict(LU.json_to_dict(state))
def dispatch_fallback_event(): def dispatch_fallback_event():
timeslot = self.scheduler.timetable.get_current_timeslot() timetable: TimetableService = self.scheduler.get_timetable()
fallback_show_name = self.config.general.fallback_show_name timeslot = timetable.get_current_timeslot()
self.event_dispatcher.on_fallback_active(timeslot, fallback_show_name) self.event_dispatcher.on_fallback_active(timeslot)
# Initialize state # Initialize state
if not self.playout_state: if not self.playout_state:
......
...@@ -239,18 +239,26 @@ class EngineEventDispatcher: ...@@ -239,18 +239,26 @@ class EngineEventDispatcher:
thread = Thread(target=func, args=(self, channel)) thread = Thread(target=func, args=(self, channel))
thread.start() thread.start()
def on_fallback_active(self, timeslot, fallback_name): def on_fallback_active(self, timeslot):
""" """
Call when a fallback is activated for the given timeslot. Call when a fallback is activated.
This means there is no proper playlist scheduled. Fallback means the station fallback audio source is played when:
1. no timeslot is available.
2. the current timefrome of the active timeslot provides no audio source/playlists.
TODO In the future case (1) should technically not happen, as "Virtual Timeslots" ensure
there is always some timeslot available, even without any playlists/media sources assigned.
Args:
timeslot (Timeslot): The active timeslot, if available. Can be `None`.
""" """
def func(self, timeslot, fallback_type): def func(self, timeslot):
self.logger.debug("on_fallback_active(..)") self.logger.debug("on_fallback_active(..)")
self.call_event("on_fallback_active", timeslot, fallback_type) self.call_event("on_fallback_active", timeslot)
thread = Thread(target=func, args=(self, timeslot, fallback_name)) thread = Thread(target=func, args=(self, timeslot))
thread.start() thread.start()
def on_queue(self, items: list): def on_queue(self, items: list):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment