--- /dev/null
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+
+# Fedi API Block - An aggregator for fetching blocking data from fediverse nodes
+# Copyright (C) 2023 Free Software Foundation
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+import json
+import sys
+import validators
+import fba
+
+domains = list()
+try:
+ fetched = fba.post_json_api("gql.api.bka.li", "/v1/graphql", json.dumps({
+ "query": "query domainlist {nodeinfo(order_by: {domain: asc}) {domain}}"
+ }))
+
+ # DEBUG: print(f"DEBUG: fetched({len(fetched)})[]='{type(fetched)}'")
+ if len(fetched) > 0 and "data" in fetched and "nodeinfo" in fetched["data"]:
+ for entry in fetched["data"]["nodeinfo"]:
+ # DEBUG: print(f"DEBUG: entry['{type(entry)}']='{entry}'")
+ if not "domain" in entry:
+ print(f"WARNING: entry does not contain 'domain' - SKIPPED!")
+ continue
+ elif not validators.domain(entry["domain"]):
+ print(f"WARNING: domain='{entry['domain']}' is {entry['domain']}' is not a valid domain - SKIPPED!")
+ continue
+ elif fba.is_blacklisted(entry["domain"]):
+ # DEBUG: print(f"DEBUG: domain='blacklisted - SKIPPED!")
+ continue
+
+ domains.append(entry["domain"])
+
+except BaseException as e:
+ print(f"ERROR: Cannot fetch graphql,exception[{type(e)}]:'{str(e)}'")
+ sys.exit(255)
+
+# Show domains
+# DEBUG: print(f"DEBUG: domains()={len(domains)}")
+if len(domains) > 0:
+ print(f"INFO: Adding {len(domains)} new instances ...")
+ for domain in domains:
+ print(f"INFO: Fetching instances from domain='{domain}' ...")
+ fba.fetch_instances(domain, None, None, sys.argv[0])
+
+fba.connection.close()