{"record":{"id":"4d527d76799c520c","repo":"tonhowtf/omniget","slug":"nenhuma-legenda-reconhecida-no-arquivo","errorCode":null,"errorMessage":"nenhuma legenda reconhecida no arquivo","messagePattern":"nenhuma legenda reconhecida no arquivo","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/subtitle.rs","lineNumber":166,"sourceCode":"            }\n        }\n    }\n    cues\n}\n\n/// Descobre o formato pelo conteúdo, não pela extensão — arquivo de legenda\n/// vem com o nome errado o tempo todo.\npub fn parse(text: &str) -> anyhow::Result<Vec<Cue>> {\n    let head = text.trim_start_matches('\\u{feff}');\n    let cues = if head.contains(\"[Script Info]\") || head.contains(\"Dialogue:\") {\n        parse_ass(head)\n    } else if head.contains(\"-->\") {\n        parse_timed_blocks(head, \"-->\")\n    } else {\n        Vec::new()\n    };\n    if cues.is_empty() {\n        return Err(anyhow!(\"nenhuma legenda reconhecida no arquivo\"));\n    }\n    Ok(cues)\n}\n\n// ── Escrita ────────────────────────────────────────────────────────────\n\npub fn to_srt(cues: &[Cue]) -> String {\n    let mut out = String::new();\n    for (i, c) in cues.iter().enumerate() {\n        out.push_str(&format!(\n            \"{}\\n{} --> {}\\n{}\\n\\n\",\n            i + 1,\n            fmt_srt_time(c.start_ms),\n            fmt_srt_time(c.end_ms),\n            c.text\n        ));\n    }\n    out","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/subtitle.rs#L148-L184","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let head = std::fs::read_to_string(path)?;\nlet looks_like_subtitle = head.contains(\"-->\") || head.contains(\"WEBVTT\") || head.contains(\"[Script Info]\");\nif !looks_like_subtitle { return Err(format!(\"{} is not an SRT/VTT/ASS subtitle\", path.display())); }","typeGuard":"fn is_subtitle_file(bytes: &[u8]) -> bool {\n    let head = String::from_utf8_lossy(&bytes[..bytes.len().min(2048)]);\n    head.contains(\"-->\") || head.contains(\"WEBVTT\") || head.contains(\"[Script Info]\")\n}","tryCatchPattern":"match subtitle::parse(text) {\n    Ok(cues) if !cues.is_empty() => { /* use cues */ }\n    Err(e) => { tracing::warn!(\"subtitle parse failed: {e}\"); /* ask user for SRT/VTT/ASS */ }\n}","preventionTips":["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"],"tags":["subtitle","parsing","srt","vtt","empty-input"],"backgroundTag":"unsupported-source-format","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}