This commit is contained in:
parent
66a80f5526
commit
6d88564ebf
@ -138,6 +138,7 @@ class UpstreamHandler():
|
|||||||
self.raw = False
|
self.raw = False
|
||||||
self.valid = False
|
self.valid = False
|
||||||
self.proxy = ProxyElem(None)
|
self.proxy = ProxyElem(None)
|
||||||
|
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):
|
||||||
@ -158,9 +159,16 @@ class UpstreamHandler():
|
|||||||
async def setup(self, handler):
|
async def setup(self, handler):
|
||||||
self.provider = handler.get_query_argument("provider", None)
|
self.provider = handler.get_query_argument("provider", None)
|
||||||
raw_str = handler.get_query_argument("raw", None)
|
raw_str = handler.get_query_argument("raw", None)
|
||||||
|
direct_str = handler.get_query_argument("direct", None)
|
||||||
|
|
||||||
|
true_values = ['y', 'yes', 't', 'true', 'on', '1']
|
||||||
|
if isinstance(direct_str, str):
|
||||||
|
try:
|
||||||
|
self.direct = (direct_str.lower() in true_values)
|
||||||
|
except ValueError as e:
|
||||||
|
logger.info(e)
|
||||||
if isinstance(raw_str, str):
|
if isinstance(raw_str, str):
|
||||||
try:
|
try:
|
||||||
true_values = ['y', 'yes', 't', 'true', 'on', '1']
|
|
||||||
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)
|
||||||
@ -172,6 +180,7 @@ class UpstreamHandler():
|
|||||||
elif self.provider.startswith("youtube"):
|
elif self.provider.startswith("youtube"):
|
||||||
path = path.removeprefix("/")
|
path = path.removeprefix("/")
|
||||||
self.upstream = providers[self.provider] + path
|
self.upstream = providers[self.provider] + path
|
||||||
|
if not self.direct:
|
||||||
proxy_list = proxies.get(self.provider)
|
proxy_list = proxies.get(self.provider)
|
||||||
if isinstance(proxy_list, list):
|
if isinstance(proxy_list, list):
|
||||||
futures = []
|
futures = []
|
||||||
@ -254,10 +263,16 @@ class MainHandler(tornado.web.RequestHandler):
|
|||||||
provider_data = await stream_providers.get_seafile(handler.upstream, handler.proxy, logger)
|
provider_data = await stream_providers.get_seafile(handler.upstream, handler.proxy, logger)
|
||||||
else:
|
else:
|
||||||
provider_data = await stream_providers.get_any(handler.upstream, handler.proxy, logger)
|
provider_data = await stream_providers.get_any(handler.upstream, handler.proxy, logger)
|
||||||
proxied = await handler.proxy.proxy_url([(provider_data.upstream(), provider_data.proxy_ctype()), provider_data.thumbnail()])
|
|
||||||
video_info = {}
|
video_info = {}
|
||||||
|
if handler.direct:
|
||||||
|
video_info["upstream"] = provider_data.upstream()
|
||||||
|
video_info["poster"] = provider_data.thumbnail()
|
||||||
|
else:
|
||||||
|
proxied = await handler.proxy.proxy_url([(provider_data.upstream(), provider_data.proxy_ctype()), provider_data.thumbnail()])
|
||||||
video_info["upstream"] = proxied[0]
|
video_info["upstream"] = proxied[0]
|
||||||
video_info["poster"] = proxied[1]
|
video_info["poster"] = proxied[1]
|
||||||
|
|
||||||
video_info["ctype"] = provider_data.ctype()
|
video_info["ctype"] = provider_data.ctype()
|
||||||
meta = provider_data.meta()
|
meta = provider_data.meta()
|
||||||
title = provider_data.title()
|
title = provider_data.title()
|
||||||
|
Loading…
Reference in New Issue
Block a user