This commit is contained in:
Antoine Gersant 2024-07-10 23:17:41 -07:00
commit 138eacc9fc
3 changed files with 6 additions and 6 deletions

View file

@ -86,14 +86,13 @@ impl From<id3::Tag> for SongTags {
pub fn read(path: &Path) -> Option<SongTags> { pub fn read(path: &Path) -> Option<SongTags> {
let data = match utils::get_audio_format(path) { let data = match utils::get_audio_format(path) {
Some(AudioFormat::AIFF) => read_aiff(path), Some(AudioFormat::AIFF) => read_aiff(path),
Some(AudioFormat::APE) => read_ape(path),
Some(AudioFormat::FLAC) => read_flac(path), Some(AudioFormat::FLAC) => read_flac(path),
Some(AudioFormat::MP3) => read_mp3(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::OGG) => read_vorbis(path),
Some(AudioFormat::OPUS) => read_opus(path), Some(AudioFormat::OPUS) => read_opus(path),
Some(AudioFormat::WAVE) => read_wave(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, None => return None,
}; };
match data { match data {

View file

@ -149,14 +149,13 @@ fn generate_thumbnail(image_path: &Path, options: &Options) -> Result<DynamicIma
fn read(image_path: &Path) -> Result<DynamicImage, Error> { fn read(image_path: &Path) -> Result<DynamicImage, Error> {
match get_audio_format(image_path) { match get_audio_format(image_path) {
Some(AudioFormat::AIFF) => read_aiff(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::FLAC) => read_flac(image_path),
Some(AudioFormat::MP3) => read_mp3(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::OGG) => read_vorbis(image_path),
Some(AudioFormat::OPUS) => read_opus(image_path), Some(AudioFormat::OPUS) => read_opus(image_path),
Some(AudioFormat::WAVE) => read_wave(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)), None => image::open(image_path).map_err(|e| Error::Image(image_path.to_owned(), e)),
} }
} }

View file

@ -24,6 +24,7 @@ pub enum AudioFormat {
OGG, OGG,
OPUS, OPUS,
WAVE, WAVE,
M4B,
} }
pub fn get_audio_format(path: &Path) -> Option<AudioFormat> { pub fn get_audio_format(path: &Path) -> Option<AudioFormat> {
@ -46,6 +47,7 @@ pub fn get_audio_format(path: &Path) -> Option<AudioFormat> {
"ogg" => Some(AudioFormat::OGG), "ogg" => Some(AudioFormat::OGG),
"opus" => Some(AudioFormat::OPUS), "opus" => Some(AudioFormat::OPUS),
"wav" => Some(AudioFormat::WAVE), "wav" => Some(AudioFormat::WAVE),
"m4b" => Some(AudioFormat::M4B),
_ => None, _ => None,
} }
} }