feat: nejaktivnější hodina v týdenním i měsíčním přehledu

This commit is contained in:
2026-06-15 19:18:02 +02:00
parent bd69a8934e
commit 52f57da254
2 changed files with 43 additions and 3 deletions
+8
View File
@@ -7,6 +7,9 @@ import sys
import urllib.request
import urllib.error
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
_TZ_PRAGUE = ZoneInfo("Europe/Prague")
def load_env(path=".env"):
env = {}
@@ -83,7 +86,11 @@ def main():
tag_counts = {}
candidates = []
media_count = {"image": 0, "video": 0, "gifv": 0, "audio": 0, "total": 0}
hourly_count = {str(h): 0 for h in range(24)}
for toot in timeline:
created_at = datetime.fromisoformat(toot["created_at"].replace("Z", "+00:00"))
local_hour = str(created_at.astimezone(_TZ_PRAGUE).hour)
hourly_count[local_hour] += 1
for att in toot.get("media_attachments", []):
att_type = att.get("type", "")
media_count["total"] += 1
@@ -158,6 +165,7 @@ def main():
"tags": tags,
"top_links": top_links,
"media_count": media_count,
"hourly_count": hourly_count,
}, f, ensure_ascii=False, indent=2)
print(f"Uloženo: {out_path} ({len(timeline)} tootů načteno, {len(top)} top, {len(tags)} hashtagů)")