From 304919b3b4dd944d387dfe7491ce813c58961c98 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 9 Dec 2020 16:42:25 -0500 Subject: [PATCH] test --- fHDHR/config/__init__.py | 12 +++++++++--- fHDHR/device/epg/__init__.py | 3 +++ fHDHR_web/api/epg.py | 19 ++++++++++--------- fHDHR_web/api/xmltv.py | 12 ++++++++++++ 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/fHDHR/config/__init__.py b/fHDHR/config/__init__.py index cd4fd7b..1921cf7 100644 --- a/fHDHR/config/__init__.py +++ b/fHDHR/config/__init__.py @@ -53,9 +53,15 @@ class Config(): for dir_type in ["alternative_epg", "origin"]: for file_item in os.listdir(self.internal["paths"][dir_type]): - file_item_path = os.path.join(self.internal["paths"][dir_type], file_item) - if str(file_item_path).endswith("_conf.json"): - self.read_json_config(file_item_path) + file_item_path = pathlib.Path(self.internal["paths"][dir_type]).joinpath(file_item) + if file_item_path.is_dir(): + for sub_file_item in os.listdir(file_item_path): + sub_file_item_path = pathlib.Path(file_item_path).joinpath(sub_file_item) + if str(sub_file_item_path).endswith("_conf.json"): + self.read_json_config(sub_file_item_path) + else: + if str(file_item_path).endswith("_conf.json"): + self.read_json_config(file_item_path) print("Loading Configuration File: " + str(self.config_file)) self.read_ini_config(self.config_file) diff --git a/fHDHR/device/epg/__init__.py b/fHDHR/device/epg/__init__.py index b519727..9f5a8f8 100644 --- a/fHDHR/device/epg/__init__.py +++ b/fHDHR/device/epg/__init__.py @@ -140,6 +140,9 @@ class EPG(): if entry.is_file(): if entry.name[0] != '_' and entry.name.endswith(".py"): new_epgtype_list.append(str(entry.name[:-3])) + elif entry.is_dir(): + if entry.name[0] != '_': + new_epgtype_list.append(str(entry.name)) for method in new_epgtype_list: self.fhdhr.logger.info("Found %s EPG method." % method) self.epg_handling[method] = eval("self.alternative_epg.%s.%sEPG(self.fhdhr, self.channels)" % (method, method)) diff --git a/fHDHR_web/api/epg.py b/fHDHR_web/api/epg.py index d7c67ec..c7dcc69 100644 --- a/fHDHR_web/api/epg.py +++ b/fHDHR_web/api/epg.py @@ -28,15 +28,16 @@ class EPG(): if method == "get": epgdict = self.fhdhr.device.epg.get_epg(source) - epgdict = epgdict.copy() - for c in list(epgdict.keys()): - chan_obj = self.fhdhr.device.channels.get_channel_obj("origin_id", epgdict[c]["id"]) - epgdict[chan_obj.dict["number"]] = epgdict.pop(c) - epgdict[chan_obj.dict["number"]]["name"] = chan_obj.dict["name"] - epgdict[chan_obj.dict["number"]]["callsign"] = chan_obj.dict["callsign"] - epgdict[chan_obj.dict["number"]]["number"] = chan_obj.dict["number"] - epgdict[chan_obj.dict["number"]]["id"] = chan_obj.dict["origin_id"] - epgdict[chan_obj.dict["number"]]["thumbnail"] = chan_obj.thumbnail + if source in ["blocks", "origin", self.fhdhr.config.dict["main"]["dictpopname"]]: + epgdict = epgdict.copy() + for c in list(epgdict.keys()): + chan_obj = self.fhdhr.device.channels.get_channel_obj("origin_id", epgdict[c]["id"]) + epgdict[chan_obj.dict["number"]] = epgdict.pop(c) + epgdict[chan_obj.dict["number"]]["name"] = chan_obj.dict["name"] + epgdict[chan_obj.dict["number"]]["callsign"] = chan_obj.dict["callsign"] + epgdict[chan_obj.dict["number"]]["number"] = chan_obj.dict["number"] + epgdict[chan_obj.dict["number"]]["id"] = chan_obj.dict["origin_id"] + epgdict[chan_obj.dict["number"]]["thumbnail"] = chan_obj.thumbnail epg_json = json.dumps(epgdict, indent=4) diff --git a/fHDHR_web/api/xmltv.py b/fHDHR_web/api/xmltv.py index a4064fb..690794f 100644 --- a/fHDHR_web/api/xmltv.py +++ b/fHDHR_web/api/xmltv.py @@ -38,6 +38,18 @@ class xmlTV(): if method == "get": epgdict = self.fhdhr.device.epg.get_epg(source) + + if source in ["blocks", "origin", self.fhdhr.config.dict["main"]["dictpopname"]]: + epgdict = epgdict.copy() + for c in list(epgdict.keys()): + chan_obj = self.fhdhr.device.channels.get_channel_obj("origin_id", epgdict[c]["id"]) + epgdict[chan_obj.dict["number"]] = epgdict.pop(c) + epgdict[chan_obj.dict["number"]]["name"] = chan_obj.dict["name"] + epgdict[chan_obj.dict["number"]]["callsign"] = chan_obj.dict["callsign"] + epgdict[chan_obj.dict["number"]]["number"] = chan_obj.dict["number"] + epgdict[chan_obj.dict["number"]]["id"] = chan_obj.dict["origin_id"] + epgdict[chan_obj.dict["number"]]["thumbnail"] = chan_obj.thumbnail + xmltv_xml = self.create_xmltv(base_url, epgdict, source) return Response(status=200,