tonhowtf/omniget · error

Could not extract pin ID

Error message

Could not extract pin ID

What it means

native_get_media_info canonicalizes the pin URL then extracts the numeric pin ID from it. If extract_pin_id cannot find an ID in the canonical URL, this error is thrown. It means the URL is not (or no longer looks like) a valid pin permalink.

Solutions

  1. Log the canonical URL when this fires and update extract_pin_id's regex for Pinterest's current URL format.
  2. Validate the input is a pin URL (/pin/<digits>) before calling get_media_info and give early feedback.
  3. Check what resolve_pin_url returned — a login-wall or 404 redirect indicates the pin is gone, not a parser bug.
  4. Handle pinterest.com/pin/... and pin.it/... variants explicitly in resolve_pin_url.

Example fix

// before
let pin_id = Self::extract_pin_id(&canonical)
    .ok_or_else(|| anyhow!("Could not extract pin ID"))?;
// after
let pin_id = Self::extract_pin_id(&canonical).ok_or_else(|| {
    anyhow!("Could not extract pin ID from canonical URL: {} (is this a pin permalink?)", canonical)
})?;
Defensive patterns

Strategy: validation

Validate before calling

// Rust: validate the pin URL before calling get_media_info
let re = regex::Regex::new(r"pinterest\.[a-z.]+/pin/(\d+)").unwrap();
if !re.is_match(url) && !url.starts_with("https://pin.it/") {
    return Err(anyhow!("not a pin permalink: {}", url));
}

Type guard

// Rust
fn pin_id_of(url: &str) -> Option<String> {
    regex::Regex::new(r"/pin/(\d+)")
        .ok()?
        .captures(url)
        .and_then(|c| c.get(1))
        .map(|m| m.as_str().to_string())
}

Try / catch

match get_media_info(url).await {
    Err(e) if e.to_string().contains("Could not extract pin ID") => {
        eprintln!("Provide a direct pin permalink (pinterest.com/pin/<id>)");
    }
    other => other?,
}

Prevention

When it happens

Trigger: native_get_media_info(url) -> resolve_pin_url returns a canonical URL that extract_pin_id cannot parse — the URL is a profile/board/user page, a shortened/malformed link, or Pinterest redirected to a non-pin page (deleted pin, login wall).

Common situations: User pastes a board or profile URL instead of a pin URL; pin.pinterest.com short links redirect unexpectedly; Pinterest changes URL structure (/pin/<id>/ pattern altered); resolve_pin_url follows a redirect to an error/login page.

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/705b8db98458d503. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/platforms/pinterest/mod.rs:271

            file_size_bytes: total_bytes,
            duration_seconds: 0.0,
            torrent_id: None,
        })
    }
}

impl PinterestDownloader {
    async fn fallback_ytdlp(&self, url: &str) -> anyhow::Result<MediaInfo> {
        let ytdlp_path = crate::core::ytdlp::ensure_ytdlp().await?;
        let json = crate::core::ytdlp::get_video_info(&ytdlp_path, url, &[]).await?;
        crate::platforms::generic_ytdlp::GenericYtdlpDownloader::parse_video_info(&json)
    }

    async fn native_get_media_info(&self, url: &str) -> anyhow::Result<MediaInfo> {
        let canonical = self.resolve_pin_url(url).await?;

        let pin_id =
            Self::extract_pin_id(&canonical).ok_or_else(|| anyhow!("Could not extract pin ID"))?;

        let html = self.fetch_pin_html(&pin_id).await?;

        if Self::check_pin_not_found(&html) {
            return Err(anyhow!("Pin not found"));
        }

        if let Some(video_url) = Self::extract_video_url(&html) {
            return Ok(MediaInfo {
                title: format!("pinterest_{}", pin_id),
                author: String::new(),
                platform: "pinterest".to_string(),
                duration_seconds: None,
                thumbnail_url: None,
                available_qualities: vec![VideoQuality {
                    label: "original".to_string(),
                    width: 0,
                    height: 0,

View on GitHub (pinned to 8600b91f42)