From 955caf5eb2553675e9ac4202a5296f72308b306f Mon Sep 17 00:00:00 2001 From: Enju Aihara <5-EnjuAihara@users.noreply.gitlab.varis.social> Date: Fri, 4 Mar 2022 16:50:32 +0100 Subject: [PATCH] can now also fetch from mastodon instances --- fetch_blocks.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fetch_blocks.py b/fetch_blocks.py index e590c24..dbf53a9 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -21,4 +21,21 @@ with open("pleroma_instances.txt", "r") as f: except: pass +with open("mastodon_instances.txt", "r") as f: + while blocker := f.readline().strip(): + print(blocker) + c.execute(f"delete from blocks where blocker = '{blocker}'") + conn.commit() + try: + json = loads(get(f"http://127.0.0.1:8069/{blocker}").text) + for blocked in json["reject"]: + c.execute(f"insert into blocks select '{blocker}', ifnull((select domain from instances where hash = '{blocked['hash']}'), '{blocked['hash']}'), '{blocked['reason']}', 'reject'") + for blocked in json["media_removal"]: + c.execute(f"insert into blocks select '{blocker}', ifnull((select domain from instances where hash = '{blocked['hash']}'), '{blocked['hash']}'), '{blocked['reason']}', 'media_removal'") + for blocked in json["federated_timeline_removal"]: + c.execute(f"insert into blocks select '{blocker}', ifnull((select domain from instances where hash = '{blocked['hash']}'), '{blocked['hash']}'), '{blocked['reason']}', 'federated_timeline_removal'") + conn.commit() + except: + pass + conn.close() \ No newline at end of file