Update compile.py

This commit is contained in:
iam-py-test
2021-11-09 06:25:25 -05:00
committed by GitHub
parent eb1090eab0
commit f091c82625
+14 -1
View File
@@ -137,14 +137,27 @@ def getrules() -> str:
return requests.get(RULES).text
def haschanged() -> bool:
c = False
try:
hashes = json.loads(open("hash.txt").read()
except:
hashes = []
toph = hashlib.sha256("")
toph = hashlib.sha256(HEAD.encode()).hexdigest()
if toph not in hashes:
c = True
ruleshash = hashlib.sha256(json.loads(getrules()))
if ruleshash not in hashes:
c = True
with open("hash.txt","w") as f:
f.write(json.dumps([toph,ruleshash]))
f.close()
return c
def main() -> int:
data_min_json = json.loads(getrules())
if haschanged() == False:
print("No change in rules. Exiting...")
sys.exit()
filterlist = open("clear_urls_uboified.txt", "w")
filterlist.write(HEAD.format(date=date.today().strftime("%d/%m/%Y")))