#!/usr/bin/env python3
"""Pastikan media StudioSoft yang jadwalnya dihapus masih ada di server (tidak ikut terhapus)."""
import glob, os, subprocess

WS = "/home/mantapman/.hermes/profiles/atun/workspace"
IMG = f"{WS}/openclaw-img"

PERIKSA = {
    "story seri klinik (ss_storyvid_hc*)": f"{IMG}/ss_storyvid_hc*",
    "reel warna (ss_reel_biru_* / ss_reel_putih_*)": f"{IMG}/ss_reel_[bp]*",
    "album opt2 (ss_opt2_*)": f"{IMG}/ss_opt2_*",
    "carousel 10 slide (ss_car10_*)": f"{IMG}/ss_car10_*",
    "story canvas (ss_story_canvas_*)": f"{IMG}/ss_story_canvas_*",
    "carousel 4 slide lama (SSIGSEP_*)": f"{IMG}/SSIGSEP_*",
}
for label, pola in PERIKSA.items():
    berkas = glob.glob(pola)
    total = sum(os.path.getsize(f) for f in berkas if os.path.isfile(f))
    print(f"  {label:<48} {len(berkas):>5} berkas · {total / 1024 / 1024:.1f} MB")

print("\nberkas yang jadwalnya baru dihapus (harus tetap ada):")
WAJIB = ["ss_storyvid_hc42_seoklinik.mp4", "ss_storyvid_hc41_analytics.mp4", "ss_storyvid_hc40_klinikkecil.mp4",
         "ss_storyvid_hc39_iklanfb.mp4", "ss_storyvid_hc38_website.mp4", "ss_storyvid_hc37_edukasi.mp4",
         "ss_storyvid_hc36_klinikdm.mp4", "ss_storyvid_hc32.mp4", "ss_storyvid_hc31.mp4",
         "ss_reel_biru_11.mp4", "ss_opt2_11_01.jpg", "ss_opt2_11_02.jpg", "ss_opt2_11_03.jpg", "ss_opt2_11_04.jpg",
         "ss_reel_putih_20.mp4", "ss_reel_biru_19.mp4"]
hilang = []
for n in WAJIB:
    p = os.path.join(IMG, n)
    ada = os.path.exists(p)
    print(f"   {'✅' if ada else '❌ HILANG'} {n}")
    if not ada:
        hilang.append(n)
print(f"\n  hilang: {len(hilang)}")

# trash khusus (kalau ada pemakaian `trash` di workspace)
r = subprocess.run(["bash", "-lc", f"ls -1 {WS}/../trash 2>/dev/null | head -3"], capture_output=True, text=True)
print(f"  folder trash: {r.stdout.strip() or '(tidak ada)'}")
total_img = subprocess.run(["bash", "-lc", f"du -sh {IMG}"], capture_output=True, text=True).stdout.strip()
print(f"  total folder media: {total_img}")
