]> git.mxchange.org Git - fba.git/blobdiff - fetch_instances.py
Another masto fork
[fba.git] / fetch_instances.py
index c59d7fa33927a887bcf928aadabb561410901bf5..e6090353e4e75fbdb2c03e579714ae1367b9a0db 100644 (file)
@@ -7,7 +7,7 @@ import json
 domain = sys.argv[1]
 
 headers = {
-    "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
+    "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Firefox/102.0"
 }
 
 
@@ -27,6 +27,8 @@ peerlist = get_peers(domain)
 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"]:
@@ -34,6 +36,10 @@ def get_type(instdomain: str) -> str:
         if res.ok:
             if res.json()["software"]["name"] == "akkoma":
                 return "pleroma"
+            elif res.json()["software"]["name"] == "hometown":
+                return "mastodon"
+            elif res.json()["software"]["name"] == "ecko":
+                return "mastodon"
             else:
                 return res.json()["software"]["name"]
         elif res.status_code == 404:
@@ -55,6 +61,9 @@ for instance in peerlist:
     instance = instance.lower()
     print(instance)
     try:
+        c.execute(
+            "select domain from instances where domain = ?", (instance,)
+        )
         if c.fetchone() == None:
             c.execute(
                 "insert into instances select ?, ?, ?",