import sqlite3
from bs4 import BeautifulSoup
+headers = {
+ "user-agent": "fedi-block-api (https://gitlab.com/EnjuAihara/fedi-block-api)"
+}
def get_mastodon_blocks(domain: str) -> dict:
try:
media_removal = []
federated_timeline_removal = []
- doc = BeautifulSoup(get(f"https://{domain}/about/more").text, "html.parser")
+ doc = BeautifulSoup(get(f"https://{domain}/about/more", headers=headers, timeout=5).text, "html.parser")
for header in doc.find_all("h3"):
if header.text == "Suspended servers":
for line in header.find_next_siblings("table")[0].find_all("tr")[1:]:
def get_type(domain: str) -> str:
try:
- res = get("https://"+domain, timeout=5)
+ res = get("https://"+domain, headers=headers, timeout=5)
if "pleroma" in res.text.lower():
print("pleroma")
return "pleroma"
conn = sqlite3.connect("blocks.db")
c = conn.cursor()
-c.execute("select domain, software from instances where software in ('pleroma', 'mastodon')")
+#c.execute("select domain, software from instances where software in ('pleroma', 'mastodon')")
+c.execute("select 'chizu.love', 'pleroma'")
for blocker, software in c.fetchall():
if software == "pleroma":
try:
# Blocks
c.execute("delete from blocks where blocker = ?", (blocker,))
- json = get(f"https://{blocker}/nodeinfo/2.1.json").json()
+ json = get(f"https://{blocker}/nodeinfo/2.1.json", headers=headers, timeout=5).json()
if "mrf_simple" in json["metadata"]["federation"]:
for mrf in json["metadata"]["federation"]["mrf_simple"]:
for blocked in json["metadata"]["federation"]["mrf_simple"][mrf]: