expose rechead json

This commit is contained in:
deflax 2024-01-17 20:32:48 +02:00
parent 6b36db48aa
commit 19271fe016
2 changed files with 12 additions and 6 deletions

View file

@ -86,7 +86,7 @@ async def query_playhead():
logger_discord.error('Cannot connect to the playhead!')
head_name = playhead['name']
head_prio = playhead['prio']
return f'```Now playing {head_name}. Priority={head_prio}```'
return f'```Now playing {head_name}. priority={head_prio}```'
async def query_database():
global database

View file

@ -30,9 +30,9 @@ enable_delay = 24
# Init
database = {}
prio = 0
playhead = {}
rechead = ""
rechead = {}
prio = 0
with open('/config/epg.json', 'r') as epg_json:
epg = json.load(epg_json)
@ -165,11 +165,12 @@ def exec_recorder(stream_id, stream_hls_url):
global rechead
current_datetime = datetime.now().strftime("%Y-%m-%d_%H-%M-%S-%f")
output_file = current_datetime + ".mp4"
if rechead != "":
if rechead != {}:
logger_job.error('Recorder is already started. Refusing to start another job.')
else:
logger_job.warning(f'Recording {output_file} started.')
rechead = stream_id
rechead = { 'id': stream_id,
'file': output_file }
output = f'{rec_path}/live/{output_file}'
ffmpeg = (
FFmpeg()
@ -186,7 +187,7 @@ def exec_recorder(stream_id, stream_hls_url):
ffmpeg.execute()
logger_job.warning(f'Recording {output_file} finished. Moving file to {rec_path}/vod')
os.rename(f'{rec_path}/live/{output_file}', f'{rec_path}/vod/{output_file}')
rechead = ""
rechead = {}
# Datarhei CORE API sync
def core_api_sync():
@ -261,6 +262,11 @@ def playhead_route():
global playhead
return jsonify(playhead)
@app.route('/rechead', methods=['GET'])
def rechead_route():
global rechead
return jsonify(rechead)
@app.route('/database', methods=['GET'])
def database_route():
global database