Gerador de vídeos narrativos (Godot + FFmpeg), painel Next.js, serviço de voz, Clipador de lives e Publicador para YouTube, TikTok e Instagram. Inclui a leitura das visualizações dos posts para o Dashboard e o botão "Publicar no <rede>" nos cartões das publicações. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""Utilidades compartilhadas pelos scripts da skill cenaforge (só biblioteca padrão)."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import shutil
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# .claude/skills/cenaforge/scripts/<arquivo> -> raiz do repositório
|
|
REPO_ROOT = Path(__file__).resolve().parents[4]
|
|
RUNS_DIR = REPO_ROOT / "output" / "runs"
|
|
LAST_SUCCESS = REPO_ROOT / "output" / "last-success.json"
|
|
|
|
|
|
def utf8_stdout() -> None:
|
|
"""Console do Windows pode vir em cp1252; acentos e '—' quebrariam."""
|
|
for stream in (sys.stdout, sys.stderr):
|
|
try:
|
|
stream.reconfigure(encoding="utf-8")
|
|
except (AttributeError, ValueError):
|
|
pass
|
|
|
|
|
|
def rel(path: Path) -> str:
|
|
try:
|
|
return path.resolve().relative_to(REPO_ROOT).as_posix()
|
|
except ValueError:
|
|
return str(path)
|
|
|
|
|
|
def load_json(path: Path) -> dict:
|
|
with open(path, encoding="utf-8") as f:
|
|
return json.load(f)
|
|
|
|
|
|
def find_tool(name: str) -> str | None:
|
|
"""Mesma ordem do lançador: variável de ambiente -> PATH -> .tools/ (só Godot)."""
|
|
env = {"godot": "GODOT_BIN", "ffmpeg": "FFMPEG_BIN", "ffprobe": "FFPROBE_BIN"}[name]
|
|
if os.environ.get(env):
|
|
return os.environ[env] if Path(os.environ[env]).is_file() else None
|
|
for candidate in ([name, "godot4"] if name == "godot" else [name]):
|
|
found = shutil.which(candidate)
|
|
if found:
|
|
return found
|
|
if name == "godot":
|
|
pattern = "Godot_v*-stable_win64.exe" if os.name == "nt" else "Godot_v*-stable_linux.x86_64"
|
|
for exe in sorted((REPO_ROOT / ".tools").glob(f"godot-*/{pattern}"), reverse=True):
|
|
return str(exe)
|
|
return None
|