-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When Writing to a File That Uses Id3v2 Using Tag, It Erases All Items that Have Multiple Values #507
Comments
Thanks for all the details. I haven't looked into it yet, but some observations:
For multi-value items, you should make a new for genre in genre.split(", ") {
tag.push(TagItem::new(
ItemKey::Genre,
ItemValue::Text(genre.to_string())
));
} When merging a lofty-rs/lofty/src/id3/v2/tag.rs Lines 1267 to 1270 in 7f55f81
Every concrete tag type implements let tag = match tagged_file.primary_tag() {
Some(tag) => tag,
None => return Err("No tag found".to_string()),
};
// ...
if tag.tag_type() == TagType::Id3v2 {
let id3_tag: Id3v2Tag = tag.into();
id3_tag.save_to_path(/* ... */)?;
} else {
tag.save_to_path(/* ... */)?;
} Not sure if the workaround applies here or not, I'll have to look into it.
That's weird. All of the MusicBrainz tags use the same logic, so if one disappears then they all should. |
Thank you for the quick reply! I tried your suggestions, specifically the converting the tag to a
However It still makes every MusicBrainz tag into a singular value. I generated the test result with the I'll create more results with different files with Id3v2Original
Written using lofty
|
Ah, so for the MusicBrainz keys, they were just never added here: lofty-rs/lofty/src/id3/v2/tag.rs Lines 1404 to 1409 in 7f55f81
So what ends up happening is they fall through to this: lofty-rs/lofty/src/id3/v2/tag.rs Lines 1572 to 1575 in 7f55f81
Which doesn't join them together, it inserts them one by one. That means that only the last ID will actually be saved. That's a simple fix. Did the workaround for #349 fix anything? I'm not sure if that's a related issue here. |
That's great! Should I create a PR to change that or would you like to handle it?
Yes actually, The |
If you could, that'd be great! All the variants are here: lofty-rs/lofty/src/tag/item.rs Lines 592 to 644 in 7f55f81
With the exception of
I haven't looked into that issue in awhile, but I think it's a little more involved. You may need to keep using that workaround for a bit until I can get around to it. |
That's fine! It only adds a couple of lines of code for me |
Reproducer
I tried the following code:
Summary
When writing to Id3v2 Tags using the generic
Tag
struct, it seems to be erasing tags that have multiple values and making them singular that I don't even specify.Another odd side effect I didn't mention in the title is that when writing using
Tag
it also erases everything in theMusicBrainzRecordingId
for some odd reason as well.To make sure it was just Id3v2, I tried the same code with a file with Vorbis Comments, and another with Ilst and they were fine.
This seems similar to the issue #349,
I did read the workaround but I wasn't sure how to implement it with how I'm using the
ItemKey
,because the
Id3v2Tag
expects aFrame
instead of anItem
.I've generated examples of what I'm talking about:
Idv2
Original
Written with Lofty
Vorbis Comments
Original
Written with Lofty
Ilst
Original
Written with Lofty
I have more examples but this summary is getting long enough.
TLDR
When writing to Id3v2 Files with
Tag
it removes multiple strings from all items not just the ones I specify and replaces it with the first string.How would you recommend me go forward to fix this issue?
Expected behavior
When writing a Id3v2 files using
Tag
, keep the items that have multiple values.Assets
No response
The text was updated successfully, but these errors were encountered: