#!/usr/bin/env python3
"""Validasi caption Threads 12 Okt 2026 sebelum create."""
import json, re

P = "/home/mantapman/.hermes/profiles/atun/workspace/threads_content_today.json"
d = json.load(open(P))
print("date:", d["date"], "| akun:", len(d["accounts"]))
CJK = re.compile(r"[\u3000-\u303f\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uac00-\ud7af\uff00-\uffef]")
CTA = re.compile(r"komentar|tulis di|ceritakan|menurut kamu", re.I)
MENTION = re.compile(r"@\w+")
URL = re.compile(r"https?://\S+")
bad = 0
for a in d["accounts"]:
    t = a["text"]
    links = URL.findall(t)
    tags = re.findall(r"#(\w+)", t)
    cek = {
        "len": len(t),
        "le500": len(t) <= 500,
        "link": len(links),
        "cta": bool(CTA.search(t[-160:])),
        "mention": MENTION.findall(t),
        "cjk": CJK.findall(t),
        "hashtag_besar": [x for x in tags if x != x.lower()],
        "topic_len": len(a.get("topic", "")),
        "anda": t.count("Anda"),
    }
    print(f"\n-- {a['account']} slot {a['slot']}: {cek}")
    if not cek["le500"] or cek["link"] == 0 or not cek["cta"] or cek["mention"] or cek["cjk"] or cek["topic_len"] > 50:
        bad += 1
        print("   ❌ MASALAH")
print("\nTOTAL bermasalah:", bad)
