Call readpicture when albumart doesnt return art
continuous-integration/drone/push Build is passing Details

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
1 changed files with 14 additions and 1 deletions

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 {
let query: IndexQuery = req.query()?;
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)
.map(|k| k.mime_type())
.unwrap_or("application/octet-stream");
@ -198,6 +210,7 @@ async fn get_art(req: tide::Request<()>) -> tide::Result {
} else {
tide::Response::builder(tide::StatusCode::NotFound)
};
Ok(resp.into())
}