From 77dc2eac23addea77eeb67faae9bf02cc7e51524 Mon Sep 17 00:00:00 2001 From: duydl <56506156+duydl@users.noreply.github.com> Date: Fri, 10 May 2024 09:59:45 +0700 Subject: [PATCH] Add support for m4b format (#208) * Add support for m4b * Formatting * Formatting --------- Co-authored-by: Antoine Gersant --- src/app/index/metadata.rs | 5 ++--- src/app/thumbnail.rs | 5 ++--- src/utils.rs | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/index/metadata.rs b/src/app/index/metadata.rs index ca3c273..5e6af88 100644 --- a/src/app/index/metadata.rs +++ b/src/app/index/metadata.rs @@ -86,14 +86,13 @@ impl From for SongTags { pub fn read(path: &Path) -> Option { let data = match utils::get_audio_format(path) { Some(AudioFormat::AIFF) => read_aiff(path), - Some(AudioFormat::APE) => read_ape(path), Some(AudioFormat::FLAC) => read_flac(path), Some(AudioFormat::MP3) => read_mp3(path), - Some(AudioFormat::MP4) => read_mp4(path), - Some(AudioFormat::MPC) => read_ape(path), Some(AudioFormat::OGG) => read_vorbis(path), Some(AudioFormat::OPUS) => read_opus(path), Some(AudioFormat::WAVE) => read_wave(path), + Some(AudioFormat::APE) | Some(AudioFormat::MPC) => read_ape(path), + Some(AudioFormat::MP4) | Some(AudioFormat::M4B) => read_mp4(path), None => return None, }; match data { diff --git a/src/app/thumbnail.rs b/src/app/thumbnail.rs index 06ea021..1be3bfa 100644 --- a/src/app/thumbnail.rs +++ b/src/app/thumbnail.rs @@ -149,14 +149,13 @@ fn generate_thumbnail(image_path: &Path, options: &Options) -> Result Result { match get_audio_format(image_path) { Some(AudioFormat::AIFF) => read_aiff(image_path), - Some(AudioFormat::APE) => read_ape(image_path), Some(AudioFormat::FLAC) => read_flac(image_path), Some(AudioFormat::MP3) => read_mp3(image_path), - Some(AudioFormat::MP4) => read_mp4(image_path), - Some(AudioFormat::MPC) => read_ape(image_path), Some(AudioFormat::OGG) => read_vorbis(image_path), Some(AudioFormat::OPUS) => read_opus(image_path), Some(AudioFormat::WAVE) => read_wave(image_path), + Some(AudioFormat::APE) | Some(AudioFormat::MPC) => read_ape(image_path), + Some(AudioFormat::MP4) | Some(AudioFormat::M4B) => read_mp4(image_path), None => image::open(image_path).map_err(|e| Error::Image(image_path.to_owned(), e)), } } diff --git a/src/utils.rs b/src/utils.rs index 57f5d6d..0a538d3 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -24,6 +24,7 @@ pub enum AudioFormat { OGG, OPUS, WAVE, + M4B, } pub fn get_audio_format(path: &Path) -> Option { @@ -46,6 +47,7 @@ pub fn get_audio_format(path: &Path) -> Option { "ogg" => Some(AudioFormat::OGG), "opus" => Some(AudioFormat::OPUS), "wav" => Some(AudioFormat::WAVE), + "m4b" => Some(AudioFormat::M4B), _ => None, } }