Call readpicture when albumart doesnt return art
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5e1faf887e
commit
751d19f4f3
1 changed files with 14 additions and 1 deletions
15
src/main.rs
15
src/main.rs
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue