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: