mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-14 00:17:07 +00:00
5eb032a3d4
This is not allowed [by spec](https://xiph.org/flac/format.html#def_VORBIS_COMMENT), but is still possible to encounter in the wild. Now we will just tag whichever tag happens to be latest in the stream and use it, they **will not be merged** like other formats (such as ID3v2 in MP3) where multiple tags are valid.
31 lines
873 B
Rust
31 lines
873 B
Rust
use lofty::flac::FlacFile;
|
|
use lofty::{Accessor, AudioFile, ParseOptions, ParsingMode};
|
|
|
|
use std::fs::File;
|
|
use std::io::Seek;
|
|
|
|
#[test]
|
|
fn multiple_vorbis_comments() {
|
|
let mut file = File::open("tests/files/assets/two_vorbis_comments.flac").unwrap();
|
|
|
|
// Reading a file with multiple VORBIS_COMMENT blocks should error when using `Strict`, as it is
|
|
// not allowed by spec.
|
|
assert!(FlacFile::read_from(
|
|
&mut file,
|
|
ParseOptions::new()
|
|
.read_properties(false)
|
|
.parsing_mode(ParsingMode::Strict)
|
|
)
|
|
.is_err());
|
|
|
|
file.rewind().unwrap();
|
|
|
|
// But by default, we should just take the last tag in the stream
|
|
let f = FlacFile::read_from(&mut file, ParseOptions::new().read_properties(false)).unwrap();
|
|
|
|
// The first tag has the artist "Artist 1", the second has "Artist 2".
|
|
assert_eq!(
|
|
f.vorbis_comments().unwrap().artist().as_deref(),
|
|
Some("Artist 2")
|
|
);
|
|
}
|