Skip to content

Commit

Permalink
Fallback to Illustation/Icon/OtherIcon when cover is not found
Browse files Browse the repository at this point in the history
Fix #826
  • Loading branch information
martpie committed Feb 17, 2025
1 parent ef10ace commit 8da936f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src-tauri/src/plugins/cover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::str::FromStr;
use base64::prelude::{Engine as _, BASE64_STANDARD};
use lofty::file::TaggedFileExt;
use lofty::picture::{MimeType, PictureType};
use log::info;
use tauri::plugin::{Builder, TauriPlugin};
use tauri::Runtime;

Expand All @@ -25,10 +26,11 @@ fn get_cover_from_id3(path: String) -> Option<String> {
None => return None,
};

let cover = match primary_tag.get_picture_type(PictureType::CoverFront) {
Some(cover) => cover,
None => return None,
};
let cover = primary_tag
.get_picture_type(PictureType::CoverFront)
.or_else(|| primary_tag.get_picture_type(PictureType::Illustration))
.or_else(|| primary_tag.get_picture_type(PictureType::Icon))
.or_else(|| primary_tag.get_picture_type(PictureType::OtherIcon))?;

let format = match cover.mime_type() {
Some(MimeType::Png) => "png".to_string(),
Expand Down

0 comments on commit 8da936f

Please sign in to comment.