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

Merge pull request #90 from deathbybandaid/dev

Dev
This commit is contained in:
Deathbybandaid 2020-12-16 09:38:21 -05:00 committed by GitHub
commit 91926a2dcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 11 deletions

View File

@ -52,13 +52,6 @@ def run(settings, logger, db, script_dir, fHDHR_web, origin, alternative_epg):
if settings.dict["main"]["thread_method"] in ["multiprocessing", "threading"]: if settings.dict["main"]["thread_method"] in ["multiprocessing", "threading"]:
fhdhr_web.start() fhdhr_web.start()
# Perform some actions now that HTTP Server is running, but don't wait for response
# Hit EPG Update API URL without waiting
try:
fhdhr.web.session.get("%s/api/startup_tasks" % (fhdhr.api.base))
except fhdhr.web.exceptions.ReadTimeout:
pass
if settings.dict["fhdhr"]["discovery_address"]: if settings.dict["fhdhr"]["discovery_address"]:
fhdhr.logger.info("SSDP Server Starting") fhdhr.logger.info("SSDP Server Starting")
if settings.dict["main"]["thread_method"] in ["multiprocessing"]: if settings.dict["main"]["thread_method"] in ["multiprocessing"]:
@ -69,7 +62,7 @@ def run(settings, logger, db, script_dir, fHDHR_web, origin, alternative_epg):
fhdhr_ssdp.start() fhdhr_ssdp.start()
if settings.dict["epg"]["method"]: if settings.dict["epg"]["method"]:
fhdhr.logger.info("EPG Update Starting") fhdhr.logger.info("EPG Update Thread Starting")
if settings.dict["main"]["thread_method"] in ["multiprocessing"]: if settings.dict["main"]["thread_method"] in ["multiprocessing"]:
fhdhr_epg = multiprocessing.Process(target=fhdhr.device.epg.run) fhdhr_epg = multiprocessing.Process(target=fhdhr.device.epg.run)
elif settings.dict["main"]["thread_method"] in ["threading"]: elif settings.dict["main"]["thread_method"] in ["threading"]:
@ -77,6 +70,18 @@ def run(settings, logger, db, script_dir, fHDHR_web, origin, alternative_epg):
if settings.dict["main"]["thread_method"] in ["multiprocessing", "threading"]: if settings.dict["main"]["thread_method"] in ["multiprocessing", "threading"]:
fhdhr_epg.start() fhdhr_epg.start()
# Perform some actions now that HTTP Server is running, but don't wait for response
# Hit EPG Update API URL without waiting
fhdhr.logger.info("Waiting 3 seconds to send startup tasks trigger.")
time.sleep(3)
try:
fhdhr.web.session.get("%s/api/startup_tasks" % (fhdhr.api.base))
except fhdhr.web.exceptions.ReadTimeout:
pass
except fhdhr.web.exceptions.ConnectionError as e:
fhdhr.logger.warning("Startup tasks failed: %s" % e)
pass
# wait forever # wait forever
while True: while True:
time.sleep(3600) time.sleep(3600)

View File

@ -296,10 +296,18 @@ class EPG():
while True: while True:
for epg_method in self.epg_methods: for epg_method in self.epg_methods:
last_update_time = self.fhdhr.db.get_fhdhr_value("update_time", epg_method) last_update_time = self.fhdhr.db.get_fhdhr_value("update_time", epg_method)
updatetheepg = False
if not last_update_time: if not last_update_time:
self.fhdhr.web.session.get(self.epg_update_url) updatetheepg = True
elif time.time() >= (last_update_time + self.sleeptime[epg_method]): elif time.time() >= (last_update_time + self.sleeptime[epg_method]):
self.fhdhr.web.session.get(self.epg_update_url) updatetheepg = True
time.sleep(360) if updatetheepg:
try:
self.fhdhr.web.session.get(self.epg_update_url, timeout=0.0000000001)
except self.fhdhr.web.exceptions.ReadTimeout:
pass
except self.fhdhr.web.exceptions.ConnectionError as e:
self.fhdhr.logger.error("Error updating %s EPG cache: %s" % (epg_method, e))
time.sleep(1800)
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass