fix config 502
This commit is contained in:
parent
47e053be94
commit
050c654b92
@ -19,12 +19,12 @@ class UpstreamHandler():
|
|||||||
self.provider = None
|
self.provider = None
|
||||||
self.raw = False
|
self.raw = False
|
||||||
self.valid = False
|
self.valid = False
|
||||||
self.proxy = ProxyElem(None)
|
self.proxy = config.ProxyElem(None, None)
|
||||||
self.direct = False
|
self.direct = False
|
||||||
self.upstream = None
|
self.upstream = None
|
||||||
async def test_socks(self, proxy):
|
async def test_socks(self, proxy):
|
||||||
if not hasattr(proxy, "proxy") or not isinstance(proxy.proxy, str):
|
if not hasattr(proxy, "proxy") or not isinstance(proxy.proxy, str):
|
||||||
return (True, ProxyElem(None))
|
return (True, config.ProxyElem(None, None))
|
||||||
try:
|
try:
|
||||||
splitted = proxy.proxy.rsplit(":", 1)
|
splitted = proxy.proxy.rsplit(":", 1)
|
||||||
host = proxy
|
host = proxy
|
||||||
@ -54,16 +54,16 @@ class UpstreamHandler():
|
|||||||
self.raw = (raw_str.lower() in true_values)
|
self.raw = (raw_str.lower() in true_values)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
if self.provider in providers.keys():
|
if self.provider in config.providers.keys():
|
||||||
self.valid = True
|
self.valid = True
|
||||||
path = handler.request.path
|
path = handler.request.path
|
||||||
if self.provider.startswith("nextcloud"):
|
if self.provider.startswith("nextcloud"):
|
||||||
path = path.removesuffix("/").removesuffix("download").removesuffix("/")
|
path = path.removesuffix("/").removesuffix("download").removesuffix("/")
|
||||||
elif self.provider.startswith("youtube"):
|
elif self.provider.startswith("youtube"):
|
||||||
path = path.removeprefix("/")
|
path = path.removeprefix("/")
|
||||||
self.upstream = providers[self.provider] + path
|
self.upstream = config.providers[self.provider] + path
|
||||||
if not self.direct:
|
if not self.direct:
|
||||||
proxy_list = proxies.get(self.provider)
|
proxy_list = config.proxies.get(self.provider)
|
||||||
if isinstance(proxy_list, list):
|
if isinstance(proxy_list, list):
|
||||||
futures = []
|
futures = []
|
||||||
for current in proxy_list:
|
for current in proxy_list:
|
||||||
@ -95,7 +95,7 @@ class MainHandler(tornado.web.RequestHandler):
|
|||||||
video_info = None
|
video_info = None
|
||||||
meta = None
|
meta = None
|
||||||
title = None
|
title = None
|
||||||
if template_script is not None and template_html is not None:
|
if config.template_script is not None and config.template_html is not None:
|
||||||
provider_data = None
|
provider_data = None
|
||||||
if handler.provider.startswith("nextcloud"):
|
if handler.provider.startswith("nextcloud"):
|
||||||
provider_data = await stream_providers.get_nextcloud(handler.upstream, handler.proxy, logger)
|
provider_data = await stream_providers.get_nextcloud(handler.upstream, handler.proxy, logger)
|
||||||
@ -127,15 +127,15 @@ class MainHandler(tornado.web.RequestHandler):
|
|||||||
async def handle_render(self, handler):
|
async def handle_render(self, handler):
|
||||||
video_info, meta, title = await self.get_data(handler)
|
video_info, meta, title = await self.get_data(handler)
|
||||||
if video_info is not None:
|
if video_info is not None:
|
||||||
script = template_script.generate(info=json.dumps(video_info))
|
script = config.template_script.generate(info=json.dumps(video_info))
|
||||||
b64 = str(base64.b64encode(script), "ascii")
|
b64 = str(base64.b64encode(script), "ascii")
|
||||||
data = {}
|
data = {}
|
||||||
script_file = f'data:text/javascript;charset=utf-8;base64,{b64}'
|
script_file = f'data:text/javascript;charset=utf-8;base64,{b64}'
|
||||||
data["script"] = script_file
|
data["script"] = script_file
|
||||||
data["videojs_version"] = videojs_version
|
data["videojs_version"] = config.videojs_version
|
||||||
data["chromecast_version"] = chromecast_version
|
data["chromecast_version"] = config.chromecast_version
|
||||||
data["font_awesome_version"] = font_awesome_version
|
data["font_awesome_version"] = config.font_awesome_version
|
||||||
rendered_html = template_html.generate(data=data, meta=meta, title=title)
|
rendered_html = config.template_html.generate(data=data, meta=meta, title=title)
|
||||||
self.write(rendered_html)
|
self.write(rendered_html)
|
||||||
else:
|
else:
|
||||||
self.set_status(404)
|
self.set_status(404)
|
||||||
@ -148,17 +148,17 @@ class MainHandler(tornado.web.RequestHandler):
|
|||||||
class PlaylistHandler(tornado.web.RequestHandler):
|
class PlaylistHandler(tornado.web.RequestHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
self.set_header("Content-Type", "text/plain; charset=utf-8")
|
self.set_header("Content-Type", "text/plain; charset=utf-8")
|
||||||
self.write(playlist)
|
self.write(config.playlist)
|
||||||
|
|
||||||
class IconHandler(tornado.web.RequestHandler):
|
class IconHandler(tornado.web.RequestHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
self.set_header("Content-Type", "image/png")
|
self.set_header("Content-Type", "image/png")
|
||||||
self.write(favicon)
|
self.write(config.favicon)
|
||||||
|
|
||||||
class StyleHandler(tornado.web.RequestHandler):
|
class StyleHandler(tornado.web.RequestHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
self.set_header("Content-Type", "text/css; charset=utf-8")
|
self.set_header("Content-Type", "text/css; charset=utf-8")
|
||||||
self.write(custom_style)
|
self.write(config.custom_style)
|
||||||
try:
|
try:
|
||||||
handlers = []
|
handlers = []
|
||||||
handlers.append((tornado.routing.PathMatches("/sources.m3u8"), PlaylistHandler))
|
handlers.append((tornado.routing.PathMatches("/sources.m3u8"), PlaylistHandler))
|
||||||
|
Loading…
Reference in New Issue
Block a user