# NOISY-DEBUG: print("DEBUG: Returning doc():", len(doc))
return doc
-def determine_software(domain: str) -> str:
- # NOISY-DEBUG: print("DEBUG: Determining software for domain:", domain)
- software = None
+def fetch_nodeinfo(domain: str) -> list:
+ print("DEBUG: Fetching nodeinfo from domain:", domain)
+ json = None
try:
+ print("DEBUG: Fetching 2.1.json from domain:", domain)
res = reqto.get(f"https://{domain}/nodeinfo/2.1.json", headers=headers, timeout=5)
- # NOISY-DEBUG: print("DEBUG: domain,res.ok,res.status_code:", domain, res.ok, res.status_code)
- if res.status_code == 404:
+ if res.status_code == 404 or "text/html" in res.headers["content-type"]:
+ print("DEBUG: Fetching 2.0 from domain:", domain)
res = reqto.get(f"https://{domain}/nodeinfo/2.0", headers=headers, timeout=5)
- if res.status_code == 404:
+ if res.status_code == 404 or "text/html" in res.headers["content-type"]:
+ print("DEBUG: Fetching 2.0.json from domain:", domain)
res = reqto.get(f"https://{domain}/nodeinfo/2.0.json", headers=headers, timeout=5)
if res.ok and "text/html" in res.headers["content-type"]:
+ print("DEBUG: Fetching 2.1 from domain:", domain)
res = reqto.get(f"https://{domain}/nodeinfo/2.1", headers=headers, timeout=5)
- if res.ok:
- json = res.json()
- # NOISY-DEBUG: print("DEBUG: json():", len(json))
-
- if json["software"]["name"] in ["akkoma", "rebased"]:
- software = "pleroma"
- elif json["software"]["name"] in ["hometown", "ecko"]:
- software = "mastodon"
- elif json["software"]["name"] in ["calckey", "groundpolis", "foundkey", "cherrypick"]:
- software = "misskey"
- else:
- software = json["software"]["name"]
- elif res.status_code == 404:
+ if res.status_code == 404 or "text/html" in res.headers["content-type"]:
+ print("DEBUG: Fetching /api/v1/instance from domain:", domain)
res = reqto.get(f"https://{domain}/api/v1/instance", headers=headers, timeout=5)
+
+ print("DEBUG: domain,res.ok,res.status_code:", domain, res.ok, res.status_code)
if res.ok:
- software = "mastodon"
+ json = res.json()
+
except:
- print("WARNING: Failed fetching instance meta data:", domain, software)
+ print("WARNING: Failed fetching nodeinfo from domain:", domain)
+
+ print("DEBUG: Returning json():", len(json))
+ return json
+
+def determine_software(domain: str) -> str:
+ # NOISY-DEBUG: print("DEBUG: Determining software for domain:", domain)
+ software = None
+ json = fetch_nodeinfo(domain)
+ # NOISY-DEBUG: print("DEBUG: json():", len(json))
+
+ if json["software"]["name"] in ["akkoma", "rebased"]:
+ software = "pleroma"
+ elif json["software"]["name"] in ["hometown", "ecko"]:
+ software = "mastodon"
+ elif json["software"]["name"] in ["calckey", "groundpolis", "foundkey", "cherrypick"]:
+ software = "misskey"
+ else:
+ software = json["software"]["name"]
# NOISY-DEBUG: print("DEBUG: Returning domain,software:", domain, software)
return software