1 from requests import get
5 conn = sqlite3.connect("blocks.db")
8 with open("pleroma_instances.txt", "r") as f:
9 while blocker := f.readline().strip():
11 c.execute(f"delete from blocks where blocker = '{blocker}'")
14 json = loads(get(f"https://{blocker}/nodeinfo/2.1.json").text)
15 for mrf in json["metadata"]["federation"]["mrf_simple"]:
16 for blocked in json["metadata"]["federation"]["mrf_simple"][mrf]:
17 c.execute(f"insert into blocks select '{blocker}', '{blocked}', '', '{mrf}'")
18 for blocked in json["metadata"]["federation"]["quarantined_instances"]:
19 c.execute(f"insert into blocks select '{blocker}', '{blocked}', '', 'quarantined_instances'")
24 with open("mastodon_instances.txt", "r") as f:
25 while blocker := f.readline().strip():
27 c.execute(f"delete from blocks where blocker = '{blocker}'")
30 json = loads(get(f"http://127.0.0.1:8069/{blocker}").text)
31 for blocked in json["reject"]:
32 c.execute(f"insert into blocks select '{blocker}', ifnull((select domain from instances where hash = '{blocked['hash']}'), '{blocked['hash']}'), '{blocked['reason']}', 'reject'")
33 for blocked in json["media_removal"]:
34 c.execute(f"insert into blocks select '{blocker}', ifnull((select domain from instances where hash = '{blocked['hash']}'), '{blocked['hash']}'), '{blocked['reason']}', 'media_removal'")
35 for blocked in json["federated_timeline_removal"]:
36 c.execute(f"insert into blocks select '{blocker}', ifnull((select domain from instances where hash = '{blocked['hash']}'), '{blocked['hash']}'), '{blocked['reason']}', 'federated_timeline_removal'")