fix the mess created by chatgpt
This commit is contained in:
parent
2b0ba2181b
commit
e4bd771275
1 changed files with 8 additions and 6 deletions
|
@ -69,6 +69,7 @@ def process_running_channel(database, scheduler, stream_id, stream_name, stream_
|
||||||
|
|
||||||
# Helper function to remove channel from the database
|
# Helper function to remove channel from the database
|
||||||
def remove_channel_from_database(database, scheduler, stream_id, stream_name, state):
|
def remove_channel_from_database(database, scheduler, stream_id, stream_name, state):
|
||||||
|
if stream_id in database:
|
||||||
logger_job.info(f'{stream_id} ({stream_name}) has been removed from the database. Reason: {state.exec}')
|
logger_job.info(f'{stream_id} ({stream_name}) has been removed from the database. Reason: {state.exec}')
|
||||||
database.pop(stream_id)
|
database.pop(stream_id)
|
||||||
scheduler.remove_job(stream_id)
|
scheduler.remove_job(stream_id)
|
||||||
|
@ -122,6 +123,7 @@ def core_api_sync():
|
||||||
process_running_channel(database, scheduler, stream_id, stream_name, stream_description, stream_hls_url)
|
process_running_channel(database, scheduler, stream_id, stream_name, stream_description, stream_hls_url)
|
||||||
else:
|
else:
|
||||||
remove_channel_from_database(database, scheduler, stream_id, stream_name, state)
|
remove_channel_from_database(database, scheduler, stream_id, stream_name, state)
|
||||||
|
new_ids.remove(stream_id)
|
||||||
|
|
||||||
# Cleanup orphaned references
|
# Cleanup orphaned references
|
||||||
orphan_keys = [key for key in database if key not in new_ids]
|
orphan_keys = [key for key in database if key not in new_ids]
|
||||||
|
@ -139,11 +141,11 @@ def show_scheduled_tasks():
|
||||||
# Login
|
# Login
|
||||||
try:
|
try:
|
||||||
client = Client(base_url='https://' + api_hostname, username=api_username, password=api_password)
|
client = Client(base_url='https://' + api_hostname, username=api_username, password=api_password)
|
||||||
logger_job.info('Logging in to Datarhei Core API ' + api_username + '@' + api_hostname)
|
logger_api.info('Logging in to Datarhei Core API ' + api_username + '@' + api_hostname)
|
||||||
client.login()
|
client.login()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger_job.error('client login error')
|
logger_api.error('client login error')
|
||||||
logger_job.error(err)
|
logger_api.error(err)
|
||||||
|
|
||||||
# Schedule datarhei core api sync
|
# Schedule datarhei core api sync
|
||||||
scheduler.add_job(func=core_api_sync, trigger="interval", seconds=CORE_SYNC_PERIOD, id="core_api_sync")
|
scheduler.add_job(func=core_api_sync, trigger="interval", seconds=CORE_SYNC_PERIOD, id="core_api_sync")
|
||||||
|
|
Loading…
Reference in a new issue