From 0f480a26c5a2651365829cdfc669fe78846c6ebb Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Fri, 6 Jan 2023 14:03:01 +0100 Subject: [PATCH] mp4: Map FlagCompilation to text "0"/"1" This is consistent with other tag types. --- src/mp4/ilst/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/mp4/ilst/mod.rs b/src/mp4/ilst/mod.rs index 5721ab06..621ff2f9 100644 --- a/src/mp4/ilst/mod.rs +++ b/src/mp4/ilst/mod.rs @@ -374,6 +374,10 @@ impl From for Tag { tag.pictures.push(pic); continue; }, + AtomData::Bool(b) => { + let text = if b { "1".to_owned() } else { "0".to_owned() }; + ItemValue::Text(text) + }, // We have to special case track/disc numbers since they are stored together AtomData::Unknown { code: 0, data } if data.len() >= 6 => { if let AtomIdent::Fourcc(ref fourcc) = ident { @@ -466,6 +470,22 @@ impl From for Ilst { ItemKey::TrackTotal => convert_to_uint(&mut tracks.1, data.as_str()), ItemKey::DiscNumber => convert_to_uint(&mut discs.0, data.as_str()), ItemKey::DiscTotal => convert_to_uint(&mut discs.1, data.as_str()), + ItemKey::FlagCompilation => { + if let Ok(num) = data.as_str().parse::() { + let data = match num { + 0 => false, + 1 => true, + _ => { + // Ignore all other, unexpected values + continue; + }, + }; + ilst.atoms.push(Atom { + ident: ident.into_owned(), + data: AtomDataStorage::Single(AtomData::Bool(data)), + }) + } + }, _ => ilst.atoms.push(Atom { ident: ident.into_owned(), data: AtomDataStorage::Single(AtomData::UTF8(data)),