]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 22 May 2023 00:11:50 +0000 (02:11 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 22 May 2023 00:34:30 +0000 (02:34 +0200)
- try to strip of path if not aliased and known
- fixed some errors

fba.py
fetch_blocks.py

diff --git a/fba.py b/fba.py
index 5c13864fb18bef5d90002718f5ca8f0ae40ca32b..5a5281c5b0442888f90a7cfca195ae4825b46f1a 100644 (file)
--- a/fba.py
+++ b/fba.py
@@ -166,23 +166,28 @@ def determine_software(domain: str) -> str:
 
     try:
         json = fetch_nodeinfo(domain)
+
         # NOISY-DEBUG: print("DEBUG: json():", len(json))
+        software = tidyup(json["software"]["name"])
 
-        if json["software"]["name"] in ["akkoma", "rebased"]:
-            # NOISY-DEBUG: print("DEBUG: Setting pleroma:", domain, json["software"]["name"])
+        # NOISY-DEBUG: print("DEBUG: BEFORE software:", software)
+        if software in ["akkoma", "rebased"]:
+            # NOISY-DEBUG: print("DEBUG: Setting pleroma:", domain, software)
             software = "pleroma"
-        elif json["software"]["name"] in ["hometown", "ecko"]:
-            # NOISY-DEBUG: print("DEBUG: Setting mastodon:", domain, json["software"]["name"])
+        elif software in ["hometown", "ecko"]:
+            # NOISY-DEBUG: print("DEBUG: Setting mastodon:", domain, software)
             software = "mastodon"
-        elif json["software"]["name"] in ["calckey", "groundpolis", "foundkey", "cherrypick"]:
-            # NOISY-DEBUG: print("DEBUG: Setting misskey:", domain, json["software"]["name"])
+        elif software in ["calckey", "groundpolis", "foundkey", "cherrypick"]:
+            # NOISY-DEBUG: print("DEBUG: Setting misskey:", domain, software)
             software = "misskey"
-        else:
-            # NOISY-DEBUG: print("DEBUG: Using name:", domain, json["software"]["name"])
-            software = tidyup(json["software"]["name"].lower())
-
-            if software == "":
-                software = None
+        elif software.find("/") > 0:
+            print("WARNING: Spliting of path:", software)
+            software = software.split("/")[-1];
+
+        if software == "":
+            print("WARNING: tidyup() left no software name behind:", domain)
+            software = None
+        # NOISY-DEBUG: print("DEBUG: AFTER software:", software)
     except:
         print("WARNING: Could not determine software type:", domain)
 
index 247d15dc7a0b8b1950e2b93dbef95ff9d7c21262..57a53a8cd299b52a646ad85a2c810e2bcde150ad 100644 (file)
@@ -10,10 +10,10 @@ fba.cursor.execute(
 )
 
 for blocker, software in fba.cursor.fetchall():
-    # NOISY-DEBUG: print("DEBUG: BEFORE-blocker,software:", blocker, software)
+    # NOISY-DEBUG: print("DEBUG: BEFORE blocker,software:", blocker, software)
     blockdict = []
     blocker = fba.tidyup(blocker)
-    # NOISY-DEBUG: print("DEBUG: AFTER-blocker,software:", blocker, software)
+    # NOISY-DEBUG: print("DEBUG: AFTER blocker,software:", blocker, software)
 
     if blocker == "":
         print("WARNING: blocker is now empty!")
@@ -165,7 +165,7 @@ for blocker, software in fba.cursor.fetchall():
                 # handling CSRF, I've saw at least one server requiring it to access the endpoint
                 # NOISY-DEBUG: print("DEBUG: Fetching meta:", blocker)
                 meta = bs4.BeautifulSoup(
-                    reqto.get(f"https://{blocker}/about", headers=fba.headers, timeout=fba.(config["connection_timeout"], config["read_timeout"])).text,
+                    reqto.get(f"https://{blocker}/about", headers=fba.headers, timeout=(fba.config["connection_timeout"], config["read_timeout"])).text,
                     "html.parser",
                 )
                 try:
@@ -177,7 +177,7 @@ for blocker, software in fba.cursor.fetchall():
                     reqheaders = fba.headers
 
                 # NOISY-DEBUG: print("DEBUG: Quering API domain_blocks:", blocker)
-                blocks = reqto.get(f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqheaders, timeout=fba.(config["connection_timeout"], config["read_timeout"])).json()
+                blocks = reqto.get(f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqheaders, timeout=(fba.config["connection_timeout"], config["read_timeout"])).json()
 
                 # NOISY-DEBUG: print("DEBUG: blocks():", len(blocks))
                 for block in blocks:
@@ -286,9 +286,9 @@ for blocker, software in fba.cursor.fetchall():
 
                 for instance in blocks:
                     blocked, reason = instance.values()
-                    # NOISY-DEBUG: print("DEBUG: BEFORE-blocked:", blocked)
+                    # NOISY-DEBUG: print("DEBUG: BEFORE blocked:", blocked)
                     blocked = fba.tidyup(blocked)
-                    # NOISY-DEBUG: print("DEBUG: AFTER-blocked:", blocked)
+                    # NOISY-DEBUG: print("DEBUG: AFTER blocked:", blocked)
 
                     if blocked == "":
                         print("WARNING: blocked is empty:", blocker)
@@ -347,7 +347,7 @@ for blocker, software in fba.cursor.fetchall():
         print("INFO: blocker:", blocker)
         try:
             # Blocks
-            federation = reqto.get(f"https://{blocker}/api/v1/instance/peers?filter=suspended", headers=fba.headers, timeout=fba.(config["connection_timeout"], config["read_timeout"])).json()
+            federation = reqto.get(f"https://{blocker}/api/v1/instance/peers?filter=suspended", headers=fba.headers, timeout=(fba.config["connection_timeout"], config["read_timeout"])).json()
 
             if (federation == None):
                 print("WARNING: No valid response:", blocker);
@@ -357,9 +357,9 @@ for blocker, software in fba.cursor.fetchall():
                 # NOISY-DEBUG: print("DEBUG: Checking fenderation():", len(federation))
                 for peer in federation:
                     blocked = peer["domain"].lower()
-                    # NOISY-DEBUG: print("DEBUG: BEFORE-blocked:", blocked)
+                    # NOISY-DEBUG: print("DEBUG: BEFORE blocked:", blocked)
                     blocked = fba.tidyup(blocked)
-                    # NOISY-DEBUG: print("DEBUG: AFTER-blocked:", blocked)
+                    # NOISY-DEBUG: print("DEBUG: AFTER blocked:", blocked)
 
                     if blocked == "":
                         print("WARNING: blocked is empty:", blocker)