From 1298e391d097f0d40f094267bfcc92a8ea660a95 Mon Sep 17 00:00:00 2001 From: Archos Date: Mon, 27 Apr 2026 19:31:59 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=C4=8Desk=C3=A9=20hashtagy=20z=20timeli?= =?UTF-8?q?ne,=20oprava=20mezery=20za=20#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- daily_top.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/daily_top.py b/daily_top.py index 1ba5cd5..4437350 100644 --- a/daily_top.py +++ b/daily_top.py @@ -37,6 +37,7 @@ def api_get(url, token): def clean_content(content): text = re.sub(r"<[^>]+>", " ", content) text = html.unescape(text) + text = re.sub(r"#\s+(\w)", r"#\1", text) return re.sub(r"\s+", " ", text).strip() def main(): @@ -56,8 +57,15 @@ def main(): sys.exit(1) try: - trend_tags = api_get(f"{base_url}/api/v1/trends/tags?limit=5", token) - tags = [t["name"] for t in trend_tags] + timeline = api_get(f"{base_url}/api/v1/timelines/public?local=true&limit=40", token) + tag_counts = {} + for toot in timeline: + if toot.get("language") != "cs": + continue + for tag in toot.get("tags", []): + name = tag["name"] + tag_counts[name] = tag_counts.get(name, 0) + 1 + tags = [t for t, _ in sorted(tag_counts.items(), key=lambda x: x[1], reverse=True)[:5]] except Exception: tags = []