From 306ac53d08984d9cd3b8fcb77ee3aa6c41eb7bff Mon Sep 17 00:00:00 2001 From: MasterGunner Date: Tue, 8 Jan 2019 18:17:46 -0400 Subject: [PATCH] Added additional routes for listing available streams and variants. --- restreamer/restreamer/main.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/restreamer/restreamer/main.py b/restreamer/restreamer/main.py index 93af7cc..98c5689 100644 --- a/restreamer/restreamer/main.py +++ b/restreamer/restreamer/main.py @@ -90,6 +90,29 @@ def metrics(): """Return current metrics in prometheus metrics format""" return prom.generate_latest() +@app.route('/files') +@stats +@has_path_args +def list_streams(): + """Returns a JSON list of streams for which there may be segments available. + Returns empty list if no streams are available. + """ + path = app.static_folder + return json.dumps(listdir(path, error=False)) + + +@app.route('/files/') +@stats +@has_path_args +def list_variants(stream): + """Returns a JSON list of variants for the given stream for which there may + be segments available. Returns empty list on non-existent streams, etc. + """ + path = os.path.join( + app.static_folder, + stream, + ) + return json.dumps(listdir(path, error=False)) @app.route('/files//') @stats