#!/usr/bin/env python3
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}"}
BASE = "https://api.getxapi.com/twitter"

for h in ["emeeliojohann", "luke_o", "Santanutwts", "SebastianRoehl", "zodchiii"]:
    r = requests.get(f"{BASE}/user/tweets", params={"userName": h, "count": 30}, headers=H, timeout=40)
    if r.status_code != 200:
        print(f"\n### @{h} HTTP {r.status_code}"); time.sleep(0.3); continue
    tw = r.json().get("tweets", [])
    if not tw:
        print(f"\n### @{h} EMPTY"); time.sleep(0.3); continue
    au = tw[0].get("author", {})
    bio = (au.get("description") or "").replace("\n", " ")[:140]
    print(f"\n### @{h} | f={au.get('followers')} | {au.get('location') or ''}")
    print(f"BIO: {bio}")
    for t in tw[:8]:
        txt = " ".join((t.get("text") or "").split())[:170]
        print(f"  - {str(t.get('createdAt'))[:10]} | {txt}")
    time.sleep(0.3)
