]> git.mxchange.org Git - fba.git/blobdiff - fba/networks/mastodon.py
Continued:
[fba.git] / fba / networks / mastodon.py
index cda3cc4786b328cc2e20307de4b9721da831dbd8..f0de5de88b33a0217ec5b257f651eb7d1952006f 100644 (file)
@@ -115,10 +115,24 @@ def fetch_blocks_from_about(domain: str) -> dict:
         if header_text in blocklist or header_text.lower() in blocklist:
             # replaced find_next_siblings with find_all_next to account for instances that e.g. hide lists in dropdown menu
             for line in header.find_all_next("table")[0].find_all("tr")[1:]:
+                domain = line.find("span").text
+                hash   = line.find("span")["title"][9:]
+                reason = line.find_all("td")[1].text
+
+                logger.debug("domain='%s',reason='%s' - BEFORE!", domain, reason)
+                domain = tidyup.domain(domain) if domain != "" else None
+                reason = tidyup.reason(reason) if reason != "" else None
+
+                logger.debug("domain='%s',reason='%s' - AFTER!", domain, reason)
+                if domain is None or domain == "":
+                    logger.warning("domain='%s' is empty,line='%s' - SKIPPED!", domain, line)
+                    continue
+
+                logger.debug("Appending domain='%s',hash='%s',reason='%s' to blocklist header_text='%s' ...", domain, hash, reason, blocklist)
                 blocklist[header_text].append({
-                    "domain": tidyup.domain(line.find("span").text),
-                    "hash"  : tidyup.domain(line.find("span")["title"][9:]),
-                    "reason": tidyup.reason(line.find_all("td")[1].text),
+                    "domain": domain,
+                    "hash"  : hash,
+                    "reason": reason,
                 })
         else:
             logger.warning("header_text='%s' not found in blocklist()=%d", header_text, len(blocklist))
@@ -157,6 +171,7 @@ def fetch_blocks(domain: str) -> list:
                 logger.debug("block[]='%s' is of type 'dict' - SKIPPED!", type(block))
                 continue
             elif "domain" not in block:
+                logger.debug("block='%s'", block)
                 logger.warning("block()=%d does not contain element 'domain' - SKIPPED!", len(block))
                 continue
             elif not domain_helper.is_wanted(block["domain"]):