fix region parsing

This commit is contained in:
Roy Olav Purser 2022-01-30 14:14:22 +01:00
parent 050c654b92
commit dca80369de
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -1,5 +1,6 @@
import json
import sys
import pprint
import os
import re
import base64
@ -41,7 +42,7 @@ class ProxyElem():
timeout = aiohttp.ClientTimeout(total=5)
return aiohttp.ClientSession(timeout=timeout)
def __repr__(self):
return str(self.proxy)
return f"<region=<{str(self.region)}> proxy=<{str(self.proxy)}>>"
async def proxy_url(self, urls):
clean_urls = []
for url in urls:
@ -130,7 +131,7 @@ for key in providers:
region_current_keys.add(f'{key}_{region_country}')
region = os.environ.get(match)
if region is not None:
region_current.append(proxy)
region_current.append(region)
region_countries.append(region_country)
if region_country is None:
region_empty = False
@ -138,7 +139,6 @@ for key in providers:
for elem in proxy_current_keys:
proxies[elem] = []
new_providers[elem] = providers[key]
print(proxies)
for proxy, region, country in zip(proxy_current, region_current, proxy_countries):
new_key = key
@ -150,6 +150,8 @@ for key in providers:
if len(proxies[elem]) == 0:
proxies[elem].append(ProxyElem(None, None))
pprint.pp(proxies)
providers = new_providers
proxy_keys = []