{"record":{"id":"9950be1888b44d54","repo":"tonhowtf/omniget","slug":"n-o-consegui-ler-a-legenda","errorCode":null,"errorMessage":"não consegui ler a legenda: {}","messagePattern":"não consegui ler a legenda: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/yt_notes.rs","lineNumber":466,"sourceCode":"\npub async fn run(opts: Options, progress: super::ProgressFn) -> anyhow::Result<NotesResult> {\n    let used_session = opts\n        .session_netscape\n        .as_ref()\n        .map(|s| !s.trim().is_empty())\n        .unwrap_or(false);\n    let mut meta = VideoMeta {\n        title: opts.title.clone(),\n        url: opts.url.trim().to_string(),\n        ..Default::default()\n    };\n    let source;\n    let cues: Vec<Cue>;\n\n    if !opts.subtitle_path.trim().is_empty() {\n        super::report(&progress, ID, \"progress\", 1, Some(4), None);\n        let text = std::fs::read_to_string(opts.subtitle_path.trim())\n            .map_err(|e| anyhow!(\"não consegui ler a legenda: {}\", e))?;\n        cues = super::subtitle::parse(&text)?;\n        source = \"legenda-local\".to_string();\n        if !opts.url.trim().is_empty() {\n            if let Ok(m) = fetch_meta(&opts).await {\n                meta = merge_meta(meta, m);\n            }\n        }\n    } else if !opts.url.trim().is_empty() {\n        super::report(&progress, ID, \"progress\", 1, Some(4), None);\n        meta = merge_meta(meta, fetch_meta(&opts).await?);\n        super::report(&progress, ID, \"progress\", 2, Some(4), None);\n        match fetch_subtitles(&opts).await {\n            Ok(Some(text)) => {\n                cues = super::subtitle::parse(&text)?;\n                source = \"legenda-youtube\".to_string();\n            }\n            Ok(None) | Err(_) if opts.allow_whisper => {\n                super::report(&progress, ID, \"progress\", 3, Some(4), None);","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/yt_notes.rs#L448-L484","documentation":"The local subtitle file specified in opts.subtitle_path could not be read from disk; the io::Error from std::fs::read_to_string is wrapped into this message. The notes tool needs the subtitle text to extract cues and build markdown.","triggerScenarios":"`run` sees a non-empty opts.subtitle_path and calls read_to_string on it; the file is missing, unreadable (permissions), or not valid UTF-8 (read_to_string fails on invalid UTF-8).","commonSituations":"Subtitle path typo; .srt with non-UTF-8 encoding (e.g. Latin-1); file deleted between selection and run; no read permission; path with unusual characters mishandled upstream.","solutions":["Verify the subtitle file exists and the path is correct","Convert the subtitle to UTF-8 (e.g. `iconv -f latin1 -t utf-8 subs.srt`)","Check file read permissions","Re-export the subtitle from the source in UTF-8 .vtt/.srt format"],"exampleFix":"// before\nlet opts = Options { subtitle_path: \"legenda.srt\".into(), ..Default::default() };\n// after\nlet path = \"/abs/path/legenda_utf8.srt\";\nlet bytes = std::fs::read(path)?; // fail early with clear error\nString::from_utf8(bytes).expect(\"subtitle must be UTF-8\");\nlet opts = Options { subtitle_path: path.into(), ..Default::default() };","handlingStrategy":"validation","validationCode":"let text = std::fs::read_to_string(&opts.subtitle_path)\n    .map_err(|e| anyhow!(\"legenda ilegível: {}\", e))?;\ndebug_assert!(!text.trim().is_empty());","typeGuard":null,"tryCatchPattern":"match run(opts, progress).await {\n    Err(e) if e.to_string().starts_with(\"não consegui ler a legenda\") => {\n        eprintln!(\"confira o caminho/permissões/codificação UTF-8 da legenda\");\n    }\n    other => other?,\n}","preventionTips":["Store subtitles as UTF-8 (.vtt/.srt)","Resolve and check paths right after user selection","Add read permission checks in setup"],"tags":["rust","file-io","subtitles","utf-8"],"backgroundTag":"file-read-failed","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"}