Dont add the meta in the db directly. Check for optional details

This commit is contained in:
deflax 2025-03-05 23:33:52 +00:00
parent c36a69172c
commit 7a89d2605f
2 changed files with 14 additions and 7 deletions

View file

@ -61,7 +61,14 @@ def process_running_channel(database, scheduler, stream_id, stream_name, stream_
except Exception as e: except Exception as e:
# Skip channels without readable meta # Skip channels without readable meta
return return
logger_job.warning(f'{stream_id} ({stream_name}) has been registered with {api_settings} ') logger_job.warning(f'{stream_id} ({stream_name}) found. {api_settings} ')
# Check whether we have stream details
try:
stream_details = api_settings.get('details')
logger_job.warning(f'Details found: {stream_details}')
except Exception as e:
stream_details = ""
if stream_start == "now": if stream_start == "now":
# Check if the stream_hls_url returns 200 # Check if the stream_hls_url returns 200
@ -83,7 +90,7 @@ def process_running_channel(database, scheduler, stream_id, stream_name, stream_
func=exec_stream, trigger='cron', hour=stream_start, jitter=60, func=exec_stream, trigger='cron', hour=stream_start, jitter=60,
id=stream_id, args=(stream_id, stream_name, stream_prio, stream_hls_url) id=stream_id, args=(stream_id, stream_name, stream_prio, stream_hls_url)
) )
database.update({stream_id: {'name': stream_name, 'start_at': stream_start, 'meta': stream_description, 'src': stream_hls_url}}) database.update({stream_id: {'name': stream_name, 'start_at': stream_start, 'details': stream_details, 'src': stream_hls_url}})
# Bootstrap the playhead if its still empty. # Bootstrap the playhead if its still empty.
if playhead == {}: if playhead == {}:

View file

@ -164,13 +164,13 @@ async def query_database():
for key, value in database.items(): for key, value in database.items():
stream_name = value['name'] stream_name = value['name']
stream_start_at = value['start_at'] stream_start_at = value['start_at']
stream_meta = value['meta'] stream_details = value['details']
if stream_start_at == 'now': if stream_start_at == 'now':
# Check if the announement job already exists # Check if the announement job already exists
if scheduler.get_job('announce_live_channel') is None: if scheduler.get_job('announce_live_channel') is None:
# Job doesn't exist, so add it # Job doesn't exist, so add it
logger_discord.info(f'{stream_name} live stream detected!') logger_discord.info(f'{stream_name} live stream detected!')
scheduler.add_job(func=announce_live_channel, trigger='interval', minutes=int(live_channel_update), id='announce_live_channel', args=(stream_name, stream_meta)) scheduler.add_job(func=announce_live_channel, trigger='interval', minutes=int(live_channel_update), id='announce_live_channel', args=(stream_name, stream_details))
scheduler.get_job('announce_live_channel').modify(next_run_time=datetime.now()) scheduler.get_job('announce_live_channel').modify(next_run_time=datetime.now())
return return
else: else:
@ -185,11 +185,11 @@ async def query_database():
await live_channel.send(f'{stream_name} is offline.') await live_channel.send(f'{stream_name} is offline.')
logger_discord.info(f'{stream_name} is offline.') logger_discord.info(f'{stream_name} is offline.')
async def announce_live_channel(stream_name, stream_meta): async def announce_live_channel(stream_name, stream_details):
if live_channel_id != 0: if live_channel_id != 0:
live_channel = bot.get_channel(int(live_channel_id)) live_channel = bot.get_channel(int(live_channel_id))
await live_channel.send(f'{stream_name} is live! :satellite_orbital: {stream_meta}') await live_channel.send(f'{stream_name} is live! :satellite_orbital: {stream_details}')
logger_discord.info(f'{stream_name} is live! {stream_meta}') logger_discord.info(f'{stream_name} is live! {stream_details}')
# Execute recorder # Execute recorder
async def exec_recorder(playhead): async def exec_recorder(playhead):