#!/usr/bin/env python3
"""Cek HTTP status link calon + panjang caption + aturan (CJK, mention, 500 char)."""
import re, sys
sys.path.insert(0, "/home/mantapman/.hermes/profiles/atun/workspace")
from openssl_fetch import fetch

LINKS = [
    "https://studiosoft.id/ai-untuk-konten-marketing-menulis-artikel-seo-yang-disukai-google/",
    "https://studiosoft.id/optimasi-konten-masuk-ai-overview-google/",
    "https://www.tslaw.id/cara-daftar-cv-pt-online/",
    "https://www.theskincodeclinic.com/bekas-jerawat-cekung/",
    "https://dasindonesia.com/tips-menjaga-kesehatan-dan-kinerja-ac-mobil/",
]
for u in LINKS:
    try:
        st, head, body = fetch(u)
    except Exception as e:
        st, body = f"ERR {str(e)[:50]}", b""
    print(f"{st}  {len(body):>7}  {u}")

CJK = re.compile(r"[\u3000-\u9fff\uff00-\uffef\uac00-\ud7af]")
print("\n=== cek caption (dari file JSON kalau ada) ===")
import json, os
p = "/home/mantapman/.hermes/profiles/atun/workspace/threads_content_today.json"
if os.path.exists(p):
    d = json.load(open(p))
    print("date:", d.get("date"))
    for it in d["accounts"]:
        t = it["text"]
        urls = re.findall(r"https?://\S+", t)
        men = bool(re.search(r"@\w+", t))
        cjk = bool(CJK.search(t))
        print(f"  {it['account']:11} slot={it['slot']:>2} len={len(t):>3} urls={len(urls)} "
              f"mention={men} cjk={cjk} min={it.get('min')} max={it.get('max')}")
