Files

38 lines
1.3 KiB
Rust

//! Read-only native smoke: cargo run --locked --example anilist_probe
use std::io;
use tubular::{
anilist::{Client, catalog_count},
anime::Identity,
};
fn main() -> io::Result<()> {
let client = Client::default();
let results = client.search("Cowboy Bebop")?;
let media = results
.iter()
.find(|media| media["id"] == "1")
.ok_or_else(|| io::Error::other("Exact Cowboy Bebop AniList ID 1 absent from search"))?;
let id = media["id"]
.as_str()
.ok_or_else(|| io::Error::other("Missing catalog ID"))?;
let detail = client.detail(id)?;
let count = catalog_count(&detail)?.ok_or_else(|| io::Error::other("Catalog count unknown"))?;
if count == 0 {
return Err(io::Error::other("No catalog episode number 1"));
}
let identity = Identity::anilist(id.into(), 1)?;
println!(
"native search: {} records; exact AniList ID {id}",
results.len()
);
println!(
"detail: {count} catalog episode numbers; selected episode 1; source not checked by this probe"
);
println!("identity: {}", identity.key());
println!("watch URL: {}", identity.watch_url()?);
println!(
"PASS: native AniList search -> exact detail -> catalog episode -> stable sub URL (no source check or playback request)"
);
Ok(())
}