Cargo fix & format

This commit is contained in:
Frieder Hannenheim 2023-07-04 18:53:22 +02:00 committed by Alex
parent f191df4e53
commit f3841a37eb
2 changed files with 18 additions and 15 deletions

View file

@ -33,8 +33,8 @@ fn verify_frame(frame: &FrameRef<'_>) -> Result<()> {
| (_, FrameValue::Binary(_))
| ("UFID", FrameValue::UniqueFileIdentifier(_))
| ("POPM", FrameValue::Popularimeter(_))
| ("TIPL" | "TMCL", FrameValue::KeyValue { .. })
| ("WFED" | "GRP1" | "MVNM" | "MVIN", FrameValue::Text { .. }) => Ok(()),
| (("TIPL" | "TMCL"), FrameValue::KeyValue { .. }) => Ok(()),
(id, FrameValue::Text { .. }) if id.starts_with('T') => Ok(()),
(id, FrameValue::Url(_)) if id.starts_with('W') => Ok(()),
(id, frame_value) => Err(Id3v2Error::new(Id3v2ErrorKind::BadFrame(

View file

@ -1,10 +1,12 @@
use crate::{set_artist, temp_file, verify_artist};
use byteorder::ReadBytesExt;
use lofty::id3::v2::{Frame, FrameFlags, FrameValue, Id3v2Tag, KeyValueFrame};
use lofty::mpeg::MpegFile;
use lofty::{
Accessor, FileType, ItemKey, ItemValue, ParseOptions, Probe, Tag, TagExt, TagItem, TagType,
TaggedFileExt, id3::v2::{Id3v2Tag, Frame, FrameValue, KeyValueFrame, FrameFlags}, mpeg::MpegFile, AudioFile,
Accessor, AudioFile, FileType, ItemKey, ItemValue, ParseOptions, Probe, Tag, TagExt, TagItem,
TagType, TaggedFileExt,
};
use std::{io::{Seek, Write, Read}, fs::File};
use std::io::{Seek, Write};
#[test]
fn read() {
@ -311,25 +313,26 @@ fn remove_ape() {
#[test]
fn read_and_write_tpil_frame() {
let key_value_pairs = vec![
("engineer".to_string(), "testperson".to_string()),
("vocalist".to_string(), "testhuman".to_string())
];
("engineer".to_string(), "testperson".to_string()),
("vocalist".to_string(), "testhuman".to_string()),
];
let mut file = temp_file!("tests/files/assets/minimal/full_test.mp3");
let mut mpeg_file = MpegFile::read_from(&mut file, ParseOptions::new()).unwrap();
let tag: &mut Id3v2Tag = mpeg_file.id3v2_mut().unwrap();
tag.insert(
Frame::new(
"TIPL",
"TIPL",
KeyValueFrame {
encoding: lofty::TextEncoding::UTF8,
key_value_pairs: key_value_pairs.clone()
key_value_pairs: key_value_pairs.clone(),
},
FrameFlags::default()
).unwrap()
FrameFlags::default(),
)
.unwrap(),
);
file.rewind().unwrap();
@ -343,8 +346,8 @@ fn read_and_write_tpil_frame() {
let content = match tag.get("TIPL").unwrap().content() {
FrameValue::KeyValue(content) => content,
_ => panic!("Wrong Frame Value Type for TIPL")
_ => panic!("Wrong Frame Value Type for TIPL"),
};
assert_eq!(key_value_pairs, content.key_value_pairs);
}
}