Files
timbre/src/coverartarchive.rs
2026-08-24 16:46:42 -04:00

20 lines
594 B
Rust

use std::io::Read;
pub fn fetch_cover_art(release_id: &str) -> Option<Vec<u8>> {
let url = format!("https://coverartarchive.org/release/{}/front", release_id);
let response = ureq::get(&url)
.header("User-Agent", "Timbre/0.1 ( ...your repo... )")
.call();
match response {
Ok(resp) => {
let mut bytes = Vec::new();
resp.into_body()
.into_reader()
.read_to_end(&mut bytes)
.expect("i couldn't read the cover art :(\n");
Some(bytes)
}
Err(_) => None,
}
}