]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 2 Jun 2023 17:51:58 +0000 (19:51 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 2 Jun 2023 17:51:58 +0000 (19:51 +0200)
- also rewrote this

fetch_blocks.py

index d2649c06d6afef91f55e81adeeecb19e4097f48b..86e51621afa021410f10ce9bbde5939b2c8645a4 100755 (executable)
@@ -97,10 +97,14 @@ for blocker, software, origin, nodeinfo_url in rows:
                             )
                             searchres = fba.cursor.fetchone()
                             # DEBUG: print("DEBUG: searchres[]:", type(searchres))
-                            if searchres != None:
-                                blocked = searchres[0]
-                                nodeinfo_url = searchres[1]
-                                # DEBUG: print("DEBUG: Looked up domain:", blocked)
+
+                            if searchres == None:
+                                print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
+                                continue
+
+                            blocked = searchres[0]
+                            nodeinfo_url = searchres[1]
+                            # DEBUG: print("DEBUG: Looked up domain:", blocked)
                         elif not validators.domain(blocked):
                             print(f"WARNING: blocked='{blocked}',software='{software}' is not a valid domai name - skipped!")
                             continue
@@ -175,10 +179,13 @@ for blocker, software, origin, nodeinfo_url in rows:
                             )
                             searchres = fba.cursor.fetchone()
 
-                            if searchres != None:
-                                blocked = searchres[0]
-                                origin = searchres[1]
-                                nodeinfo_url = searchres[2]
+                            if searchres == None:
+                                print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
+                                continue
+
+                            blocked = searchres[0]
+                            origin = searchres[1]
+                            nodeinfo_url = searchres[2]
                         elif not validators.domain(blocked):
                             print(f"WARNING: blocked='{blocked}',software='{software}' is not a valid domai name - skipped!")
                             continue
@@ -268,8 +275,8 @@ for blocker, software, origin, nodeinfo_url in rows:
                     continue
 
                 # DEBUG: print(f"DEBUG: Checking {len(blocks)} entries from blocker='{blocker}',software='{software}',block_level='{block_level}' ...")
-                for instance in blocks:
-                    blocked, blocked_hash, reason = instance.values()
+                for block in blocks:
+                    blocked, blocked_hash, reason = block.values()
                     # DEBUG: print("DEBUG: blocked,hash,reason:", blocked, blocked_hash, reason)
                     blocked = fba.tidyup(blocked)
                     # DEBUG: print("DEBUG: AFTER-blocked:", blocked)
@@ -288,7 +295,7 @@ for blocker, software, origin, nodeinfo_url in rows:
                         searchres = fba.cursor.fetchone()
 
                         if searchres == None:
-                            print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
+                            print(f"WARNING: Cannot deobsfucate blocked='{blocked}',blocked_hash='{blocked_hash}' - SKIPPED!")
                             continue
 
                         # DEBUG: print("DEBUG: Updating domain: ", searchres[0])
@@ -355,9 +362,11 @@ for blocker, software, origin, nodeinfo_url in rows:
             elif software == "bookwyrm":
                 print("WARNING: bookwyrm is not fully supported for fetching blacklist!", blocker)
                 #json = fba.get_bookwyrm_blocks(blocker)
+                continue
             elif software == "takahe":
                 print("WARNING: takahe is not fully supported for fetching blacklist!", blocker)
                 #json = fba.get_takahe_blocks(blocker)
+                continue
 
             print(f"INFO: Checking {len(json.items())} entries from blocker='{blocker}',software='{software}' ...")
             for block_level, blocks in json.items():
@@ -369,8 +378,8 @@ for blocker, software, origin, nodeinfo_url in rows:
                     continue
 
                 # DEBUG: print(f"DEBUG: Checking {len(blocks)} entries from blocker='{blocker}',software='{software}',block_level='{block_level}' ...")
-                for instance in blocks:
-                    blocked, reason = instance.values()
+                for block in blocks:
+                    blocked, reason = block.values()
                     # DEBUG: print("DEBUG: BEFORE blocked:", blocked)
                     blocked = fba.tidyup(blocked)
                     # DEBUG: print("DEBUG: AFTER blocked:", blocked)