diff --git a/backend/stream.py b/backend/stream.py index 8587da1..28d1be8 100755 --- a/backend/stream.py +++ b/backend/stream.py @@ -37,7 +37,7 @@ class ProxyElem(): def __init__(self, proxy): self.proxy = proxy def local(self): - timeout = aiohttp.ClientTimeout(total=1) + timeout = aiohttp.ClientTimeout(total=5) return aiohttp.ClientSession(timeout=timeout) def session(self): connector = None @@ -227,11 +227,14 @@ class MainHandler(tornado.web.RequestHandler): if isinstance(provider_data.ctype(), str): video_info["ctype"] = provider_data.ctype() else: - async with handler.proxy.local() as session: - resp = await session.head(proxied[0]) - ctype = resp.headers.get("Content-Type", None) - if isinstance(ctype, str): - video_info["ctype"] = ctype + try: + async with handler.proxy.local() as session: + resp = await session.head(proxied[0]) + ctype = resp.headers.get("Content-Type", None) + if isinstance(ctype, str): + video_info["ctype"] = ctype + except Exception as e: + logger.info(e) script = template_script.generate(info=json.dumps(video_info)) b64 = str(base64.b64encode(script), "ascii")