Update mp4ameta

This commit is contained in:
Serial 2021-07-19 21:01:00 -04:00
parent 29abe33324
commit 134bef896a
2 changed files with 23 additions and 24 deletions

View file

@ -19,7 +19,7 @@ filepath = { version = "0.1.1", optional = true } # wav/aiff only supports paths
ogg_pager = { version = "0.1.6", optional = true }
unicase = { version = "2.6.0", optional = true }
# Mp4
mp4ameta = {version = "0.10.2", optional = true}
mp4ameta = {version = "0.11.0", optional = true}
# Flac
metaflac = {version = "0.2.4", optional = true}
# Errors

View file

@ -32,7 +32,8 @@ impl Mp4Tag {
#[allow(missing_docs, clippy::missing_errors_doc)]
pub fn remove_from(file: &mut File) -> Result<()> {
Ok(()) // TODO
Mp4InnerTag::default().write_to(file)?;
Ok(())
}
}
@ -177,26 +178,25 @@ impl AudioTagEdit for Mp4Tag {
fn front_cover(&self) -> Option<Picture> {
if let Some(picture) = &self.inner.artwork() {
return match picture {
mp4ameta::Data::Jpeg(d) => Some(Picture {
pic_type: PictureType::Other,
mime_type: MimeType::Jpeg,
description: None,
data: Cow::from(d.clone()),
}),
mp4ameta::Data::Png(d) => Some(Picture {
return match picture.fmt {
mp4ameta::ImgFmt::Png => Some(Picture {
pic_type: PictureType::Other,
mime_type: MimeType::Png,
description: None,
data: Cow::from(d.clone()),
data: Cow::from(picture.data.to_vec()),
}),
mp4ameta::Data::Bmp(d) => Some(Picture {
mp4ameta::ImgFmt::Jpeg => Some(Picture {
pic_type: PictureType::Other,
mime_type: MimeType::Jpeg,
description: None,
data: Cow::from(picture.data.to_vec()),
}),
mp4ameta::ImgFmt::Bmp => Some(Picture {
pic_type: PictureType::Other,
mime_type: MimeType::Bmp,
description: None,
data: Cow::from(d.clone()),
data: Cow::from(picture.data.to_vec()),
}),
_ => None,
};
}
@ -206,18 +206,18 @@ impl AudioTagEdit for Mp4Tag {
match cover.mime_type {
MimeType::Png => self
.inner
.add_artwork(mp4ameta::Data::Png(Vec::from(cover.data))),
.add_artwork(mp4ameta::Img::new(mp4ameta::ImgFmt::Png, cover.data)),
MimeType::Jpeg => self
.inner
.add_artwork(mp4ameta::Data::Jpeg(Vec::from(cover.data))),
.add_artwork(mp4ameta::Img::new(mp4ameta::ImgFmt::Jpeg, cover.data)),
MimeType::Bmp => self
.inner
.add_artwork(mp4ameta::Data::Bmp(Vec::from(cover.data))),
.add_artwork(mp4ameta::Img::new(mp4ameta::ImgFmt::Bmp, cover.data)),
_ => {},
}
}
fn remove_front_cover(&mut self) {
self.inner.remove_artwork();
self.inner.remove_artworks();
}
fn back_cover(&self) -> Option<Picture> {
@ -231,11 +231,10 @@ impl AudioTagEdit for Mp4Tag {
let mut pictures = Vec::new();
for art in self.inner.artworks() {
let info = match art {
mp4ameta::Data::Png(d) => Some((MimeType::Png, d.clone())),
mp4ameta::Data::Jpeg(d) => Some((MimeType::Jpeg, d.clone())),
mp4ameta::Data::Bmp(d) => Some((MimeType::Bmp, d.clone())),
_ => None,
let info = match art.fmt {
mp4ameta::ImgFmt::Png => Some((MimeType::Png, art.data.to_vec())),
mp4ameta::ImgFmt::Jpeg => Some((MimeType::Jpeg, art.data.to_vec())),
mp4ameta::ImgFmt::Bmp => Some((MimeType::Bmp, art.data.to_vec())),
};
if let Some((mime_type, data)) = info {
@ -258,7 +257,7 @@ impl AudioTagEdit for Mp4Tag {
}
}
fn remove_pictures(&mut self) {
self.inner.remove_artwork()
self.inner.remove_artworks()
}
fn track_number(&self) -> Option<u32> {