From d0419ebe73cf55e2c87d2c1b8531b1ce839b4126 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Thu, 28 Sep 2023 07:44:40 +1000 Subject: [PATCH] restreamer: Expose an endpoint for listing files that aren't segments --- restreamer/restreamer/main.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/restreamer/restreamer/main.py b/restreamer/restreamer/main.py index a0f7d0f..c426a2a 100644 --- a/restreamer/restreamer/main.py +++ b/restreamer/restreamer/main.py @@ -155,6 +155,23 @@ def list_segments(channel, quality, hour): return json.dumps(list_segment_files(path, include_tombstones=tombstones, include_chat=True)) +@app.route('/extras/') +@request_stats +@has_path_args +def list_extras(dir): + """List all files under directory recursively. All paths returned are relative to dir. + Files can be fetched under /segments//. + Note this is only intended for extra files, and not for segments. + """ + root = os.path.join(app.static_folder, dir) + result = [] + for path, subdirs, files in os.walk(root): + relpath = os.path.relpath(path, root) + for file in files: + result.append(os.path.normpath(os.path.join(relpath, file))) + return json.dumps(result) + + @app.route('/thumbnail-templates') def list_thumbnail_templates(): """List available thumbnail templates. Returns a JSON list of names."""