tonhowtf/omniget · error

não consegui ler a legenda

Error message

não consegui ler a legenda: {}

What it means

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.

Solutions

  1. Verify the subtitle file exists and the path is correct
  2. Convert the subtitle to UTF-8 (e.g. `iconv -f latin1 -t utf-8 subs.srt`)
  3. Check file read permissions
  4. Re-export the subtitle from the source in UTF-8 .vtt/.srt format

Example fix

// before
let opts = Options { subtitle_path: "legenda.srt".into(), ..Default::default() };
// after
let path = "/abs/path/legenda_utf8.srt";
let bytes = std::fs::read(path)?; // fail early with clear error
String::from_utf8(bytes).expect("subtitle must be UTF-8");
let opts = Options { subtitle_path: path.into(), ..Default::default() };
Defensive patterns

Strategy: validation

Validate before calling

let text = std::fs::read_to_string(&opts.subtitle_path)
    .map_err(|e| anyhow!("legenda ilegível: {}", e))?;
debug_assert!(!text.trim().is_empty());

Try / catch

match run(opts, progress).await {
    Err(e) if e.to_string().starts_with("não consegui ler a legenda") => {
        eprintln!("confira o caminho/permissões/codificação UTF-8 da legenda");
    }
    other => other?,
}

Prevention

When it happens

Trigger: `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).

Common situations: 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.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/9950be1888b44d54. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/yt_notes.rs:466

pub async fn run(opts: Options, progress: super::ProgressFn) -> anyhow::Result<NotesResult> {
    let used_session = opts
        .session_netscape
        .as_ref()
        .map(|s| !s.trim().is_empty())
        .unwrap_or(false);
    let mut meta = VideoMeta {
        title: opts.title.clone(),
        url: opts.url.trim().to_string(),
        ..Default::default()
    };
    let source;
    let cues: Vec<Cue>;

    if !opts.subtitle_path.trim().is_empty() {
        super::report(&progress, ID, "progress", 1, Some(4), None);
        let text = std::fs::read_to_string(opts.subtitle_path.trim())
            .map_err(|e| anyhow!("não consegui ler a legenda: {}", e))?;
        cues = super::subtitle::parse(&text)?;
        source = "legenda-local".to_string();
        if !opts.url.trim().is_empty() {
            if let Ok(m) = fetch_meta(&opts).await {
                meta = merge_meta(meta, m);
            }
        }
    } else if !opts.url.trim().is_empty() {
        super::report(&progress, ID, "progress", 1, Some(4), None);
        meta = merge_meta(meta, fetch_meta(&opts).await?);
        super::report(&progress, ID, "progress", 2, Some(4), None);
        match fetch_subtitles(&opts).await {
            Ok(Some(text)) => {
                cues = super::subtitle::parse(&text)?;
                source = "legenda-youtube".to_string();
            }
            Ok(None) | Err(_) if opts.allow_whisper => {
                super::report(&progress, ID, "progress", 3, Some(4), None);

View on GitHub (pinned to 8600b91f42)