Call readpicture when albumart doesnt return art
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Sijmen 2023-05-13 14:53:12 +02:00
parent 5e1faf887e
commit 751d19f4f3
Signed by: vijfhoek
GPG key ID: DAF7821E067D9C48

View file

@ -186,7 +186,19 @@ async fn post_queue_move(mut req: tide::Request<()>) -> tide::Result {
async fn get_art(req: tide::Request<()>) -> tide::Result { async fn get_art(req: tide::Request<()>) -> tide::Result {
let query: IndexQuery = req.query()?; let query: IndexQuery = req.query()?;
let path = percent_decode_str(&query.path).decode_utf8_lossy(); let path = percent_decode_str(&query.path).decode_utf8_lossy();
let resp = if let Ok(art) = mpd::connect()?.albumart(&path) {
let mut mpd = mpd::Mpd::connect().await?;
let resp = if let Ok(art) = mpd.albumart(&path).await {
let mime = infer::get(&art)
.map(|k| k.mime_type())
.unwrap_or("application/octet-stream");
tide::Response::builder(tide::StatusCode::Ok)
.body(art)
.content_type(mime)
.header("cache-control", "max-age=3600")
} else if let Ok(art) = mpd.readpicture(&path).await {
let mime = infer::get(&art) let mime = infer::get(&art)
.map(|k| k.mime_type()) .map(|k| k.mime_type())
.unwrap_or("application/octet-stream"); .unwrap_or("application/octet-stream");
@ -198,6 +210,7 @@ async fn get_art(req: tide::Request<()>) -> tide::Result {
} else { } else {
tide::Response::builder(tide::StatusCode::NotFound) tide::Response::builder(tide::StatusCode::NotFound)
}; };
Ok(resp.into()) Ok(resp.into())
} }