From f8e4fb255bac30a58dcdee5133544502713b84da Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Thu, 3 Jun 2021 16:10:12 +0200 Subject: [PATCH] retry content type through proxy --- backend/stream.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/stream.py b/backend/stream.py index baf2feb..8587da1 100755 --- a/backend/stream.py +++ b/backend/stream.py @@ -223,7 +223,15 @@ class MainHandler(tornado.web.RequestHandler): video_info = {} video_info["upstream"] = proxied[0] video_info["poster"] = proxied[1] - video_info["ctype"] = provider_data.ctype() + + 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 script = template_script.generate(info=json.dumps(video_info)) b64 = str(base64.b64encode(script), "ascii")