From 967b2a4166c07ce137d965d6236294f9c04f9ddc Mon Sep 17 00:00:00 2001 From: deflax Date: Sun, 7 Jan 2024 04:01:27 +0200 Subject: [PATCH] update the head based on global and stream prio --- src/scheduler/app.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/scheduler/app.py b/src/scheduler/app.py index 35578f1..616b2de 100644 --- a/src/scheduler/app.py +++ b/src/scheduler/app.py @@ -84,13 +84,24 @@ def find_event_entry(events, target_name): return {"start_at": entry.get("start_at"), "prio": entry.get("prio")} return None +# Helper function to update the head +def update_head(stream_hls_url): + head = { "head": stream_hls_url } + logger_job.info(f'Head position is: {str(head)}') + # Tasks def stream_exec(stream_name, stream_prio, stream_hls_url): global head - logger_job.info('Hello {}, your priority is: {}'. format(stream_name, stream_prio)) - head = { "head": stream_hls_url } - logger_job.info('head position is: ' + str(head)) - + global prio + logger_job.info(f'Hello {stream_name}!') + if stream_prio > prio: + logger_job.info(f'Source priority is now set to: {stream_prio}') + update_head(stream_hls_url) + elif stream_prio == prio: + update_head(stream_hls_url) + elif stream_prio < prio: + logger_job.warning(f'Source with higher priority ({prio}) is blocking. Skipping head update!') + def core_api_sync(): global database global epg