Skip to content

Commit d61a333

Browse files
committed
Map lowercase MusicBrainz TIPL keys to properties (#1274)
1 parent e73517d commit d61a333

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

taglib/mpeg/id3v2/frames/textidentificationframe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ PropertyMap TextIdentificationFrame::makeTIPLProperties() const
315315
const StringList l = fieldList();
316316
for(auto it = l.begin(); it != l.end(); ++it) {
317317
auto found = std::find_if(involvedPeople.begin(), involvedPeople.end(),
318-
[=](const auto &person) { return *it == person.first; });
318+
[=](const auto &person) { return it->upper() == person.first; });
319319
if(found != involvedPeople.end()) {
320320
map.insert(found->second, (++it)->split(","));
321321
}

tests/test_id3v2.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,38 @@ class TestID3v2 : public CppUnit::TestFixture
12651265
CPPUNIT_ASSERT_EQUAL(static_cast<ID3v2::UserTextIdentificationFrame *>(nullptr), ID3v2::UserTextIdentificationFrame::find(&tag, "non existing"));
12661266
CPPUNIT_ASSERT_EQUAL(frame10, ID3v2::CommentsFrame::findByDescription(&tag, "iTunNORM"));
12671267
CPPUNIT_ASSERT_EQUAL(static_cast<ID3v2::CommentsFrame *>(nullptr), ID3v2::CommentsFrame::findByDescription(&tag, "non existing"));
1268+
1269+
// Check if the allowed TIPL keys are correctly mapped to properties.
1270+
// These are the keys used by MusicBrainz: arranger, engineer, producer, DJ-mix, mix.
1271+
// See https://picard-docs.musicbrainz.org/downloads/MusicBrainz_Picard_Tag_Map.html.
1272+
// MusicBrainz Picard uses lowercase keys whereas TagLib used uppercase keys.
1273+
auto frame11 = new ID3v2::TextIdentificationFrame("TIPL");
1274+
StringList tiplData;
1275+
tiplData.append("arranger");
1276+
tiplData.append("an arranger");
1277+
tiplData.append("ENGINEER");
1278+
tiplData.append("an engineer");
1279+
tiplData.append("producer");
1280+
tiplData.append("a producer");
1281+
tiplData.append("DJ-mix");
1282+
tiplData.append("a DJ mixer");
1283+
tiplData.append("mix");
1284+
tiplData.append("a mixer");
1285+
frame11->setText(tiplData);
1286+
tag.addFrame(frame11);
1287+
1288+
properties = tag.properties();
1289+
CPPUNIT_ASSERT_EQUAL(0u, properties.unsupportedData().size());
1290+
CPPUNIT_ASSERT(properties.contains("ARRANGER"));
1291+
CPPUNIT_ASSERT(properties.contains("ENGINEER"));
1292+
CPPUNIT_ASSERT(properties.contains("PRODUCER"));
1293+
CPPUNIT_ASSERT(properties.contains("DJMIXER"));
1294+
CPPUNIT_ASSERT(properties.contains("MIXER"));
1295+
CPPUNIT_ASSERT_EQUAL(String("an arranger"), properties["ARRANGER"].front());
1296+
CPPUNIT_ASSERT_EQUAL(String("an engineer"), properties["ENGINEER"].front());
1297+
CPPUNIT_ASSERT_EQUAL(String("a producer"), properties["PRODUCER"].front());
1298+
CPPUNIT_ASSERT_EQUAL(String("a DJ mixer"), properties["DJMIXER"].front());
1299+
CPPUNIT_ASSERT_EQUAL(String("a mixer"), properties["MIXER"].front());
12681300
}
12691301

12701302
void testPropertiesMovement()

0 commit comments

Comments
 (0)