updateDomains: controlla anche i findhost, elimina se canale non più esistente
This commit is contained in:
+14
-10
@@ -42,9 +42,14 @@ if __name__ == '__main__':
|
|||||||
with open(fileJson) as f:
|
with open(fileJson) as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
result = data['direct']
|
chList = os.listdir('channels')
|
||||||
|
|
||||||
for chann, host in sorted(data['direct'].items()):
|
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
|
# to get an idea of the timing
|
||||||
# useful only if you control all channels
|
# useful only if you control all channels
|
||||||
# for channels with error 522 about 40 seconds are lost ...
|
# for channels with error 522 about 40 seconds are lost ...
|
||||||
@@ -54,11 +59,11 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# all right
|
# all right
|
||||||
if rslt['code'] == 200:
|
if rslt['code'] == 200:
|
||||||
result[chann] = host
|
data[k][chann] = host
|
||||||
# redirect
|
# redirect
|
||||||
elif str(rslt['code']).startswith('3'):
|
elif str(rslt['code']).startswith('3'):
|
||||||
# result[chann] = str(rslt['code']) +' - '+ rslt['redirect'][:-1]
|
# data[k][chann] = str(rslt['code']) +' - '+ rslt['redirect'][:-1]
|
||||||
result[chann] = rslt['redirect']
|
data[k][chann] = rslt['redirect']
|
||||||
# cloudflare...
|
# cloudflare...
|
||||||
elif rslt['code'] in [429, 503, 403]:
|
elif rslt['code'] in [429, 503, 403]:
|
||||||
from lib import proxytranslate
|
from lib import proxytranslate
|
||||||
@@ -67,7 +72,7 @@ if __name__ == '__main__':
|
|||||||
print('Cloudflare riconosciuto')
|
print('Cloudflare riconosciuto')
|
||||||
try:
|
try:
|
||||||
page_data = proxytranslate.process_request_proxy(host).get('data', '')
|
page_data = proxytranslate.process_request_proxy(host).get('data', '')
|
||||||
result[chann] = re.search('<base href="([^"]+)', page_data).group(1)
|
data[k][chann] = re.search('<base href="([^"]+)', page_data).group(1)
|
||||||
rslt['code_new'] = 200
|
rslt['code_new'] = 200
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
@@ -83,10 +88,9 @@ if __name__ == '__main__':
|
|||||||
print('Errore Sconosciuto - '+str(rslt['code']) +' - '+ host)
|
print('Errore Sconosciuto - '+str(rslt['code']) +' - '+ host)
|
||||||
|
|
||||||
print("check #### FINE #### rslt :%s " % (rslt))
|
print("check #### FINE #### rslt :%s " % (rslt))
|
||||||
if result[chann].endswith('/'):
|
if data[k][chann].endswith('/'):
|
||||||
result[chann] = result[chann][:-1]
|
data[k][chann] = data[k][chann][:-1]
|
||||||
|
|
||||||
result = {'findhost': data['findhost'], 'direct': result}
|
|
||||||
# I write the updated file
|
# I write the updated file
|
||||||
with open(fileJson, 'w') as f:
|
with open(fileJson, 'w') as f:
|
||||||
json.dump(result, f, sort_keys=True, indent=4)
|
json.dump(data, f, sort_keys=True, indent=4)
|
||||||
|
|||||||
Reference in New Issue
Block a user