Compare commits

...

2 commits

2 changed files with 14 additions and 11 deletions

View file

@ -61,7 +61,14 @@ def process_running_channel(database, scheduler, stream_id, stream_name, stream_
except Exception as e:
# Skip channels without readable meta
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":
# 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,
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.
if playhead == {}:

View file

@ -164,13 +164,13 @@ async def query_database():
for key, value in database.items():
stream_name = value['name']
stream_start_at = value['start_at']
stream_meta = value['meta']
stream_details = value['details']
if stream_start_at == 'now':
# Check if the announement job already exists
if scheduler.get_job('announce_live_channel') is None:
# Job doesn't exist, so add it
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())
return
else:
@ -180,16 +180,12 @@ async def query_database():
# Cleanup the announce job
if scheduler.get_job('announce_live_channel') is not None:
scheduler.remove_job('announce_live_channel')
if live_channel_id != 0:
live_channel = bot.get_channel(int(live_channel_id))
await live_channel.send(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:
live_channel = bot.get_channel(int(live_channel_id))
await live_channel.send(f'{stream_name} is live! :satellite_orbital: {stream_meta}')
logger_discord.info(f'{stream_name} is live! {stream_meta}')
await live_channel.send(f'{stream_name} is live! :satellite_orbital: {stream_details}')
logger_discord.info(f'{stream_name} is live! {stream_details}')
# Execute recorder
async def exec_recorder(playhead):