import json, re, requests
d = json.load(open('/home/kiro/trend-engine/trends/x/raw/scan_results_2026-10-15_FULL.json'))
q = d['qualifying']
AI = re.compile(r'\b(ai\b|3d|generated) ?animation|\bai\b|gemini|(?<!\bfilm )(?<!\bfilm-)(?<!\bscreenplay )(?<!\bscreenplay-)\bprompt|generative|midjourney|sora|runway|veo|seedance|kling', re.I)
print('--- nofilmschool texts (AI term check) ---')
for x in sorted([y for y in q if y['handle'] == 'nofilmschool'], key=lambda y: -y['score']):
    t = x['text'] or ''
    m = AI.search(t)
    print(('MATCH ' + repr(m.group(0))) if m else 'no-match', '|', t[:150])
print('\nKatana mentions in qualifying:', sum(1 for x in q if 'katana' in (x['text'] or '').lower()))
# resolve t.co of the #1 core post
try:
    r = requests.head('https://t.co/ygh7Bp66EE', allow_redirects=True, timeout=20)
    print('\n#1 post link resolves to:', r.url)
    r2 = requests.get(r.url, timeout=20)
    print('final status', r2.status_code, '| title:', re.search(r'<title>(.*?)</title>', r2.text, re.S).group(1)[:120] if '<title>' in r2.text else 'n/a')
except Exception as e:
    print('resolve failed:', e)
