"""Projeto: inspecionar o .fcpxml e lembrar a pasta/arquivo em uso. Extraído de models_api.py — a tabela de comandos segue lá. """ from __future__ import annotations from pathlib import Path from fcpxml.model_manager import ( load_project_config, save_project_config, ) from fcpxml.parser import parse_fcpxml from . import shared def cmd_inspect(args: dict) -> int: """Validate an FCPXML file and return a summary of its projects/timelines.""" path = str(args.get("path", "")) if not path: shared.emit({"ok": False, "error": "Nenhum arquivo informado."}) return 1 if not Path(path).exists(): shared.emit({"ok": False, "error": "Arquivo não encontrado."}) return 1 try: proj = parse_fcpxml(path) except Exception as exc: shared.emit({"ok": False, "error": f"Erro ao ler o projeto: {exc}"}) return 1 timelines = [] for tl in proj.timelines: timelines.append( { "name": tl.name, "duration_seconds": round(tl.duration.seconds, 3), "frame_rate": round(tl.frame_rate, 3), "width": tl.width, "height": tl.height, "clips": tl.total_clips, "cuts": tl.total_cuts, "connected": len(tl.connected_clips), "markers": len(tl.markers), } ) shared.emit( { "ok": True, "path": path, "name": proj.name, "fcpxml_version": proj.fcpxml_version, "timelines": timelines, } ) return 0 def cmd_project_config(args: dict) -> int: """Read the last project folder/file the app was working on.""" shared.emit({"ok": True, **load_project_config()}) return 0 def cmd_set_project_config(args: dict) -> int: """Persist the last project folder/file. Only the given fields change.""" config = save_project_config(folder=args.get("folder"), file=args.get("file")) shared.emit({"ok": True, **config}) return 0