1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 11:36:59 -05:00

Merge pull request #18 from deathbybandaid/dev

Better xmltv handling
This commit is contained in:
Deathbybandaid 2020-10-09 08:22:02 -04:00 committed by GitHub
commit 3aee9dd4a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,5 @@
import xml.etree.ElementTree
from io import BytesIO
import time
from fHDHR.tools import sub_el
@ -12,28 +11,11 @@ class xmlTV_XML():
def __init__(self, settings, epghandling):
self.config = settings
self.epghandling = epghandling
self.updated_at = None
self.epg_method = self.config.dict["fhdhr"]["epg_method"]
self.epg_sleeptime = self.config.dict[self.epg_method]["epg_update_frequency"]
def get_xmltv_xml(self, base_url, force_update=False):
nowtime = time.time()
update_xmltv = False
def get_xmltv_xml(self, base_url):
if not self.xmltv_xml or force_update:
update_xmltv = True
elif not self.updated_at:
update_xmltv = True
elif nowtime >= (self.updated_at + self.epg_sleeptime):
update_xmltv = True
if update_xmltv:
print("Updating xmltv cache.")
epgdict = self.epghandling.epgtypes.get_epg()
self.xmltv_xml = self.create_xmltv(base_url, epgdict)
self.updated_at = nowtime
return self.xmltv_xml
return self.create_xmltv(base_url, epgdict)
def xmltv_headers(self):
"""This method creates the XML headers for our xmltv"""