diff --git a/backend/cli.py b/backend/cli.py index 1524668..6c281f8 100644 --- a/backend/cli.py +++ b/backend/cli.py @@ -390,6 +390,65 @@ def cmd_studio(args): sys.exit(rc) +def cmd_reel(args): + """Create and iterate on a highlights reel — detect once, then edit moments fast.""" + from services.reel import ( + ReelSession, seed_session, edit_moment, build_reel, list_sessions, delete_session, + ) + from services.transcript_packer import compute_cache_hash, load_cached_transcript_for_video + + def _mmss(s): + return f"{int(s // 60)}:{int(s % 60):02d}" + + def _show(session): + for i, m in enumerate(session.moments, 1): + flag = "" if m.enabled else " (disabled)" + print(f" [{i}] {_mmss(m.start)}-{_mmss(m.end)} ({m.duration:.0f}s, {m.why}){flag}") + if m.text: + print(" " + (m.text[:150] + "…" if len(m.text) > 150 else m.text)) + + action = getattr(args, "reel_action", None) + if action == "new": + video = _clean_path(args.video) + sid = compute_cache_hash(video) + out_dir = args.output or os.path.join(os.getcwd(), f"reel_{sid[:8]}") + cached = load_cached_transcript_for_video(video) + words = cached.get("words") if cached else None + print(" Detecting moments (one-time)...") + session = seed_session( + sid, video, out_dir, profile=args.profile or "auto", + format=args.format or "horizontal", top_n=args.top or 10, + min_dur=args.min_dur, max_dur=args.max_dur, + words=words, progress_callback=lambda p, m: print(f" {m}") if m else None, + ) + _show(session) + print(" Building reel...") + reel = build_reel(session) + print(f" ✓ {reel}") + print(f" session: {sid}") + print(f" edit with: podcli reel edit {sid} [secs]") + elif action == "list": + for s in list_sessions(): + print(f" {s['session_id']} {s['profile']}/{s['format']} " + f"{s['enabled_count']}/{s['moment_count']} moments {os.path.basename(s['source'])}") + elif action == "delete": + ok = delete_session(args.session) + print(f" {'✓ deleted' if ok else '✗ no such session'} {args.session}") + elif action == "show": + _show(ReelSession.load(args.session)) + elif action == "edit": + session = edit_moment(ReelSession.load(args.session), args.index, args.op, args.seconds) + reel = build_reel(session) + print(f" ✓ rebuilt {reel}") + _show(session) + elif action == "build": + reel = build_reel(ReelSession.load(args.session)) + print(f" ✓ {reel}") + else: + print(" Usage: podcli reel new