tonhowtf/omniget · error

nao reconheci um video do YouTube em

Error message

nao reconheci um video do YouTube em: {}

What it means

Thrown by `sponsorblock::segments` when `video_id(input)` fails to extract a YouTube video ID from the user-supplied input. The function accepts a URL or raw ID, and this error reports any input it cannot parse into an 11-character video ID.

Solutions

  1. Pass a standard watch URL (https://www.youtube.com/watch?v=VIDEO_ID), a youtu.be/VIDEO_ID link, or the bare 11-character video ID.
  2. Strip whitespace and quotes from the input before calling.
  3. Extract the `v` parameter yourself and pass only the ID.
  4. If a new URL shape (e.g. live or shorts links) must be supported, extend the `video_id` regex.

Example fix

// before
segments("https://youtube.com/playlist?list=PL123", &cats).await?;
// after
segments("https://www.youtube.com/watch?v=dQw4w9WgXcQ", &cats).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn looks_like_video_id(s: &str) -> bool {
    let s = s.trim();
    s.len() == 11 && s.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
}

Type guard

fn is_youtube_id(s: &str) -> Option<&str> {
    let s = s.trim();
    (s.len() == 11 && !s.contains('/')).then_some(s)
}

Prevention

When it happens

Trigger: Calling `segments(input, categories)` with a non-YouTube URL, a youtu.be link with extra/missing path parts, a URL-encoded or embed URL variant the regex does not match, or a typo'd/empty string.

Common situations: Pasting a YouTube channel or playlist link instead of a video; mobile m.youtube.com share links with unusual query strings; passing an already-trimmed ID with whitespace or surrounding quotes; Vimeo/other platform links.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/sponsorblock.rs:68

/// Aceita URL completa, `youtu.be/ID`, `shorts/ID` ou o próprio ID.
pub fn video_id(input: &str) -> Option<String> {
    let s = input.trim();
    if s.len() == 11
        && s.chars()
            .all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
    {
        return Some(s.to_string());
    }
    let re =
        regex::Regex::new(r"(?:v=|youtu\.be/|shorts/|embed/|live/)([A-Za-z0-9_-]{11})").ok()?;
    re.captures(s)
        .and_then(|c| c.get(1))
        .map(|m| m.as_str().to_string())
}

pub async fn segments(input: &str, categories: &[String]) -> anyhow::Result<SponsorResult> {
    let id = video_id(input)
        .ok_or_else(|| anyhow!("nao reconheci um video do YouTube em: {}", input))?;
    let cats: Vec<&str> = if categories.is_empty() {
        CATEGORIES.to_vec()
    } else {
        categories.iter().map(|s| s.as_str()).collect()
    };
    let mut h = Sha256::new();
    h.update(id.as_bytes());
    let prefix = &hex::encode(h.finalize())[..4];
    let url = format!(
        "{}/api/skipSegments/{}?categories={}&actionTypes={}",
        SERVER,
        prefix,
        urlencoding::encode(&serde_json::to_string(&cats)?),
        urlencoding::encode(r#"["skip","mute","full","poi","chapter"]"#)
    );
    let client = super::client()?;
    let resp = client.get(&url).send().await?;
    let mut segs: Vec<Segment> = Vec::new();

View on GitHub (pinned to 8600b91f42)