From d65aa2c171ba3cfda6f065e9b33b0b17f5e50c2e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 8 Aug 2023 20:14:54 +0200 Subject: [PATCH] Continued: - you can now with --feed=https://some-fba/feed.atom specify an other ATOM feed from an FBA/Pleroma bot - parserset_defaults() is now specified first, then additional parameter --- fba/boot.py | 11 ++++++----- fba/commands.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fba/boot.py b/fba/boot.py index 6d88b87..55e9fb4 100644 --- a/fba/boot.py +++ b/fba/boot.py @@ -55,8 +55,8 @@ def init_parser(): "check_instance", help="Checks given instance if it exists and returns proper exit code" ) - parser.add_argument("--domain", required=True, help="Instance name (aka. domain) to check") parser.set_defaults(command=commands.check_instance) + parser.add_argument("--domain", required=True, help="Instance name (aka. domain) to check") ### Fetch from bka.li ### parser = subparser_command.add_parser( @@ -70,10 +70,10 @@ def init_parser(): "recheck_obfuscation", help="Checks all instance's obfuscated peers if they can be de-obfuscated now.", ) + parser.set_defaults(command=commands.recheck_obfuscation) parser.add_argument("--domain", help="Instance name (aka. domain)") parser.add_argument("--software", help="Name of software, e.g. 'lemmy'") parser.add_argument("--force", action="store_true", help="Include also already existing instances, otherwise only new are checked") - parser.set_defaults(command=commands.recheck_obfuscation) ### Fetch blocks from registered instances or given ### parser = subparser_command.add_parser( @@ -104,8 +104,8 @@ def init_parser(): "fetch_fba_rss", help="Fetches domains from a FBA-specific RSS feed.", ) - parser.add_argument("--feed", required=True, help="RSS feed to fetch domains from (e.g. https://fba.ryoma.agency/rss?domain=foo.bar).") parser.set_defaults(command=commands.fetch_fba_rss) + parser.add_argument("--feed", required=True, help="RSS feed to fetch domains from (e.g. https://fba.ryoma.agency/rss?domain=foo.bar).") ### Fetch blocks from FBA's bot account ### parser = subparser_command.add_parser( @@ -113,23 +113,24 @@ def init_parser(): help="Fetches ATOM feed with domains from FBA's bot account.", ) parser.set_defaults(command=commands.fetch_fbabot_atom) + parser.add_argument("--feed", required=True, help="RSS feed to fetch domains from (e.g. https://fba.ryoma.agency/rss?domain=foo.bar).") ### Fetch blocks from oliphant's GIT repository ### parser = subparser_command.add_parser( "fetch_oliphant", help="Fetches CSV files (block recommendations) for more possible instances to disover", ) - parser.add_argument("--domain", help="Instance name (aka. domain) to check") parser.set_defaults(command=commands.fetch_oliphant) + parser.add_argument("--domain", help="Instance name (aka. domain) to check") ### Fetch instances from given initial instance ### parser = subparser_command.add_parser( "fetch_instances", help="Fetches instances (aka. \"domains\") from an initial instance. You may want to re-run this command several times (at least 3 with big instances) to have a decent amount of valid instances.", ) + parser.set_defaults(command=commands.fetch_instances) parser.add_argument("--domain", required=True, help="Instance name (aka. domain) to fetch further instances from. Start with a large instance, e.g. mastodon.social .") parser.add_argument("--single", action="store_true", help="Only fetch given instance.") - parser.set_defaults(command=commands.fetch_instances) ### Fetch blocks from static text file(s) ### parser = subparser_command.add_parser( diff --git a/fba/commands.py b/fba/commands.py index 3cdf7ce..475de87 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -834,6 +834,14 @@ def fetch_fbabot_atom(args: argparse.Namespace) -> int: locking.acquire() source_domain = "ryona.agency" + feed = f"https://{source_domain}/users/fba/feed.atom" + + logger.debug("args.feed[%s]='%s'", type(args.feed), args.feed) + if args.feed is not None and validators.url(args.feed): + logger.debug("Setting feed='%s' ...", args.feed) + feed = str(args.feed) + source_domain = urlparse(args.feed).netloc + if sources.is_recent(source_domain): logger.info("API from source_domain='%s' has recently being accessed - EXIT!", source_domain) return 0 @@ -841,8 +849,6 @@ def fetch_fbabot_atom(args: argparse.Namespace) -> int: logger.debug("source_domain='%s' has not been recently used, marking ...", source_domain) sources.update(source_domain) - feed = f"https://{source_domain}/users/fba/feed.atom" - domains = list() logger.info("Fetching ATOM feed='%s' from FBA bot account ...", feed) -- 2.39.5