From 1944c56d9c9b9e3b5663452b43c9ae1a6622ec6b Mon Sep 17 00:00:00 2001 From: Archos Date: Sat, 11 Apr 2026 12:22:15 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20hashtagy=20z=20featured=5Ftags=20m?= =?UTF-8?q?=C3=ADsto=20bio=20parsov=C3=A1n=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mastodon_cz_accounts.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mastodon_cz_accounts.py b/mastodon_cz_accounts.py index b1676b7..b61c87e 100644 --- a/mastodon_cz_accounts.py +++ b/mastodon_cz_accounts.py @@ -232,14 +232,17 @@ def categorize(acc): return cat return "ostatni" -def extract_tags(acc): - text = re.sub(r"<[^>]+>", " ", acc.get("note", "") or "").lower() - found = [] - for kws in CATEGORIES.values(): - for kw in kws: - if kw in text and kw not in found and len(kw) > 3: - found.append(kw.strip()) - return found[:4] +def fetch_featured_tags(acc): + account_id = acc.get("id") + instance = acc.get("_source_instance", "") + if not account_id or not instance: + return [] + url = f"https://{instance}/api/v1/accounts/{account_id}/featured_tags" + token = _token_for(instance) + data = api_get(url, token=token) + if not data or not isinstance(data, list): + return [] + return [t["name"] for t in data if isinstance(t, dict) and t.get("name")][:4] # ── VÝSTUP ──────────────────────────────────── def _to_output(acc): @@ -253,7 +256,7 @@ def _to_output(acc): "followers": acc.get("followers_count", 0), "statuses": acc.get("statuses_count", 0), "score": score(acc), - "tags": extract_tags(acc), + "tags": fetch_featured_tags(acc), "category": categorize(acc), "last_active": acc.get("last_status_at", ""), "url": acc.get("url", ""),