diff --git a/fHDHR/device/channels/__init__.py b/fHDHR/device/channels/__init__.py index 36d85af..99631a7 100644 --- a/fHDHR/device/channels/__init__.py +++ b/fHDHR/device/channels/__init__.py @@ -70,13 +70,20 @@ class Channels(): updatelist = True if updatelist: + channel_origin_id_list = [str(self.list[x].dict["origin_id"]) for x in list(self.list.keys())] self.fhdhr.logger.info("Performing Channel Scan.") channel_dict_list = self.origin.get_channels() for channel_info in channel_dict_list: - channel_obj = Channel(self.fhdhr, self.id_system, origin_id=channel_info["id"]) + chan_existing = False + if str(channel_info["id"]) in channel_origin_id_list: + chan_existing = True + channel_obj = self.get_channel_obj("origin_id", channel_info["id"]) + else: + channel_obj = Channel(self.fhdhr, self.id_system, origin_id=channel_info["id"]) channel_id = channel_obj.dict["id"] channel_obj.basics(channel_info) - self.list[channel_id] = channel_obj + if not chan_existing: + self.list[channel_id] = channel_obj if not self.list_update_time: self.fhdhr.logger.info("Found " + str(len(self.list)) + " channels for " + str(self.fhdhr.config.dict["main"]["servicename"])) diff --git a/fHDHR/device/epg/__init__.py b/fHDHR/device/epg/__init__.py index b79dca5..4d7e817 100644 --- a/fHDHR/device/epg/__init__.py +++ b/fHDHR/device/epg/__init__.py @@ -36,6 +36,13 @@ class EPG(): if epg_method not in list(self.sleeptime.keys()): self.sleeptime[epg_method] = self.fhdhr.config.dict["epg"]["update_frequency"] + if self.fhdhr.config.dict["fhdhr"]["address"] == "0.0.0.0": + self.location = ('http://127.0.0.1:%s' % str(self.fhdhr.config.dict["fhdhr"]["port"])) + else: + self.location = ('http://%s:%s' % (self.fhdhr.config.dict["fhdhr"]["address"], str(self.fhdhr.config.dict["fhdhr"]["port"]))) + + self.epg_update_url = "%s/api/epg?method=update" % (self.location) + def clear_epg_cache(self, method=None): if not method: @@ -178,12 +185,12 @@ class EPG(): def run(self): for epg_method in self.epg_methods: - self.update(epg_method) + self.fhdhr.web.session.get(self.epg_update_url) try: while True: for epg_method in self.epg_methods: if time.time() >= (self.fhdhr.db.get_fhdhr_value("update_time", epg_method) + self.sleeptime[epg_method]): - self.update(epg_method) - time.sleep(3600) + self.fhdhr.web.session.get(self.epg_update_url) + time.sleep(360) except KeyboardInterrupt: pass