#!/usr/bin/env python3
"""hc48: riwayat topik Threads SS (carousel) + artikel yang dipakai, dari dump Repliz."""
import json, re, sys
sys.path.insert(0, "/home/mantapman/.hermes/profiles/atun/workspace")
from repliz_client import ACC

d = json.load(open("/tmp/repliz_all_20260926.json"))
T = ACC.STUDIOSOFT_THREADS
url_re = re.compile(r"studiosoft\.id/([a-z0-9\-]+)")
rows = []
for x in d:
    if x.get("accountId") != T:
        continue
    t = (x.get("title") or "") + " " + (x.get("description") or "")
    slugs = set(url_re.findall(t))
    rows.append(((x.get("scheduleAt") or "")[:16], x.get("status"), (x.get("type") or ""),
                 len(x.get("medias") or []), ",".join(sorted(slugs)) or "-"))
rows.sort()
print(len(rows), "threads docs")
for r in rows:
    print(r)
