add m4a support via mp4ameta crate

This commit is contained in:
Ray 2020-06-16 08:06:27 -04:00
parent e9346e29ee
commit 7637037e3d
3 changed files with 11 additions and 10 deletions

6
Cargo.lock generated
View file

@ -1204,7 +1204,7 @@ dependencies = [
[[package]] [[package]]
name = "mp4ameta" name = "mp4ameta"
version = "0.2.0" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1485,7 +1485,7 @@ dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"metaflac 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "metaflac 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"mp3-duration 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "mp3-duration 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"mp4ameta 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "mp4ameta 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2948,7 +2948,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" "checksum mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19"
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
"checksum mp3-duration 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "eda61ba6c266cd2c7bfcea9a2719837dc062869e24e101a93c1b0873d17c2d35" "checksum mp3-duration 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "eda61ba6c266cd2c7bfcea9a2719837dc062869e24e101a93c1b0873d17c2d35"
"checksum mp4ameta 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3538f327d5d3afbc25b3677f5bd1e917ae7e9d3eae2aa9c3b57bc77f0356e829" "checksum mp4ameta 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0c1c3784b35bb34f94341fd1e2bf9a2c66fc40804464a155b06b3cd71f8d623e"
"checksum native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" "checksum native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d"
"checksum net2 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" "checksum net2 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7"
"checksum notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" "checksum notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd"

View file

@ -28,7 +28,7 @@ lewton = "0.10.1"
log = "0.4.5" log = "0.4.5"
metaflac = "0.2.3" metaflac = "0.2.3"
mp3-duration = "0.1.9" mp3-duration = "0.1.9"
mp4ameta = "0.2.0" mp4ameta = "0.2.1"
pbkdf2 = "0.3" pbkdf2 = "0.3"
rand = "0.7" rand = "0.7"
rayon = "1.3" rayon = "1.3"

View file

@ -218,14 +218,15 @@ fn read_mp4(path: &Path) -> Result<SongTags> {
track_number: None, track_number: None,
year: None, year: None,
}; };
tags.artist = Some(tag.artist().unwrap().to_string()); tags.artist = tag.artist().map(|v| v.to_string());
tags.album_artist = Some(tag.album_artist().unwrap().to_string()); tags.album_artist = tag.album_artist().map(|v| v.to_string());
tags.album = Some(tag.album().unwrap().to_string()); tags.album = tag.album().map(|v| v.to_string());
tags.title = Some(tag.title().unwrap().to_string()); tags.title = tag.title().map(|v| v.to_string());
tags.duration = Some(tag.duration().unwrap() as u32); tags.duration = tag.duration().map(|v| v as u32);
tags.disc_number = tag.disk_number().0.and_then(|d| Some(d as u32)); tags.disc_number = tag.disk_number().0.and_then(|d| Some(d as u32));
tags.track_number = tag.track_number().0.and_then(|d| Some(d as u32)); tags.track_number = tag.track_number().0.and_then(|d| Some(d as u32));
tags.year = tag.year().unwrap().parse::<i32>().ok(); let year = tag.year().and_then(|v| Some(v.parse::<i32>().ok()));
tags.year = match year { None => None, Some(year) => year};
Ok(tags) Ok(tags)
} }