Without ItemKey::Unknown what is the best way to add custom fields now?
#572
-
|
In my metadata editor I had a generic function to help insert some custom fields in particular:
So for adding these in what is the best way previously I used this: /// Helper function to insert custom metadata fields
fn set_custom_field(tag: &mut Tag, field_name: &str, value: &str) {
let item_key = ItemKey::Unknown(field_name.to_string());
if value.is_empty() {
tag.remove_key(&item_key);
} else {
// Create a TagItem with the custom field
let tag_item = TagItem::new(item_key, ItemValue::Text(value.to_string()));
// Use insert_unchecked for custom fields
tag.insert_unchecked(tag_item);
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
There's no way to add custom fields without using the concrete formats like It also pushes users away from resorting to custom fields unless absolutely necessary. What I recommend instead is to make PRs for any As for |
Beta Was this translation helpful? Give feedback.
-
|
Thank you, I made a PR to get Out of curiosity, what do you plan |
Beta Was this translation helpful? Give feedback.
There's no way to add custom fields without using the concrete formats like
Id3v2Tag.ItemKey::Unknownwas kind of a nuisance since it required Lofty to do extra validation when merging tags. With it gone, everyItemKeyis now guaranteed to have well defined mappings.It also pushes users away from resorting to custom fields unless absolutely necessary.
What I recommend instead is to make PRs for any
ItemKeys that you may need. For example, release country is already a well defined field, it just doesn't have anItemKeymapping yet: https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#id30As for
TAGS, that'd probably be better suited for anItemKey::Keywords(which also doe…