Fix edge-case where MPD omits album art format
This commit is contained in:
parent
7286de21bf
commit
bce9855743
4 changed files with 19 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/target
|
||||
/.idea
|
||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1668,7 +1668,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mpd_info_screen"
|
||||
version = "0.3.6"
|
||||
version = "0.3.7"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"freetype",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mpd_info_screen"
|
||||
version = "0.3.6"
|
||||
version = "0.3.7"
|
||||
edition = "2018"
|
||||
description = "Displays info on currently playing music from an MPD daemon"
|
||||
license = "MIT"
|
||||
|
|
|
@ -397,9 +397,22 @@ impl MPDDisplay {
|
|||
);
|
||||
}
|
||||
|
||||
let img_result = ImageReader::with_format(Cursor::new(&image_ref), image_format)
|
||||
let img_result = if is_unknown_format {
|
||||
let mut reader = ImageReader::new(Cursor::new(&image_ref));
|
||||
reader = reader
|
||||
.with_guessed_format()
|
||||
.map_err(|e| format!("Error: Failed to guess format of album art image: {}", e))?;
|
||||
reader.decode().map_err(|e| {
|
||||
format!(
|
||||
"Error: Failed to decode album art image (guessed format): {}",
|
||||
e
|
||||
)
|
||||
})
|
||||
} else {
|
||||
ImageReader::with_format(Cursor::new(&image_ref), image_format)
|
||||
.decode()
|
||||
.map_err(|e| format!("Error: Failed to decode album art image: {}", e));
|
||||
.map_err(|e| format!("Error: Failed to decode album art image: {}", e))
|
||||
};
|
||||
if img_result.is_err() && !self.tried_album_art_in_dir {
|
||||
return try_second_art_fetch_method(
|
||||
&mut self.tried_album_art_in_dir,
|
||||
|
|
Loading…
Reference in a new issue