mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 15:36:59 -05:00
commit
0b8a5104a9
@ -35,5 +35,11 @@
|
||||
"config_file": false,
|
||||
"config_web": false
|
||||
}
|
||||
,
|
||||
"xmltv_offset": {
|
||||
"value": "+0000",
|
||||
"config_file": false,
|
||||
"config_web": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +155,9 @@ class Config():
|
||||
self.conf_default[section][key] = {}
|
||||
|
||||
confvalue = confimport[section][key]["value"]
|
||||
if isint(confvalue):
|
||||
if key == "xmltv_offset":
|
||||
confvalue = str(confvalue)
|
||||
elif isint(confvalue):
|
||||
confvalue = int(confvalue)
|
||||
elif isfloat(confvalue):
|
||||
confvalue = float(confvalue)
|
||||
@ -196,6 +198,8 @@ class Config():
|
||||
for (each_key, each_val) in config_handler.items(each_section):
|
||||
if not each_val:
|
||||
each_val = None
|
||||
elif each_key == "xmltv_offset":
|
||||
each_val = str(each_val)
|
||||
elif each_val.lower() in ["none"]:
|
||||
each_val = None
|
||||
elif each_val.lower() in ["false"]:
|
||||
|
||||
@ -28,8 +28,12 @@ class EPG():
|
||||
|
||||
self.def_method = self.fhdhr.config.dict["epg"]["def_method"]
|
||||
self.sleeptime = {}
|
||||
for epg_method in list(self.epg_handling.keys()):
|
||||
self.sleeptime[epg_method] = self.fhdhr.config.dict["epg"]["update_frequency"]
|
||||
for epg_method in self.epg_methods:
|
||||
if epg_method in list(self.fhdhr.config.dict.keys()):
|
||||
if "update_frequency" in list(self.fhdhr.config.dict[epg_method].keys()):
|
||||
self.sleeptime[epg_method] = self.fhdhr.config.dict[epg_method]["update_frequency"]
|
||||
if epg_method not in list(self.sleeptime.keys()):
|
||||
self.sleeptime[epg_method] = self.fhdhr.config.dict["epg"]["update_frequency"]
|
||||
|
||||
self.epg_update_url = "%s/api/epg?method=update" % (self.fhdhr.api.base)
|
||||
|
||||
@ -303,7 +307,7 @@ class EPG():
|
||||
updatetheepg = True
|
||||
if updatetheepg:
|
||||
try:
|
||||
self.fhdhr.web.session.get(self.epg_update_url, timeout=0.0000000001)
|
||||
self.fhdhr.web.session.get("%s?sorurce=%s" % (self.epg_update_url, epg_method), timeout=0.0000000001)
|
||||
except self.fhdhr.web.exceptions.ReadTimeout:
|
||||
pass
|
||||
except self.fhdhr.web.exceptions.ConnectionError as e:
|
||||
|
||||
@ -28,6 +28,7 @@ class Startup_Tasks():
|
||||
self.fhdhr.api.client.get(self.channel_update_url)
|
||||
|
||||
# Hit EPG Update API
|
||||
self.fhdhr.api.client.get(self.epg_update_url)
|
||||
for epg_method in self.fhdhr.device.epg.epg_methods:
|
||||
self.fhdhr.api.client.get("%s?sorurce=%s" % (self.epg_update_url, epg_method))
|
||||
|
||||
return "Success"
|
||||
|
||||
@ -16,6 +16,14 @@ class xmlTV():
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
self.xmltv_offset = {}
|
||||
for epg_method in list(self.fhdhr.device.epg.epg_handling.keys()):
|
||||
if epg_method in list(self.fhdhr.config.dict.keys()):
|
||||
if "xmltv_offset" in list(self.fhdhr.config.dict[epg_method].keys()):
|
||||
self.xmltv_offset[epg_method] = self.fhdhr.config.dict[epg_method]["xmltv_offset"]
|
||||
if epg_method not in list(self.xmltv_offset.keys()):
|
||||
self.xmltv_offset[epg_method] = self.fhdhr.config.dict["epg"]["xmltv_offset"]
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
@ -91,16 +99,12 @@ class xmlTV():
|
||||
"""This method is called when creation of a full xmltv is not possible"""
|
||||
return self.xmltv_file(self.xmltv_headers())
|
||||
|
||||
def timestamp_to_datetime(self, time_start, time_end):
|
||||
def timestamp_to_datetime(self, time_start, time_end, source):
|
||||
xmltvtimetamps = {}
|
||||
|
||||
source_offset = self.xmltv_offset[source]
|
||||
for time_item, time_value in zip(["time_start", "time_end"], [time_start, time_end]):
|
||||
|
||||
if str(time_value).endswith(tuple(["+0000", "+00:00"])):
|
||||
xmltvtimetamps[time_item] = str(time_value)
|
||||
else:
|
||||
xmltvtimetamps[time_item] = str(datetime.datetime.fromtimestamp(time_value)) + " +0000"
|
||||
|
||||
timestampval = datetime.datetime.fromtimestamp(time_value).strftime('%Y%m%d%H%M%S')
|
||||
xmltvtimetamps[time_item] = "%s %s" % (timestampval, source_offset)
|
||||
return xmltvtimetamps
|
||||
|
||||
def create_xmltv(self, base_url, epgdict, source):
|
||||
@ -142,7 +146,7 @@ class xmlTV():
|
||||
|
||||
for program in channel_listing:
|
||||
|
||||
xmltvtimetamps = self.timestamp_to_datetime(program['time_start'], program['time_end'])
|
||||
xmltvtimetamps = self.timestamp_to_datetime(program['time_start'], program['time_end'], source)
|
||||
|
||||
prog_out = sub_el(out, 'programme',
|
||||
start=xmltvtimetamps['time_start'],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user