From f091c82625e17b6a2fa50e558ba6d0fa3afb1ce8 Mon Sep 17 00:00:00 2001 From: iam-py-test <84232764+iam-py-test@users.noreply.github.com> Date: Tue, 9 Nov 2021 06:25:25 -0500 Subject: [PATCH] Update compile.py --- ClearURLs for uBo/compile.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ClearURLs for uBo/compile.py b/ClearURLs for uBo/compile.py index 707089525..0675d39e9 100644 --- a/ClearURLs for uBo/compile.py +++ b/ClearURLs for uBo/compile.py @@ -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")))