fix config 502

This commit is contained in:
Roy Olav Purser 2022-01-30 13:38:01 +01:00
parent 47e053be94
commit 050c654b92
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -19,12 +19,12 @@ class UpstreamHandler():
self.provider = None
self.raw = False
self.valid = False
self.proxy = ProxyElem(None)
self.proxy = config.ProxyElem(None, None)
self.direct = False
self.upstream = None
async def test_socks(self, proxy):
if not hasattr(proxy, "proxy") or not isinstance(proxy.proxy, str):
return (True, ProxyElem(None))
return (True, config.ProxyElem(None, None))
try:
splitted = proxy.proxy.rsplit(":", 1)
host = proxy
@ -54,16 +54,16 @@ class UpstreamHandler():
self.raw = (raw_str.lower() in true_values)
except ValueError as e:
logger.info(e)
if self.provider in providers.keys():
if self.provider in config.providers.keys():
self.valid = True
path = handler.request.path
if self.provider.startswith("nextcloud"):
path = path.removesuffix("/").removesuffix("download").removesuffix("/")
elif self.provider.startswith("youtube"):
path = path.removeprefix("/")
self.upstream = providers[self.provider] + path
self.upstream = config.providers[self.provider] + path
if not self.direct:
proxy_list = proxies.get(self.provider)
proxy_list = config.proxies.get(self.provider)
if isinstance(proxy_list, list):
futures = []
for current in proxy_list:
@ -95,7 +95,7 @@ class MainHandler(tornado.web.RequestHandler):
video_info = None
meta = 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
if handler.provider.startswith("nextcloud"):
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):
video_info, meta, title = await self.get_data(handler)
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")
data = {}
script_file = f'data:text/javascript;charset=utf-8;base64,{b64}'
data["script"] = script_file
data["videojs_version"] = videojs_version
data["chromecast_version"] = chromecast_version
data["font_awesome_version"] = font_awesome_version
rendered_html = template_html.generate(data=data, meta=meta, title=title)
data["videojs_version"] = config.videojs_version
data["chromecast_version"] = config.chromecast_version
data["font_awesome_version"] = config.font_awesome_version
rendered_html = config.template_html.generate(data=data, meta=meta, title=title)
self.write(rendered_html)
else:
self.set_status(404)
@ -148,17 +148,17 @@ class MainHandler(tornado.web.RequestHandler):
class PlaylistHandler(tornado.web.RequestHandler):
def get(self):
self.set_header("Content-Type", "text/plain; charset=utf-8")
self.write(playlist)
self.write(config.playlist)
class IconHandler(tornado.web.RequestHandler):
def get(self):
self.set_header("Content-Type", "image/png")
self.write(favicon)
self.write(config.favicon)
class StyleHandler(tornado.web.RequestHandler):
def get(self):
self.set_header("Content-Type", "text/css; charset=utf-8")
self.write(custom_style)
self.write(config.custom_style)
try:
handlers = []
handlers.append((tornado.routing.PathMatches("/sources.m3u8"), PlaylistHandler))