fHDHR_STIRR/fHDHR_web/api/startup_tasks.py
deathbybandaid 57e0a6a88a test
2020-12-16 09:25:57 -05:00

34 lines
1.1 KiB
Python

class Startup_Tasks():
endpoints = ["/api/startup_tasks"]
endpoint_name = "api_startup_tasks"
endpoint_methods = ["GET", "POST"]
def __init__(self, fhdhr):
self.fhdhr = fhdhr
self.epg_update_url = "%s/api/epg?method=update" % (self.fhdhr.api.base)
self.channel_update_url = "%s/api/channels?method=scan" % (self.fhdhr.api.base)
def __call__(self, *args):
return self.get(*args)
def get(self, *args):
# Hit Channel Update API URL without waiting unless we've never scanned before
haseverscanned = self.fhdhr.db.get_fhdhr_value("channels", "scanned_time")
updatechannels = False
if not haseverscanned:
updatechannels = True
elif self.fhdhr.config.dict["fhdhr"]["chanscan_on_start"]:
updatechannels = True
if updatechannels:
self.fhdhr.api.client.get(self.channel_update_url, timeout=0.0000000001)
# Hit EPG Update API URL without waiting
self.fhdhr.api.client.get(self.epg_update_url, timeout=0.0000000001)
return "Success"