mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 10:26:57 -05:00
commit
60455b6a84
@ -44,7 +44,7 @@ def run(settings, logger, db, script_dir, fHDHR_web, origin, alternative_epg):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
print("HTTP Server Starting")
|
fhdhr.logger.info("HTTP Server Starting")
|
||||||
if settings.dict["main"]["thread_method"] in ["multiprocessing"]:
|
if settings.dict["main"]["thread_method"] in ["multiprocessing"]:
|
||||||
fhdhr_web = multiprocessing.Process(target=fhdhrweb.run)
|
fhdhr_web = multiprocessing.Process(target=fhdhrweb.run)
|
||||||
elif settings.dict["main"]["thread_method"] in ["threading"]:
|
elif settings.dict["main"]["thread_method"] in ["threading"]:
|
||||||
@ -52,8 +52,15 @@ 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"]:
|
||||||
print("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"]:
|
||||||
fhdhr_ssdp = multiprocessing.Process(target=fhdhr.device.ssdp.run)
|
fhdhr_ssdp = multiprocessing.Process(target=fhdhr.device.ssdp.run)
|
||||||
elif settings.dict["main"]["thread_method"] in ["threading"]:
|
elif settings.dict["main"]["thread_method"] in ["threading"]:
|
||||||
@ -62,7 +69,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"]:
|
||||||
print("EPG Update Starting")
|
fhdhr.logger.info("EPG Update 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"]:
|
||||||
|
|||||||
@ -20,9 +20,6 @@ class Channels():
|
|||||||
self.list_update_time = None
|
self.list_update_time = None
|
||||||
|
|
||||||
self.get_db_channels()
|
self.get_db_channels()
|
||||||
haseverscanned = self.fhdhr.db.get_fhdhr_value("channels", "scanned_time")
|
|
||||||
if (self.fhdhr.config.dict["fhdhr"]["chanscan_on_start"] or not haseverscanned):
|
|
||||||
self.get_channels()
|
|
||||||
|
|
||||||
def get_channel_obj(self, keyfind, valfind):
|
def get_channel_obj(self, keyfind, valfind):
|
||||||
if keyfind == "number":
|
if keyfind == "number":
|
||||||
|
|||||||
@ -291,8 +291,7 @@ class EPG():
|
|||||||
self.fhdhr.logger.info("Wrote " + epgtypename + " EPG cache.")
|
self.fhdhr.logger.info("Wrote " + epgtypename + " EPG cache.")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
for epg_method in self.epg_methods:
|
time.sleep(1800)
|
||||||
self.fhdhr.web.session.get(self.epg_update_url)
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
for epg_method in self.epg_methods:
|
for epg_method in self.epg_methods:
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
from .root_url import Root_URL
|
from .root_url import Root_URL
|
||||||
|
from .startup_tasks import Startup_Tasks
|
||||||
|
|
||||||
from .cluster import Cluster
|
from .cluster import Cluster
|
||||||
from .settings import Settings
|
from .settings import Settings
|
||||||
@ -19,6 +20,7 @@ class fHDHR_API():
|
|||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|
||||||
self.root_url = Root_URL(fhdhr)
|
self.root_url = Root_URL(fhdhr)
|
||||||
|
self.startup_tasks = Startup_Tasks(fhdhr)
|
||||||
|
|
||||||
self.cluster = Cluster(fhdhr)
|
self.cluster = Cluster(fhdhr)
|
||||||
self.settings = Settings(fhdhr)
|
self.settings = Settings(fhdhr)
|
||||||
|
|||||||
35
fHDHR_web/api/startup_tasks.py
Normal file
35
fHDHR_web/api/startup_tasks.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
|
||||||
|
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")
|
||||||
|
if not haseverscanned:
|
||||||
|
self.fhdhr.web.session.get(self.channel_update_url)
|
||||||
|
elif self.fhdhr.config.dict["fhdhr"]["chanscan_on_start"]:
|
||||||
|
try:
|
||||||
|
self.fhdhr.web.session.get(self.channel_update_url, timeout=0.0000000001)
|
||||||
|
except self.fhdhr.web.exceptions.ReadTimeout:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Hit EPG Update API URL without waiting
|
||||||
|
try:
|
||||||
|
self.fhdhr.web.session.get(self.epg_update_url, timeout=0.0000000001)
|
||||||
|
except self.fhdhr.web.exceptions.ReadTimeout:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return "Success"
|
||||||
@ -1,6 +1,7 @@
|
|||||||
from flask import Response, request, redirect, abort, stream_with_context
|
from flask import Response, request, redirect, abort, stream_with_context
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import uuid
|
import uuid
|
||||||
|
import json
|
||||||
|
|
||||||
from fHDHR.exceptions import TunerError
|
from fHDHR.exceptions import TunerError
|
||||||
|
|
||||||
@ -116,6 +117,21 @@ class Tuners():
|
|||||||
tuner = self.fhdhr.device.tuners.tuners[str(tuner_number)]
|
tuner = self.fhdhr.device.tuners.tuners[str(tuner_number)]
|
||||||
tuner.channel_scan()
|
tuner.channel_scan()
|
||||||
|
|
||||||
|
elif method == "status":
|
||||||
|
|
||||||
|
if not tuner_number:
|
||||||
|
tuner_status = self.fhdhr.device.tuners.status()
|
||||||
|
elif str(tuner_number) in list(self.fhdhr.device.tuners.tuners.keys()):
|
||||||
|
tuner_status = self.fhdhr.device.tuners.tuners[str(tuner_number)].get_status()
|
||||||
|
else:
|
||||||
|
tuner_status = ["Invalid Tuner %s" % tuner_number]
|
||||||
|
|
||||||
|
tuner_status_json = json.dumps(tuner_status, indent=4)
|
||||||
|
|
||||||
|
return Response(status=200,
|
||||||
|
response=tuner_status_json,
|
||||||
|
mimetype='application/json')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return "%s Invalid Method" % method
|
return "%s Invalid Method" % method
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user