Skip to content

fix: Parsing IQDB correctly#9

Merged
lyssieth merged 3 commits intolyssieth:masterfrom
Nachtalb:fix/iqdb
Oct 20, 2025
Merged

fix: Parsing IQDB correctly#9
lyssieth merged 3 commits intolyssieth:masterfrom
Nachtalb:fix/iqdb

Conversation

@Nachtalb
Copy link
Contributor

Fixes IQDB result parsing as well as simplify it.

[package]
name = "iqdbtest"
version = "0.1.0"
edition = "2024"

[dependencies]
sauce-api = { version = "1.2.0", path = "../../github.com/lyssieth/sauce-api", features = [
  "iqdb",
  "rustls",
] }
tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread"] }
use sauce_api::error::Error;
use sauce_api::source::{Output, Source, iqdb::Iqdb};

async fn find_source(url: &str) {
    let source = Iqdb::create(()).await.unwrap();
    let res: Result<Output, Error> = source.check(url).await; // Can take some time as IQDB is a bit slow.

    match res {
        Ok(result) => {
            println!("Found results! {:?}", result);
        }
        Err(e) => {
            eprintln!("Unable to find results: {}", e);
        }
    }
}

#[tokio::main]
async fn main() {
    find_source("https://cdn.donmai.us/original/ed/1e/ed1e6e777cf15e42b05f9accf4b28e8c.jpg").await;
}

Returns:
Found results! Output { original_url: "https://cdn.donmai.us/original/ed/1e/ed1e6e777cf15e42b05f9accf4b28e8c.jpg", items: [Item { link: "https://danbooru.donmai.us/posts/9213656", similarity: 0.95 }, Item { link: "https://danbooru.donmai.us/posts/7756900", similarity: 0.61 }, Item { link: "https://danbooru.donmai.us/posts/10077559", similarity: 0.49 }] }

IQDB always shows results in the same order: uploaded image, best,
others. Thus we can just iterate over all results excluding the uploaded
one and we have our final list.
Rather than reiterating over all results again
@lyssieth lyssieth self-assigned this Oct 20, 2025
Copy link
Owner

@lyssieth lyssieth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane to me; will merge in a bit.

@lyssieth lyssieth merged commit bc8033e into lyssieth:master Oct 20, 2025
2 of 4 checks passed
@Nachtalb Nachtalb deleted the fix/iqdb branch October 20, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants