From 482877e5c68b71423412836bc64137fade347b3e Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Tue, 11 May 2021 14:59:43 +0200 Subject: [PATCH] fix proxy --- stream.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/stream.py b/stream.py index bb0b68f..b9f16d3 100755 --- a/stream.py +++ b/stream.py @@ -85,8 +85,7 @@ def get_proxy_url(proxy, current, path): presp = requests.post(proxy_server, json=data) return presp.text -def rewrite(current, provider): - proxy = proxies.get(provider) +def rewrite(current, provider, proxy): resp = requests.head(current, proxies=proxy.req) ctype = resp.headers.get("Content-Type") if ctype is None: @@ -168,7 +167,6 @@ class MainHandler(tornado.web.RequestHandler): if provider == "youtube": path = path.strip("/") src = providers[provider] + self.request.path - proxy = None proxy_list = None proxy_list_orig = proxies.get(provider) if isinstance(proxy_list_orig, list): @@ -200,7 +198,7 @@ class MainHandler(tornado.web.RequestHandler): if write: self.write("Stream not found.") else: - data = rewrite(upstream, provider) + data = rewrite(upstream, provider, proxy) if data is None: self.redirect(upstream, status=303) else: