-def get_type(instdomain: str) -> str:
- try:
- res = get(f"https://{instdomain}/nodeinfo/2.1.json", headers=headers, timeout=5)
- if res.status_code == 404:
- res = get(f"https://{instdomain}/nodeinfo/2.0", headers=headers, timeout=5)
- if res.status_code == 404:
- res = get(f"https://{instdomain}/nodeinfo/2.0.json", headers=headers, timeout=5)
- if res.ok and "text/html" in res.headers["content-type"]:
- res = get(f"https://{instdomain}/nodeinfo/2.1", headers=headers, timeout=5)
- if res.ok:
- if res.json()["software"]["name"] in ["akkoma", "rebased"]:
- return "pleroma"
- elif res.json()["software"]["name"] in ["hometown", "ecko"]:
- return "mastodon"
- elif res.json()["software"]["name"] in ["calckey", "groundpolis", "foundkey", "cherrypick"]:
- return "misskey"
- else:
- return res.json()["software"]["name"]
- elif res.status_code == 404:
- res = get(f"https://{instdomain}/api/v1/instance", headers=headers, timeout=5)
- if res.ok:
- return "mastodon"
- except:
- return None