From b12e825f3a632779de58cb2f1587381b6cef82d0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 9 Oct 2020 16:01:15 -0400 Subject: [PATCH] Add Additional Functionality --- data/internal_config/fhdhr.ini | 1 + fHDHR/fHDHRweb/__init__.py | 26 +++++++++++++++++++++ fHDHR/fHDHRweb/fHDHRdevice/discover_json.py | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/data/internal_config/fhdhr.ini b/data/internal_config/fhdhr.ini index 8114878..d44f92a 100644 --- a/data/internal_config/fhdhr.ini +++ b/data/internal_config/fhdhr.ini @@ -22,3 +22,4 @@ reporting_manufacturer = BoronDust reporting_model = fHDHR reporting_firmware_ver = 20201001 reporting_tuner_type = Antenna +device_auth = fHDHR diff --git a/fHDHR/fHDHRweb/__init__.py b/fHDHR/fHDHRweb/__init__.py index 3aab69b..3b23e68 100644 --- a/fHDHR/fHDHRweb/__init__.py +++ b/fHDHR/fHDHRweb/__init__.py @@ -135,6 +135,17 @@ class HDHR_HTTP_Server(): response=xmltv, mimetype='application/xml') + @app.route('/api/xmltv') + def api_xmltv(): + if 'DeviceAuth' in list(request.args.keys()): + if request.args['DeviceAuth'] == hdhr.config.dict["dev"]["device_auth"]: + base_url = request.headers["host"] + xmltv = hdhr.get_xmltv(base_url) + return Response(status=200, + response=xmltv, + mimetype='application/xml') + return "not subscribed" + @app.route('/debug.json', methods=['GET']) def debug_json(): base_url = request.headers["host"] @@ -148,6 +159,21 @@ class HDHR_HTTP_Server(): image, imagetype = hdhr.get_image(request.args) return Response(image, content_type=imagetype, direct_passthrough=True) + @app.route('/auto/') + def auto(channel): + request_args = { + "channel": channel.replace('v', ''), + "method": hdhr.config.dict["fhdhr"]["stream_type"] + } + channel_id = request_args["channel"] + method, channelUri, content_type = hdhr.get_stream_info(request_args) + if channelUri: + if method == "direct": + return Response(hdhr.get_stream(channel_id, method, channelUri, content_type), content_type=content_type, direct_passthrough=True) + elif method == "ffmpeg": + return Response(stream_with_context(hdhr.get_stream(channel_id, method, channelUri, content_type)), mimetype="video/mpeg") + abort(503) + @app.route('/watch', methods=['GET']) def watch(): if 'method' in list(request.args.keys()) and 'channel' in list(request.args.keys()): diff --git a/fHDHR/fHDHRweb/fHDHRdevice/discover_json.py b/fHDHR/fHDHRweb/fHDHRdevice/discover_json.py index c673057..5cc07fb 100644 --- a/fHDHR/fHDHRweb/fHDHRdevice/discover_json.py +++ b/fHDHR/fHDHRweb/fHDHRdevice/discover_json.py @@ -17,7 +17,7 @@ class Discover_JSON(): "TunerCount": self.config.dict["fhdhr"]["tuner_count"], "FirmwareVersion": self.config.dict["dev"]["reporting_firmware_ver"], "DeviceID": self.config.dict["main"]["uuid"], - "DeviceAuth": "fHDHR", + "DeviceAuth": self.config.dict["dev"]["device_auth"], "BaseURL": "http://" + base_url, "LineupURL": "http://" + base_url + "/lineup.json" }