From: Enju Aihara <5-EnjuAihara@users.noreply.gitlab.varis.social> Date: Sat, 5 Mar 2022 12:09:00 +0000 (+0100) Subject: ignore empty blocks X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e00823707d4eb87bd7a4f8fb607520dbe7aa2cf7;p=fba.git ignore empty blocks --- diff --git a/fetch_blocks.py b/fetch_blocks.py index 27cbbab..aa30b8f 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -14,11 +14,15 @@ with open("pleroma_instances.txt", "r") as f: json = loads(get(f"https://{blocker}/nodeinfo/2.1.json").text) for mrf in json["metadata"]["federation"]["mrf_simple"]: for blocked in json["metadata"]["federation"]["mrf_simple"][mrf]: + if blocked == "": + continue c.execute("select case when ? in (select domain from instances) then 1 else 0 end", (blocked,)) if c.fetchone() == (0,): c.execute("insert into instances select ?, ?", (blocked, sha256(bytes(blocked, "utf-8")).hexdigest())) c.execute("insert into blocks select ?, ?, '', ?", (blocker, blocked, mrf)) for blocked in json["metadata"]["federation"]["quarantined_instances"]: + if blocked == "": + continue c.execute("select case when ? in (select domain from instances) then 1 else 0 end", (blocked,)) if c.fetchone() == (0,): c.execute("insert into instances select ?, ?", (blocked, sha256(bytes(blocked, "utf-8")).hexdigest()))