#!/usr/bin/env python3
"""Pasang video LEIT baru ke IG + TikTok LEIT — 23:00 WIB 8 Sep."""
import sys, json, urllib.request
sys.path.insert(0, "/home/mantapman/.hermes/profiles/atun/workspace")
from repliz_client import HEADERS, BASE

VIDEO_URL = "https://mantapserver.tail3947bb.ts.net/openclaw-img/leit_video_new_01.mp4"
AT = "2026-09-08T16:00:00.000Z"  # 23:00 WIB

CAP = (
    "Belajar bahasa Inggris di LEIT itu beda — suasana seru, metode praktis, dan langsung praktik bicara! 🗣️✨\n\n"
    "Di kelas kecil, kamu makin percaya diri buat ngomong. Karena bahasa itu bukan cuma dihafal, tapi dibiasakan.\n\n"
    "Yuk mulai perjalanan bahasa Inggris kamu bareng LEIT! 📚\n\n"
    "📍 LEIT Surabaya — Timur (Pakuwon Town Square) & Barat (Waterplace Residence)\n"
    "📲 WA: 0811 331 700 (Timur) / 0811 396 483 (Barat)\n\n"
    "Kamu lagi cari kursus bahasa Inggris yang nggak ngebosenin? Cerita di komentar ya! 👇\n\n"
    "#leitsurabaya #kursusbahasainggris #belajarbahasainggris #englishcourse #leitsurabaya #kursusinggris"
)

JOBS = [
    ("6a7d765862caae1e04f7ded3", "IG"),
    ("6a82c69a62caae1e04fbde9c", "TikTok"),
]

ok = fail = 0
for accid, nm in JOBS:
    payload = {
        "accountId": accid,
        "title": f"LEIT — Video Baru ({nm})",
        "description": CAP,
        "topic": "Kursus Inggris",
        "type": "video",
        "medias": [{"url": VIDEO_URL, "type": "video", "alt": "leit_video_new_01.mp4"}],
        "scheduleAt": AT,
        "replies": [],
    }
    req = urllib.request.Request(f"{BASE}/public/schedule",
                                 data=json.dumps(payload).encode(),
                                 headers={**HEADERS, "Content-Type": "application/json"})
    try:
        with urllib.request.urlopen(req, timeout=30) as r:
            res = json.load(r)
        ok += 1
        print(f"  ✅ {nm:7s} | 23:00 WIB 8 Sep | id={res.get('_id') or res.get('id') or '?'}")
    except Exception as e:
        fail += 1
        print(f"  ❌ {nm}: {e}")
print(f"\n📊 Total: {ok} OK, {fail} gagal")
