Added support for APE files

This commit is contained in:
Antoine Gersant 2020-09-24 01:46:29 -07:00
parent cf67e44d20
commit a7ef7b2bd0
3 changed files with 8 additions and 1 deletions

View file

@ -29,13 +29,14 @@ pub struct SongTags {
#[cfg_attr(feature = "profile-index", flame)]
pub fn read(path: &Path) -> Option<SongTags> {
let data = match utils::get_audio_format(path) {
Some(AudioFormat::APE) => Some(read_ape(path)),
Some(AudioFormat::FLAC) => Some(read_flac(path)),
Some(AudioFormat::MP3) => Some(read_id3(path)),
Some(AudioFormat::MP4) => Some(read_mp4(path)),
Some(AudioFormat::MPC) => Some(read_ape(path)),
Some(AudioFormat::OGG) => Some(read_vorbis(path)),
Some(AudioFormat::OPUS) => Some(read_opus(path)),
_ => None,
None => None,
};
match data {
Some(Ok(d)) => Some(d),
@ -311,4 +312,8 @@ fn test_read_metadata() {
read(Path::new("test-data/formats/sample.opus")).unwrap(),
sample_tags
);
assert_eq!(
read(Path::new("test-data/formats/sample.ape")).unwrap(),
sample_tags
);
}

View file

@ -37,6 +37,7 @@ pub fn get_data_root() -> Result<PathBuf> {
#[derive(Debug, PartialEq)]
pub enum AudioFormat {
APE,
FLAC,
MP3,
MP4,
@ -56,6 +57,7 @@ pub fn get_audio_format(path: &Path) -> Option<AudioFormat> {
_ => return None,
};
match extension.to_lowercase().as_str() {
"ape" => Some(AudioFormat::APE),
"flac" => Some(AudioFormat::FLAC),
"mp3" => Some(AudioFormat::MP3),
"m4a" => Some(AudioFormat::MP4),

Binary file not shown.