From e1fb73139aa0e5d67a6c06079f87a34a7bb7c6c3 Mon Sep 17 00:00:00 2001 From: mac12m99 <10120390+mac12m99@users.noreply.github.com> Date: Sun, 11 Apr 2021 17:17:21 +0200 Subject: [PATCH] =?UTF-8?q?updateDomains:=20controlla=20anche=20i=20findho?= =?UTF-8?q?st,=20elimina=20se=20canale=20non=20pi=C3=B9=20esistente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/updateDomains.py | 84 ++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/tools/updateDomains.py b/tools/updateDomains.py index 21575c60..09bf3781 100644 --- a/tools/updateDomains.py +++ b/tools/updateDomains.py @@ -42,51 +42,55 @@ if __name__ == '__main__': with open(fileJson) as f: data = json.load(f) - result = data['direct'] + chList = os.listdir('channels') - for chann, host in sorted(data['direct'].items()): - # to get an idea of the timing - # useful only if you control all channels - # for channels with error 522 about 40 seconds are lost ... - print("check #### INIZIO #### channel - host :%s - %s " % (chann, host)) + for k in data.keys(): + for chann, host in sorted(data[k].items()): + if chann + '.json' not in chList: + print(chann + ' not exists anymore') + del data[k][chann] + continue + # to get an idea of the timing + # useful only if you control all channels + # for channels with error 522 about 40 seconds are lost ... + print("check #### INIZIO #### channel - host :%s - %s " % (chann, host)) - rslt = http_Resp([host]) + rslt = http_Resp([host]) - # all right - if rslt['code'] == 200: - result[chann] = host - # redirect - elif str(rslt['code']).startswith('3'): - # result[chann] = str(rslt['code']) +' - '+ rslt['redirect'][:-1] - result[chann] = rslt['redirect'] - # cloudflare... - elif rslt['code'] in [429, 503, 403]: - from lib import proxytranslate - import re + # all right + if rslt['code'] == 200: + data[k][chann] = host + # redirect + elif str(rslt['code']).startswith('3'): + # data[k][chann] = str(rslt['code']) +' - '+ rslt['redirect'][:-1] + data[k][chann] = rslt['redirect'] + # cloudflare... + elif rslt['code'] in [429, 503, 403]: + from lib import proxytranslate + import re - print('Cloudflare riconosciuto') - try: - page_data = proxytranslate.process_request_proxy(host).get('data', '') - result[chann] = re.search('