1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 08:26:57 -05:00

Merge pull request #80 from deathbybandaid/dev

Dev
This commit is contained in:
Deathbybandaid 2020-12-07 16:39:36 -05:00 committed by GitHub
commit 83b16f1460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 7 deletions

View File

@ -70,12 +70,19 @@ class Channels():
updatelist = True updatelist = True
if updatelist: 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.") self.fhdhr.logger.info("Performing Channel Scan.")
channel_dict_list = self.origin.get_channels() channel_dict_list = self.origin.get_channels()
for channel_info in channel_dict_list: for channel_info in channel_dict_list:
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_obj = Channel(self.fhdhr, self.id_system, origin_id=channel_info["id"])
channel_id = channel_obj.dict["id"] channel_id = channel_obj.dict["id"]
channel_obj.basics(channel_info) channel_obj.basics(channel_info)
if not chan_existing:
self.list[channel_id] = channel_obj self.list[channel_id] = channel_obj
if not self.list_update_time: if not self.list_update_time:

View File

@ -36,6 +36,13 @@ class EPG():
if epg_method not in list(self.sleeptime.keys()): if epg_method not in list(self.sleeptime.keys()):
self.sleeptime[epg_method] = self.fhdhr.config.dict["epg"]["update_frequency"] 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): def clear_epg_cache(self, method=None):
if not method: if not method:
@ -178,12 +185,12 @@ class EPG():
def run(self): def run(self):
for epg_method in self.epg_methods: for epg_method in self.epg_methods:
self.update(epg_method) self.fhdhr.web.session.get(self.epg_update_url)
try: try:
while True: while True:
for epg_method in self.epg_methods: for epg_method in self.epg_methods:
if time.time() >= (self.fhdhr.db.get_fhdhr_value("update_time", epg_method) + self.sleeptime[epg_method]): if time.time() >= (self.fhdhr.db.get_fhdhr_value("update_time", epg_method) + self.sleeptime[epg_method]):
self.update(epg_method) self.fhdhr.web.session.get(self.epg_update_url)
time.sleep(3600) time.sleep(360)
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass

View File

@ -28,6 +28,16 @@ class EPG():
if method == "get": if method == "get":
epgdict = self.fhdhr.device.epg.get_epg(source) 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
epg_json = json.dumps(epgdict, indent=4) epg_json = json.dumps(epgdict, indent=4)
return Response(status=200, return Response(status=200,

View File

@ -81,13 +81,13 @@ class xmlTV():
def create_xmltv(self, base_url, epgdict, source): def create_xmltv(self, base_url, epgdict, source):
if not epgdict: if not epgdict:
return self.xmltv_empty() return self.xmltv_empty()
epgdict.copy() epgdict = epgdict.copy()
out = self.xmltv_headers() out = self.xmltv_headers()
if source in ["origin", "blocks", self.fhdhr.config.dict["main"]["dictpopname"]]: if source in ["origin", "blocks", self.fhdhr.config.dict["main"]["dictpopname"]]:
for c in list(epgdict.keys()): for c in list(epgdict.keys()):
chan_obj = self.fhdhr.channels.get_channel_obj("origin_id", c["id"]) 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"]] = epgdict.pop(c)
epgdict[chan_obj.dict["number"]]["name"] = chan_obj.dict["name"] 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"]]["callsign"] = chan_obj.dict["callsign"]