feat: corrigido o carregamento automático da transcrição salva ao
- corrigido o carregamento automático da transcrição salva ao abrir a geração de legendas Resumo: - 1 arquivos alterados - 0 novos - 1 modificados - 0 removidos 1 file changed, 16 insertions(+), 2 deletions(-) Arquivos: - code/cep-plugin/main.js
This commit is contained in:
+16
-2
@@ -360,9 +360,13 @@ function legendasRenderizar() {
|
||||
}
|
||||
|
||||
function gerarLegendasDaTranscricao() {
|
||||
if (!silenceState.transcriptPath) { document.getElementById("legendasStatus").textContent = "Execute ou carregue uma transcrição primeiro."; return; }
|
||||
var caminhoDaTranscricao = obterCaminhoDaTranscricaoParaLegendas();
|
||||
if (!caminhoDaTranscricao) {
|
||||
document.getElementById("legendasStatus").textContent = "Escolha uma timeline na aba Editar vídeo e carregue uma transcrição salva ou execute a transcrição.";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var transcricao = JSON.parse(fs.readFileSync(silenceState.transcriptPath, "utf-8"));
|
||||
var transcricao = JSON.parse(fs.readFileSync(caminhoDaTranscricao, "utf-8"));
|
||||
var plano = JSON.parse(document.getElementById("testarAcoesJson").value || "{}");
|
||||
var cortes = (plano.actions || []).filter(function (acao) { return acao.kind === "cut"; }).map(function (acao) { return { start: Number(acao.start), end: Number(acao.end) }; });
|
||||
var configuracao = carregarConfiguracaoDeLegendas();
|
||||
@@ -372,6 +376,16 @@ function gerarLegendasDaTranscricao() {
|
||||
} catch (erro) { document.getElementById("legendasStatus").textContent = "Não foi possível gerar: " + erro.message; }
|
||||
}
|
||||
|
||||
function obterCaminhoDaTranscricaoParaLegendas() {
|
||||
if (silenceState.transcriptPath && fs.existsSync(silenceState.transcriptPath)) return silenceState.transcriptPath;
|
||||
if (!silenceState.mediaPath) return null;
|
||||
var entradas = findCachedTranscripts(silenceState.mediaPath).sort(function (a, b) { return new Date(b.savedAt) - new Date(a.savedAt); });
|
||||
if (!entradas.length) return null;
|
||||
silenceState.transcriptPath = entradas[0].transcriptPath;
|
||||
silenceState.cachedTranscriptPath = entradas[0].transcriptPath;
|
||||
return silenceState.transcriptPath;
|
||||
}
|
||||
|
||||
function exportarLegendasSrt() {
|
||||
if (!legendasGeradas.length) { document.getElementById("legendasStatus").textContent = "Gere as legendas antes de exportar."; return; }
|
||||
var destino = path.join(silenceState.outputDir || os.tmpdir(), "legendas-geradas.srt");
|
||||
|
||||
Reference in New Issue
Block a user