#!/usr/bin/env python3
"""Hunt the 'documenting my vibe-coded app with cinematic videos' account."""
import json, os, time
import requests

key = None
for line in open(os.path.expanduser("~/.hermes/.env")):
    if line.startswith("GETXAPI_KEY="):
        key = line.split("=", 1)[1].strip()
        break
H = {"Authorization": f"Bearer {key}"}
URL = "https://api.getxapi.com/twitter/tweet/advanced_search"

QUERIES = [
    ('K_documenting', '("documenting" OR "document my") ("vibe coding" OR "vibe coded" OR "vibe-coded") (app OR saas OR startup) since:2026-01-01'),
    ('L_billion', '("vibe coded" OR "vibe coding" OR "vibe-coded") (billion OR "$1B" OR "1 billion") since:2026-01-01'),
    ('M_cinematic', '(cinematic) ("building in public" OR "build in public" OR "vibe coding") (app OR saas) since:2026-01-01'),
    ('N_founder_video', '("building in public" OR "solo founder") (cinematic OR "short film" OR documentary) (app OR saas) since:2026-01-01'),
    ('O_scale_billion', '("my app" OR "my startup") ("will scale" OR "scaling to" OR "next billion") (AI OR vibecoded) since:2026-01-01'),
]

out = {}
for name, q in QUERIES:
    r = requests.get(URL, params={"q": q, "product": "Top"}, headers=H, timeout=45)
    if r.status_code != 200:
        print(f"[{name}] HTTP {r.status_code}"); continue
    tw = r.json().get("tweets", [])
    out[name] = {"query": q, "tweets": tw}
    print(f"[{name}] {len(tw)}")
    for t in sorted(tw, key=lambda x: x.get("likeCount", 0) or 0, reverse=True)[:8]:
        a = (t.get("author") or {}).get("userName", "?")
        txt = " ".join((t.get("text") or "").split())[:230]
        print(f"   @{a} | {t.get('likeCount')} | {str(t.get('createdAt'))[:10]}")
        print(f"     {txt}")
    time.sleep(0.4)

json.dump(out, open("/home/kiro/trend-engine/trends/x/banger-x-results/2026-11-05_vibe-billion-hunt.json", "w"), indent=1)
