tonhowtf/omniget · error · anyhow::Error
nenhuma legenda reconhecida no arquivo
Error message
nenhuma legenda reconhecida no arquivo
What it means
subtitle::parse sniffs the file header to decide between SRT/ASS (-->) or VTT style timed blocks; if the resulting cue list is empty it throws "nenhuma legenda reconhecida no arquivo" (no recognized subtitles in the file). It means the file is not a supported subtitle format or contains no timed cues.
Solutions
- Verify the file is a real SRT/VTT/ASS subtitle (open it and check for '-->' or '[Script Info]')
- Check for encoding/BOM issues and re-save as UTF-8 without BOM
- Re-download or re-export the subtitle in SRT/VTT/ASS
- Confirm the correct file path was passed — not an empty placeholder
Defensive patterns
Strategy: validation
Validate before calling
let head = std::fs::read_to_string(path)?;
let looks_like_subtitle = head.contains("-->") || head.contains("WEBVTT") || head.contains("[Script Info]");
if !looks_like_subtitle { return Err(format!("{} is not an SRT/VTT/ASS subtitle", path.display())); } Type guard
fn is_subtitle_file(bytes: &[u8]) -> bool {
let head = String::from_utf8_lossy(&bytes[..bytes.len().min(2048)]);
head.contains("-->") || head.contains("WEBVTT") || head.contains("[Script Info]")
} Try / catch
match subtitle::parse(text) {
Ok(cues) if !cues.is_empty() => { /* use cues */ }
Err(e) => { tracing::warn!("subtitle parse failed: {e}"); /* ask user for SRT/VTT/ASS */ }
} Prevention
- Only accept .srt/.vtt/.ass files from the file picker
- Sniff the header for '-->' or 'WEBVTT' before parsing
- Re-encode files to UTF-8 without BOM
- Reject zero-byte files early
When it happens
Trigger: Calling parse (directly or via convert_one/shift, or the tests reading SRT/VTT/ASS) with a file whose header lacks '-->' and WEBVTT markers, or a valid-format file that yields zero cues (empty file, only comments/headers, wrong extension pointing at a non-subtitle file).
Common situations: Pointing the tool at a plain .txt, a binary file, a nulled/corrupted subtitle, an empty download, or an unsupported format (e.g. MicroDVD .sub, SAMI .smi); file saved with BOM/encoding that breaks header sniffing.
Related errors
- a legenda nao tem falas
- a saída do gallery-dl não é um dump JSON válido
- animacao do X nao encontrada na pagina
- cole o link do vídeo do Bilibili
- cor inválida
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/4d527d76799c520c.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/subtitle.rs:166
}
}
}
cues
}
/// Descobre o formato pelo conteúdo, não pela extensão — arquivo de legenda
/// vem com o nome errado o tempo todo.
pub fn parse(text: &str) -> anyhow::Result<Vec<Cue>> {
let head = text.trim_start_matches('\u{feff}');
let cues = if head.contains("[Script Info]") || head.contains("Dialogue:") {
parse_ass(head)
} else if head.contains("-->") {
parse_timed_blocks(head, "-->")
} else {
Vec::new()
};
if cues.is_empty() {
return Err(anyhow!("nenhuma legenda reconhecida no arquivo"));
}
Ok(cues)
}
// ── Escrita ────────────────────────────────────────────────────────────
pub fn to_srt(cues: &[Cue]) -> String {
let mut out = String::new();
for (i, c) in cues.iter().enumerate() {
out.push_str(&format!(
"{}\n{} --> {}\n{}\n\n",
i + 1,
fmt_srt_time(c.start_ms),
fmt_srt_time(c.end_ms),
c.text
));
}
outView on GitHub (pinned to 8600b91f42)