Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/ogg/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,4 +645,22 @@ mod tests {
assert_eq!(tag.pictures().len(), 1);
assert!(tag.items.is_empty());
}

#[test]
fn initial_key_roundtrip() {
// Both the primary and alternate key should be mapped to the primary
// key if stored again. Note: The outcome is undefined if both the
// primary and alternate key would be stored redundantly in VorbisComments!
for key in ["INITIALKEY", "KEY"] {
let mut vorbis_comments = VorbisComments {
items: vec![(key.to_owned(), "Cmaj".to_owned())],
..Default::default()
};
let mut tag = Tag::try_from(vorbis_comments).unwrap();
assert_eq!(Some("Cmaj"), tag.get_string(&ItemKey::InitialKey));
tag.insert_text(ItemKey::InitialKey, "Cmin".to_owned());
vorbis_comments = tag.into();
assert_eq!(Some("Cmin"), vorbis_comments.get("INITIALKEY"));
}
}
}
5 changes: 5 additions & 0 deletions src/tag/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ gen_map!(
"COLOR" => Color,
"MOOD" => Mood,
"BPM" => BPM,
// MusicBrainz Picard suggests "KEY" (VirtualDJ, Denon Engine DJ), but "INITIALKEY"
// seems to be more common (Rekordbox, Serato DJ, Traktor DJ, Mixxx).
// <https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#initial-key>
// <https://github.com/beetbox/beets/issues/637#issuecomment-39528023>
"INITIALKEY" | "KEY" => InitialKey,
"COPYRIGHT" => CopyrightMessage,
"LICENSE" => License,
"COMMENT" => Comment,
Expand Down