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("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("insert into blocks select ?, ?, '', ?", (blocker, blocked, mrf))
18 for blocked in json["metadata"]["federation"]["quarantined_instances"]:
19 c.execute("insert into blocks select ?, ?, '', 'quarantined_instances'", (blocker, blocked))
24 with open("mastodon_instances.txt", "r") as f:
25 while blocker := f.readline().strip():
27 c.execute("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 if blocked["domain"].count("*") > 1:
33 c.execute("insert into blocks select ?, ifnull((select domain from instances where hash = ?), ?), ?, 'reject'", (blocker, blocked["hash"], blocked["hash"], blocked['reason']))
35 c.execute("insert into blocks select ?, ?, ?, 'reject'", (blocker, blocked["domain"], blocked["reason"]))
36 for blocked in json["media_removal"]:
37 if blocked["domain"].count("*") > 1:
38 c.execute("insert into blocks select ?, ifnull((select domain from instances where hash = ?), ?), ?, 'media_removal'", (blocker, blocked["hash"], blocked["hash"], blocked['reason']))
40 c.execute("insert into blocks select ?, ?, ?, 'media_removal'", (blocker, blocked["domain"], blocked["reason"]))
41 for blocked in json["federated_timeline_removal"]:
42 if blocked["domain"].count("*") > 1:
43 c.execute("insert into blocks select ?, ifnull((select domain from instances where hash = ?), ?), ?, 'federated_timeline_removal'", (blocker, blocked["hash"], blocked["hash"], blocked['reason']))
45 c.execute("insert into blocks select ?, ?, ?, 'federated_timeline_removal'", (blocker, blocked["domain"], blocked["reason"]))