]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 1 Jul 2023 16:41:06 +0000 (18:41 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 1 Jul 2023 16:41:06 +0000 (18:41 +0200)
- if --software parameter is given, no need to fetch whole software list from
  fediverse.observer

daemon.py
fba/commands.py
fba/http/federation.py

index acc6cdff8d5a9aa96a0c3b0ae1e1f0277e33cc72..af6cee94d0d91445af933cb472ecd37ec55e989d 100755 (executable)
--- a/daemon.py
+++ b/daemon.py
@@ -341,7 +341,6 @@ def rss(request: Request, domain: str):
             # Generic
             instance[key] = domain_data[key]
 
-    print(domain_data.keys())
     return templates.TemplateResponse("views/infos.html", {
         "request" : request,
         "domain"  : domain,
index af246757c2fd9561a12419cb490e231c70ff1887..58fe8a58c5b7742a7b87e0f4c6b9700d9081ccdc 100644 (file)
@@ -406,31 +406,34 @@ def fetch_observer(args: argparse.Namespace) -> int:
     # Acquire lock
     locking.acquire()
 
-    logger.info("Fetching software list ...")
-    raw = utils.fetch_url(
-        "https://fediverse.observer",
-        network.web_headers,
-        (config.get("connection_timeout"), config.get("read_timeout"))
-    ).text
-    logger.debug("raw[%s]()=%d", type(raw), len(raw))
-
-    doc = bs4.BeautifulSoup(raw, features="html.parser")
-    logger.debug("doc[]='%s'", type(doc))
+    types = list()
+    if args.software is None:
+        logger.info("Fetching software list ...")
+        raw = utils.fetch_url(
+            "https://fediverse.observer",
+            network.web_headers,
+            (config.get("connection_timeout"), config.get("read_timeout"))
+        ).text
+        logger.debug("raw[%s]()=%d", type(raw), len(raw))
 
-    items = doc.find("div", {"aria-labelledby": "navbarDropdownMenuSoftwares"}).findAll("a", {"class": "dropdown-item"})
-    logger.debug("items[]='%s'", type(items))
+        doc = bs4.BeautifulSoup(raw, features="html.parser")
+        logger.debug("doc[]='%s'", type(doc))
 
-    types = list()
+        items = doc.find("div", {"aria-labelledby": "navbarDropdownMenuSoftwares"}).findAll("a", {"class": "dropdown-item"})
+        logger.debug("items[]='%s'", type(items))
 
-    logger.info("Checking %d menu items ...", len(items))
-    for item in items:
-        logger.debug("item[%s]='%s'", type(item), item)
-        if item.text.lower() == "all":
-            logger.debug("Skipping 'All' menu entry ...")
-            continue
+        logger.info("Checking %d menu items ...", len(items))
+        for item in items:
+            logger.debug("item[%s]='%s'", type(item), item)
+            if item.text.lower() == "all":
+                logger.debug("Skipping 'All' menu entry ...")
+                continue
 
-        logger.debug("Appending item.text='%s' ...", item.text)
-        types.append(tidyup.domain(item.text))
+            logger.debug("Appending item.text='%s' ...", item.text)
+            types.append(tidyup.domain(item.text))
+    else:
+        logger.info("Adding args.software='%s' as type ...", args.software)
+        types.append(args.software)
 
     logger.info("Fetching %d different table data ...", len(types))
     for software in types:
index b60b051ccfcc15177a83ab5548ea103a98ba4032..b053c7ccfeb38b6641aa10ab62cf7567d3faeec2 100644 (file)
@@ -403,7 +403,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str:
 
             logger.debug("software[%s]='%s'", type(software), software)
             if software is not None and software != "":
-                logger.info("domain='%s' is generated by '%s'", domain, software)
+                logger.info("domain='%s' is generated by software='%s'", domain, software)
                 instances.set_detection_mode(domain, "GENERATOR")
         elif isinstance(site_name, bs4.element.Tag) and isinstance(site_name.get("content"), str):
             logger.debug("Found property=og:site_name, domain='%s'", domain)