From 82c6b57907180e500424a0de8f34ba6eebc28dcf Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Tue, 11 May 2021 15:33:27 +0200 Subject: [PATCH] persist proxy --- stream.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/stream.py b/stream.py index 49c418d..9670567 100755 --- a/stream.py +++ b/stream.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import random import json import urllib.parse import re @@ -172,16 +171,16 @@ class MainHandler(tornado.web.RequestHandler): if isinstance(proxy_list_orig, list): proxy_list = proxy_list_orig.copy() if isinstance(proxy_list, list): - rand = random.SystemRandom() - rand.shuffle(proxy_list) for proxy_temp in proxy_list: try: - resp = requests.head(src, allow_redirects=True, proxies=proxy_temp.req, timeout=(0.1, 2.0)) + resp = requests.head(src, allow_redirects=True, proxies=proxy_temp.req, timeout=(1, 2)) if resp is not None: src = resp.url except Exception as e: print(e) else: + proxy_list.remove(proxy_temp) + proxies[provider] = [proxy_temp] + proxy_list proxy = proxy_temp if proxy is not None: try: