#!/usr/bin/env python3
"""Pasang video Pak Otto (video7) ke IG + TikTok 17:10 WIB hari ini."""
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/soto_pakotto_video7.mp4"
AT = "2026-09-05T10:10:00.000Z"  # 17:10 WIB

CAP = (
    "Hangatnya Soto Semarang Pak Otto, fresh dari dapur tiap hari! 🍜✨\n\n"
    "Ayam kampung pilihan, kuah bening gurih, sambal yang pas — plus tempe mendoan 2 ribuan & lumpia Semarang 7 ribuan buat nemenin.\n\n"
    "Ga perlu ke Semarang, cukup ke Pagerwojo Sidoarjo! 😋\n\n"
    "📍 Jl. Graha Anggrek Mas No. C-16, Ruko Pagerwojo, Buduran, Sidoarjo\n"
    "⏰ Buka Setiap Hari: 10.00 - 21.00 WIB\n"
    "📲 081230777713\n\n"
    "Udah pernah mampir? Menu favoritmu apa? Cerita di komentar ya! 👇\n\n"
    "#SotoSemarangPakOtto #SotoSemarang #KulinerSidoarjo #KulinerMalam #WarungSemarang #SotoAyamKampung"
)

JOBS = [
    ("6a86d6e962caae1e04ffedaa", "IG"),
    ("6a86d70362caae1e04ffedef", "TikTok"),
]

ok = fail = 0
for accid, nm in JOBS:
    payload = {
        "accountId": accid,
        "title": f"Soto Pak Otto — Video 7 ({nm})",
        "description": CAP,
        "topic": "Video Soto",
        "type": "video",
        "medias": [{"url": VIDEO_URL, "type": "video", "alt": "soto_pakotto_video7.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} | 17:10 WIB hari ini | 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")
