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