From e9f9bc0fbf775b8250e048a63a333a06f99066b5 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Thu, 13 May 2021 10:04:39 +0200 Subject: [PATCH] new session for each request --- stream.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/stream.py b/stream.py index 412efe0..b971f60 100755 --- a/stream.py +++ b/stream.py @@ -21,15 +21,18 @@ providers["twitch"] = "https://twitch.tv" class ProxyElem(): def __init__(self, proxy): - self.stream = streamlink.Streamlink() self.proxy = proxy self.req = {} - self.stream.set_option("http-timeout", 2.0) if proxy is not None: - self.stream.set_option("https-proxy", "socks5://" + proxy) - self.stream.set_option("http-proxy", "socks5://" + proxy) self.req["http"] = "socks5://" + proxy self.req["https"] = "socks5://" + proxy + def stream(self): + session = streamlink.Streamlink() + session.set_option("http-timeout", 2.0) + is self.proxy is not None: + session.set_option("https-proxy", "socks5://" + self.proxy) + session.set_option("http-proxy", "socks5://" + self.proxy) + return session def __repr__(self): return str(self.proxy) @@ -206,7 +209,8 @@ class MainHandler(tornado.web.RequestHandler): break if proxy is not None: try: - streams = proxy.stream.streams(src) + logger.info(proxy) + streams = proxy.stream().streams(src) except Exception as e: logger.info(e) else: