]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 30 Jun 2023 22:49:36 +0000 (00:49 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 30 Jun 2023 22:49:36 +0000 (00:49 +0200)
- rewrote fetch_observer() to dynamically load software list
- 'dolphin' is another alias for 'misskey'

fba/commands.py
fba/helpers/software.py

index 5caa65f5fa7bcb981e5cd15599e23081c24278d6..58a39bc8826be4f2435effa50c80aa68f0779edd 100644 (file)
@@ -370,41 +370,36 @@ def fetch_blocks(args: argparse.Namespace) -> int:
 
 def fetch_observer(args: argparse.Namespace) -> int:
     logger.debug("args[]='%s' - CALLED!", type(args))
-    types = [
-        "akkoma",
-        "birdsitelive",
-        "bookwyrm",
-        "calckey",
-        "diaspora",
-        "foundkey",
-        "friendica",
-        "funkwhale",
-        "gancio",
-        "gnusocial",
-        "gotosocial",
-        "hometown",
-        "hubzilla",
-        "kbin",
-        "ktistec",
-        "lemmy",
-        "mastodon",
-        "microblogpub",
-        "misskey",
-        "mitra",
-        "mobilizon",
-        "owncast",
-        "peertube",
-        "pixelfed",
-        "pleroma",
-        "plume",
-        "snac",
-        "takahe",
-        "wildebeest",
-        "writefreely"
-    ]
 
+    # 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))
+
+    items = doc.find("div", {"aria-labelledby": "navbarDropdownMenuSoftwares"}).findAll("a", {"class": "dropdown-item"})
+    logger.debug("items[]='%s'", type(items))
+
+    types = list()
+
+    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.info("Fetching %d different table data ...", len(types))
     for software in types:
         logger.debug("software='%s' - BEFORE!", software)
@@ -422,7 +417,7 @@ def fetch_observer(args: argparse.Namespace) -> int:
             ).text
             logger.debug("raw[%s]()=%d", type(raw), len(raw))
 
-            doc = bs4.BeautifulSoup(raw, features='html.parser')
+            doc = bs4.BeautifulSoup(raw, features="html.parser")
             logger.debug("doc[]='%s'", type(doc))
         except network.exceptions as exception:
             logger.warning("Cannot fetch software='%s' from fediverse.observer: '%s'", software, type(exception))
@@ -543,7 +538,7 @@ def fetch_cs(args: argparse.Namespace):
     raw = utils.fetch_url("https://raw.githubusercontent.com/chaossocial/meta/master/federation.md", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout"))).text
     logger.debug("raw()=%d,raw[]='%s'", len(raw), type(raw))
 
-    doc = bs4.BeautifulSoup(markdown.markdown(raw, extensions=extensions), features='html.parser')
+    doc = bs4.BeautifulSoup(markdown.markdown(raw, extensions=extensions), features="html.parser")
     logger.debug("doc()=%d[]='%s'", len(doc), type(doc))
 
     silenced = doc.find("h2", {"id": "silenced-instances"}).findNext("table").find("tbody")
index 30e411821409ecbd7c6f303087b450730e44551d..f4e53ca868820325de39beb95cecb5469f10b766 100644 (file)
@@ -37,7 +37,7 @@ def alias(software: str) -> str:
     elif software in ["hometown", "ecko"]:
         logger.debug("Setting mastodon: software='%s'", software)
         software = "mastodon"
-    elif software in ["slipfox calckey", "calckey", "groundpolis", "foundkey", "cherrypick", "meisskey", "magnetar", "keybump"]:
+    elif software in ["slipfox calckey", "calckey", "groundpolis", "foundkey", "cherrypick", "meisskey", "magnetar", "keybump", "dolphin"]:
         logger.debug("Setting misskey: software='%s'", software)
         software = "misskey"
     elif software == "runtube.re":