#!/usr/bin/env python3
"""Prompt-harvest + notable-post text extraction, 2026-10-27."""
import json, re
from datetime import datetime, timezone, timedelta

RAW = "/home/kiro/trend-engine/trends/x/raw"
d = json.load(open(f"{RAW}/scan_results_2026-10-27_FULL.json"))
raws = d["raw"]
def pd(s):
    try: return datetime.strptime(s, "%a %b %d %H:%M:%S %z %Y")
    except Exception: return None
now = datetime.now(timezone.utc)
cutoff = now.replace(hour=0,minute=0,second=0,microsecond=0)-timedelta(days=3)

def show(h, minlen=0, limit=12, maxchar=700):
    print(f"\n########## @{h} ##########")
    tw = [t for t in raws.get(h, []) if not t.get("retweeted_tweet")]
    tw = sorted([t for t in tw if (pd(t.get("createdAt","")) or datetime.min.replace(tzinfo=timezone.utc))>=cutoff],
                key=lambda t: pd(t["createdAt"]))
    for t in tw[-limit:]:
        txt = (t.get("text") or "")
        if len(txt) < minlen: continue
        print(f"\n[{pd(t['createdAt']).strftime('%m-%d %H:%M')} {t.get('likeCount',0)}L/{t.get('viewCount',0)}V reply={t.get('isReply')}]")
        print(txt[:maxchar].replace("\n", " | "))
        print(f"https://x.com/{h}/status/{t.get('id')}")

# prompt-harvest handles -- do they post the full prompt?
for h in ["Soaima_Ai", "ItsMaryamAi", "ElsaSofia__AI", "AI__TSUBAKI"]:
    show(h, limit=14, maxchar=900)

show("AIWarper", limit=8, maxchar=600)
show("CharaspowerAI", limit=8, maxchar=600)
show("venthuret", limit=1)
show("venturetwins", limit=9, maxchar=600)
show("Kling_ai", limit=6, maxchar=500)
show("Flovaai", limit=6, maxchar=500)
show("higgsfield_ai", limit=20, maxchar=400)
