🧐 Add ad_ignore

This commit is contained in:
Johnshall
2022-05-20 18:40:11 +08:00
committed by GitHub
parent 6ea25ea7be
commit ea0b1142fd
2 changed files with 19 additions and 0 deletions

View File

@@ -50,6 +50,19 @@ for rule_url in rules_url:
rule = rule + r.text + '\n'
# except rules
ignore = []
ad_ignore = sys.stdout
try:
if sys.version_info.major == 3:
ad_ignore = open('resultant/ad_ignore.list', 'r', encoding='utf-8')
else:
ad_ignore = open('resultant/ad_ignore.list', 'r')
except:
pass
for ig in ad_ignore.readlines():
if ig[0] != '#' and ig != '\n':
ignore.append(ig.strip())
# parse rule
rule = rule.split('\n')
@@ -91,6 +104,10 @@ for row in rule:
print('ignore: '+row0)
continue
# 去除 ignore 中的内容
if row in ignore:
continue
# 只匹配域名或 IP
if re.match(r'^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,9}$', row) or re.match(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$', row):
domains.append(row)

View File

@@ -0,0 +1,2 @@
# This file is used to fix the wrong domains from upstream repositories
t.co