From ceb55d31929cb7ed18930f4ac55529e2b8571467 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 23 May 2023 10:48:59 +0200 Subject: [PATCH] Continued: - added more mastodon-typical fields --- fba.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fba.py b/fba.py index b1a1fd8..5de6ba3 100644 --- a/fba.py +++ b/fba.py @@ -324,10 +324,15 @@ def determine_software(domain: str) -> str: return None # NOISY-DEBUG: print("DEBUG: json():", len(json), json) - if "software" not in json or "name" not in json["software"]: + if "status" in json and json["status"] == "error" and "message" in json: + print("WARNING: JSON response is an error:", json["message"]) + update_last_error(domain, json["message"]) + return None + elif "software" not in json or "name" not in json["software"]: print("WARNING: JSON response does not include [software][name], guessing ...") found = 0 - for element in {"uri", "title", "description", "email", "version", "urls", "stats", "thumbnail", "languages", "contact_account"}: + for element in {"uri", "title", "short_description", "description", "email", "version", "urls", "stats", "thumbnail", "languages", "contact_account", "registrations", "approval_required"}: + # NOISY-DEBUG: print("DEBUG: element:", element) if element in json: found = found + 1 @@ -336,7 +341,7 @@ def determine_software(domain: str) -> str: # NOISY-DEBUG: print("DEBUG: Maybe is Mastodon:", domain) return "mastodon" - print("WARNING: Cannot guess software type:", domain, found, len(json)) + print(f"WARNING: Cannot guess software type: domain='{domain}',found={found},json()={len(json)}") return None software = tidyup(json["software"]["name"]) @@ -366,7 +371,7 @@ def determine_software(domain: str) -> str: return software def update_block_reason(reason: str, blocker: str, blocked: str, block_level: str): - # NOISY: # NOISY-DEBUG: print("DEBUG: Updating block reason:", reason, blocker, blocked, block_level) + # NOISY-DEBUG: print("DEBUG: Updating block reason:", reason, blocker, blocked, block_level) try: cursor.execute( "UPDATE blocks SET reason = ?, last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ? AND reason = ''", @@ -387,7 +392,7 @@ def update_block_reason(reason: str, blocker: str, blocked: str, block_level: st sys.exit(255) def update_last_seen(blocker: str, blocked: str, block_level: str): - # NOISY: # NOISY-DEBUG: print("DEBUG: Updating last_seen for:", blocker, blocked, block_level) + # NOISY-DEBUG: print("DEBUG: Updating last_seen for:", blocker, blocked, block_level) try: cursor.execute( "UPDATE blocks SET last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ?", -- 2.39.5