Convert IPLS to TIPL and TMCL (#1274)

The involvement/involvee pairs which are supported for TIPL properties
(ARRANGER, ENGINEER, PRODUCER, DJ-MIX, MIX) are left in the TIPL
frame, other pairs are moved to a TMCL frame. This will result in a
consistent behavior for both ID3v2.3 and ID3v2.4 tags produced by
MusicBrainz Picard.
This commit is contained in:
Urs Fleisch
2025-06-14 13:14:22 +02:00
parent d61a333f27
commit 88d6b18b4f
2 changed files with 56 additions and 10 deletions

View File

@ -357,6 +357,49 @@ void FrameFactory::rebuildAggregateFrames(ID3v2::Tag *tag) const
}
}
}
if(tag->header()->majorVersion() < 4 &&
tag->frameList("TIPL").size() == 1 &&
tag->frameList("TMCL").size() == 0)
{
// FrameFactory::updateFrame() has mapped IPLS (ID3v2.3)/ IPL (ID3v2.2)
// to TIPL (ID3v2.4). However, the musicians should be rather in TMCL.
// Move all involvement/involvee pairs which are not supported by the
// TIPL property map interface to a TMCL frame.
if(auto tipl =
dynamic_cast<TextIdentificationFrame *>(tag->frameList("TIPL").front())) {
if(StringList tiplValues = tipl->toStringList(); tiplValues.size() % 2 == 0) {
static StringList tiplKeys;
if(tiplKeys.isEmpty()) {
for(const auto &kv : TextIdentificationFrame::involvedPeopleMap()) {
tiplKeys.append(kv.second);
}
}
StringList tmclValues;
for(auto it = tiplValues.begin(); it != tiplValues.end();) {
const String involvement = *it;
if(!tiplKeys.contains(involvement.upper())) {
tmclValues.append(involvement);
it = tiplValues.erase(it);
tmclValues.append(*it);
it = tiplValues.erase(it);
} else {
++it;
++it;
}
}
if(!tmclValues.isEmpty()) {
auto tmcl = new TextIdentificationFrame("TMCL");
tmcl->setText(tmclValues);
tag->addFrame(tmcl);
if(!tiplValues.isEmpty()) {
tipl->setText(tiplValues);
} else {
tag->removeFrame(tipl);
}
}
}
}
}
}
String::Type FrameFactory::defaultTextEncoding() const