Added support for APE files
This commit is contained in:
parent
cf67e44d20
commit
a7ef7b2bd0
3 changed files with 8 additions and 1 deletions
|
@ -29,13 +29,14 @@ pub struct SongTags {
|
||||||
#[cfg_attr(feature = "profile-index", flame)]
|
#[cfg_attr(feature = "profile-index", flame)]
|
||||||
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::APE) => Some(read_ape(path)),
|
||||||
Some(AudioFormat::FLAC) => Some(read_flac(path)),
|
Some(AudioFormat::FLAC) => Some(read_flac(path)),
|
||||||
Some(AudioFormat::MP3) => Some(read_id3(path)),
|
Some(AudioFormat::MP3) => Some(read_id3(path)),
|
||||||
Some(AudioFormat::MP4) => Some(read_mp4(path)),
|
Some(AudioFormat::MP4) => Some(read_mp4(path)),
|
||||||
Some(AudioFormat::MPC) => Some(read_ape(path)),
|
Some(AudioFormat::MPC) => Some(read_ape(path)),
|
||||||
Some(AudioFormat::OGG) => Some(read_vorbis(path)),
|
Some(AudioFormat::OGG) => Some(read_vorbis(path)),
|
||||||
Some(AudioFormat::OPUS) => Some(read_opus(path)),
|
Some(AudioFormat::OPUS) => Some(read_opus(path)),
|
||||||
_ => None,
|
None => None,
|
||||||
};
|
};
|
||||||
match data {
|
match data {
|
||||||
Some(Ok(d)) => Some(d),
|
Some(Ok(d)) => Some(d),
|
||||||
|
@ -311,4 +312,8 @@ fn test_read_metadata() {
|
||||||
read(Path::new("test-data/formats/sample.opus")).unwrap(),
|
read(Path::new("test-data/formats/sample.opus")).unwrap(),
|
||||||
sample_tags
|
sample_tags
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
read(Path::new("test-data/formats/sample.ape")).unwrap(),
|
||||||
|
sample_tags
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ pub fn get_data_root() -> Result<PathBuf> {
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum AudioFormat {
|
pub enum AudioFormat {
|
||||||
|
APE,
|
||||||
FLAC,
|
FLAC,
|
||||||
MP3,
|
MP3,
|
||||||
MP4,
|
MP4,
|
||||||
|
@ -56,6 +57,7 @@ pub fn get_audio_format(path: &Path) -> Option<AudioFormat> {
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
match extension.to_lowercase().as_str() {
|
match extension.to_lowercase().as_str() {
|
||||||
|
"ape" => Some(AudioFormat::APE),
|
||||||
"flac" => Some(AudioFormat::FLAC),
|
"flac" => Some(AudioFormat::FLAC),
|
||||||
"mp3" => Some(AudioFormat::MP3),
|
"mp3" => Some(AudioFormat::MP3),
|
||||||
"m4a" => Some(AudioFormat::MP4),
|
"m4a" => Some(AudioFormat::MP4),
|
||||||
|
|
BIN
test-data/formats/sample.ape
Normal file
BIN
test-data/formats/sample.ape
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue