added better way of getting the software type
This commit is contained in:
parent
f1c3126c0a
commit
433bcd3f00
@ -30,17 +30,17 @@ def get_mastodon_blocks(domain: str) -> dict:
|
|||||||
|
|
||||||
def get_type(domain: str) -> str:
|
def get_type(domain: str) -> str:
|
||||||
try:
|
try:
|
||||||
res = get("https://"+domain, headers=headers, timeout=5)
|
res = get(f"https://{domain}/nodeinfo/2.1.json", headers=headers, timeout=5)
|
||||||
if "pleroma" in res.text.lower():
|
if res.status_code == 404:
|
||||||
print("pleroma")
|
res = get(f"https://{domain}/nodeinfo/2.0.json", headers=headers, timeout=5)
|
||||||
return "pleroma"
|
if res.ok:
|
||||||
elif "mastodon" in res.text.lower():
|
return res.json()["software"]["name"]
|
||||||
print("mastodon")
|
elif res.status_code == 404:
|
||||||
|
res = get(f"https://{domain}/api/v1/instance", headers=headers, timeout=5)
|
||||||
|
if res.ok:
|
||||||
return "mastodon"
|
return "mastodon"
|
||||||
return ""
|
except:
|
||||||
except Exception as e:
|
return None
|
||||||
print("error:", e, domain)
|
|
||||||
return ""
|
|
||||||
|
|
||||||
conn = sqlite3.connect("blocks.db")
|
conn = sqlite3.connect("blocks.db")
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user