diff --git a/fHDHR/device/tuners/stream/direct_m3u8_stream.py b/fHDHR/device/tuners/stream/direct_m3u8_stream.py index 4572828..7ac4840 100644 --- a/fHDHR/device/tuners/stream/direct_m3u8_stream.py +++ b/fHDHR/device/tuners/stream/direct_m3u8_stream.py @@ -101,6 +101,8 @@ class Direct_M3U8_Stream(): self.fhdhr.logger.info("Connection Closed: %s" % e) finally: self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed") + if hasattr(self.fhdhr.origins.origins_dict[self.tuner.origin], "close_stream"): + self.fhdhr.origins.origins_dict[self.tuner.origin].close_stream(self.tuner.number, self.stream_args) self.tuner.close() # raise TunerError("806 - Tune Failed") diff --git a/fHDHR/device/tuners/stream/direct_stream.py b/fHDHR/device/tuners/stream/direct_stream.py index 7547aaf..086ff4b 100644 --- a/fHDHR/device/tuners/stream/direct_stream.py +++ b/fHDHR/device/tuners/stream/direct_stream.py @@ -64,6 +64,8 @@ class Direct_Stream(): finally: req.close() self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed") + if hasattr(self.fhdhr.origins.origins_dict[self.tuner.origin], "close_stream"): + self.fhdhr.origins.origins_dict[self.tuner.origin].close_stream(self.tuner.number, self.stream_args) self.tuner.close() # raise TunerError("806 - Tune Failed") diff --git a/fHDHR/origins/__init__.py b/fHDHR/origins/__init__.py index b960cab..1f761b1 100644 --- a/fHDHR/origins/__init__.py +++ b/fHDHR/origins/__init__.py @@ -43,3 +43,6 @@ class Origins(): if not hasattr(self.origins_dict[method], 'tuners'): self.origins_dict[method].tuners = 4 + + if not hasattr(self.origins_dict[method], 'stream_method'): + self.origins_dict[method].stream_method = self.fhdhr.config.dict["streaming"]["method"] diff --git a/fHDHR_web/api/channels.py b/fHDHR_web/api/channels.py index 5ab1595..4418eb1 100644 --- a/fHDHR_web/api/channels.py +++ b/fHDHR_web/api/channels.py @@ -26,7 +26,7 @@ class Channels(): origin_methods = self.fhdhr.origins.valid_origins origin = request.args.get('origin', default=None, type=str) - if origin not in origin_methods: + if origin and origin not in origin_methods: return "%s Invalid channels origin" % origin if method == "get": diff --git a/fHDHR_web/api/m3u.py b/fHDHR_web/api/m3u.py index deffe8a..f39054c 100644 --- a/fHDHR_web/api/m3u.py +++ b/fHDHR_web/api/m3u.py @@ -63,6 +63,13 @@ class M3U(): channel_items.append(channel_obj) else: return "Channel Disabled" + elif not origin and channel == "all" and str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("id")]: + fileName = "channels.m3u" + for origin in list(self.fhdhr.origins.origins_dict.keys()): + for fhdhr_id in [x["id"] for x in self.fhdhr.device.channels.get_channels(origin)]: + channel_obj = self.fhdhr.device.channels.get_channel_obj("id", fhdhr_id, origin) + if channel_obj.enabled: + channel_items.append(channel_obj) elif not origin and channel != "all" and str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("id")]: channel_obj = self.fhdhr.device.channels.get_channel_obj("id", channel) fileName = "%s.m3u" % channel_obj.number @@ -88,7 +95,7 @@ class M3U(): "tvg-name": str(channel_obj.dict['name']), "tvg-id": str(channel_obj.number), "tvg-logo": logourl, - "group-title": self.fhdhr.config.dict["fhdhr"]["friendlyname"], + "group-title": channel_obj.origin, "group-titleb": str(channel_obj.dict['name']), "stream_url": "%s%s" % (base_url, channel_obj.api_stream_url) } diff --git a/fHDHR_web/api/w3u.py b/fHDHR_web/api/w3u.py index 083057f..390a01a 100644 --- a/fHDHR_web/api/w3u.py +++ b/fHDHR_web/api/w3u.py @@ -31,7 +31,7 @@ class W3U(): if origin and origin not in origin_methods: return "%s Invalid channels origin" % origin - channel_info_m3u = { + channel_info_w3u = { "name": self.fhdhr.config.dict["fhdhr"]["friendlyname"], "image": '%s/favicon.ico' % base_url, "epg": '%s/api/xmltv' % base_url, @@ -42,28 +42,35 @@ class W3U(): if origin: if channel == "all": - fileName = "channels.m3u" + fileName = "channels.w3u" for fhdhr_id in [x["id"] for x in self.fhdhr.device.channels.get_channels(origin)]: channel_obj = self.fhdhr.device.channels.get_channel_obj("id", fhdhr_id, origin) if channel_obj.enabled: channel_items.append(channel_obj) elif str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number", origin)]: channel_obj = self.fhdhr.device.channels.get_channel_obj("number", channel, origin) - fileName = "%s.m3u" % channel_obj.number + fileName = "%s.w3u" % channel_obj.number if channel_obj.enabled: channel_items.append(channel_obj) else: return "Channel Disabled" elif channel != "all" and str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("id", origin)]: channel_obj = self.fhdhr.device.channels.get_channel_obj("id", channel, origin) - fileName = "%s.m3u" % channel_obj.number + fileName = "%s.w3u" % channel_obj.number if channel_obj.enabled: channel_items.append(channel_obj) else: return "Channel Disabled" + elif not origin and channel == "all" and str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("id")]: + fileName = "channels.w3u" + for origin in list(self.fhdhr.origins.origins_dict.keys()): + for fhdhr_id in [x["id"] for x in self.fhdhr.device.channels.get_channels(origin)]: + channel_obj = self.fhdhr.device.channels.get_channel_obj("id", fhdhr_id, origin) + if channel_obj.enabled: + channel_items.append(channel_obj) elif not origin and channel != "all" and str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("id")]: channel_obj = self.fhdhr.device.channels.get_channel_obj("id", channel) - fileName = "%s.m3u" % channel_obj.number + fileName = "%s.w3u" % channel_obj.number if channel_obj.enabled: channel_items.append(channel_obj) else: @@ -91,9 +98,9 @@ class W3U(): # Sort the channels sorted_channel_list = channel_sort(list(channels_info.keys())) for channel in sorted_channel_list: - channel_info_m3u["stations"].append(channels_info[channel]) + channel_info_w3u["stations"].append(channels_info[channel]) - channels_info_json = json.dumps(channel_info_m3u, indent=4) + channels_info_json = json.dumps(channel_info_w3u, indent=4) resp = Response(status=200, response=channels_info_json, mimetype='application/json') resp.headers["content-disposition"] = "attachment; filename=%s" % fileName diff --git a/fHDHR_web/brython/brython_code.py b/fHDHR_web/brython/brython_code.py index 04ed0eb..7bdc0c8 100644 --- a/fHDHR_web/brython/brython_code.py +++ b/fHDHR_web/brython/brython_code.py @@ -36,9 +36,10 @@ def chan_edit_data(items, channel_id): def chan_edit_postform(chanlist): + origin = document["origin"].value postForm = document.createElement('form') postForm.method = "POST" - postForm.action = "/api/channels?method=modify&redirect=/channels_editor" + postForm.action = "/api/channels?method=modify&origin=%s&redirect=/channels_editor&origin=%s" % (origin, origin) postForm.setRequestHeader = "('Content-Type', 'application/json')" postData = document.createElement('input') diff --git a/fHDHR_web/templates/channels_editor.html b/fHDHR_web/templates/channels_editor.html index 2635fe5..6459635 100644 --- a/fHDHR_web/templates/channels_editor.html +++ b/fHDHR_web/templates/channels_editor.html @@ -3,6 +3,7 @@ {% block content %}

{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels Editor

+
diff --git a/plugins/fHDHR_plugin_stream_ffmpeg/__init__.py b/plugins/fHDHR_plugin_stream_ffmpeg/__init__.py index 9d510a0..9cfe60d 100644 --- a/plugins/fHDHR_plugin_stream_ffmpeg/__init__.py +++ b/plugins/fHDHR_plugin_stream_ffmpeg/__init__.py @@ -57,6 +57,8 @@ class Plugin_OBJ(): ffmpeg_proc.communicate() ffmpeg_proc.kill() self.plugin_utils.logger.info("Connection Closed: Tuner Lock Removed") + if hasattr(self.fhdhr.origins.origins_dict[self.tuner.origin], "close_stream"): + self.fhdhr.origins.origins_dict[self.tuner.origin].close_stream(self.tuner.number, self.stream_args) self.tuner.close() # raise TunerError("806 - Tune Failed") diff --git a/plugins/fHDHR_plugin_stream_vlc/__init__.py b/plugins/fHDHR_plugin_stream_vlc/__init__.py index 13d90f2..3e5b8bd 100644 --- a/plugins/fHDHR_plugin_stream_vlc/__init__.py +++ b/plugins/fHDHR_plugin_stream_vlc/__init__.py @@ -58,6 +58,8 @@ class Plugin_OBJ(): vlc_proc.communicate() vlc_proc.kill() self.plugin_utils.logger.info("Connection Closed: Tuner Lock Removed") + if hasattr(self.fhdhr.origins.origins_dict[self.tuner.origin], "close_stream"): + self.fhdhr.origins.origins_dict[self.tuner.origin].close_stream(self.tuner.number, self.stream_args) self.tuner.close() # raise TunerError("806 - Tune Failed")