diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index 3c3d4376..0ab1c84c 100644 --- a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -260,7 +260,8 @@ PropertyMap TextIdentificationFrame::makeTIPLProperties() const map.unsupportedData().append(frameID()); return map; } - for(StringList::ConstIterator it = fieldList().begin(); it != fieldList().end(); ++it) { + StringList l = fieldList(); + for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) { bool found = false; for(uint i = 0; i < involvedPeopleSize; ++i) if(*it == involvedPeople[i][0]) { @@ -286,7 +287,8 @@ PropertyMap TextIdentificationFrame::makeTMCLProperties() const map.unsupportedData().append(frameID()); return map; } - for(StringList::ConstIterator it = fieldList().begin(); it != fieldList().end(); ++it) { + StringList l = fieldList(); + for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) { String instrument = PropertyMap::prepareKey(*it); if(instrument.isNull()) { // instrument is not a valid key -> frame unsupported diff --git a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp index ae013ec9..6719a9b3 100644 --- a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp @@ -114,11 +114,11 @@ void UnsynchronizedLyricsFrame::setTextEncoding(String::Type encoding) PropertyMap UnsynchronizedLyricsFrame::asProperties() const { - String key = PropertyMap::prepareKey(description()); PropertyMap map; - if(key.isEmpty()) - key = "LYRICS"; - if(key.isNull()) + String key = PropertyMap::prepareKey(description()); + if(key.isEmpty() || key.upper() == "LYRICS") + map.insert("LYRICS", text()); + else if(key.isNull()) map.unsupportedData().append(L"USLT/" + description()); else map.insert("LYRICS:" + key, text()); diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp index 4085daae..cdfa4353 100644 --- a/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/taglib/mpeg/id3v2/id3v2tag.cpp @@ -339,6 +339,7 @@ PropertyMap ID3v2::Tag::properties() const PropertyMap properties; for(FrameList::ConstIterator it = frameList().begin(); it != frameList().end(); ++it) { PropertyMap props = (*it)->asProperties(); + debug("read properties:\n" + props.toString()); properties.merge(props); } return properties; diff --git a/taglib/toolkit/tpropertymap.cpp b/taglib/toolkit/tpropertymap.cpp index 40bcaba7..1743a0b2 100644 --- a/taglib/toolkit/tpropertymap.cpp +++ b/taglib/toolkit/tpropertymap.cpp @@ -166,6 +166,8 @@ String PropertyMap::toString() const String ret = ""; for(ConstIterator it = begin(); it != end(); ++it) ret += it->first+"="+it->second.toString(", ") + "\n"; + if(!unsupported.isEmpty()) + ret += "Unsupported Data: " + unsupported.toString(", ") + "\n"; return ret; } diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index ef92b44d..530b3f3d 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -68,7 +69,8 @@ class TestID3v2 : public CppUnit::TestFixture CPPUNIT_TEST(testDowngradeTo23); // CPPUNIT_TEST(testUpdateFullDate22); TODO TYE+TDA should be upgraded to TDRC together CPPUNIT_TEST(testCompressedFrameWithBrokenLength); - CPPUNIT_TEST(testDictInterface); + CPPUNIT_TEST(testPropertyInterface); + CPPUNIT_TEST(testPropertyInterface2); CPPUNIT_TEST_SUITE_END(); public: @@ -549,7 +551,7 @@ public: CPPUNIT_ASSERT_EQUAL(TagLib::uint(86414), frame->picture().size()); } - void testDictInterface() + void testPropertyInterface() { ScopedFileCopy copy("rare_frames", ".mp3"); string newname = copy.fileName(); @@ -572,6 +574,55 @@ public: CPPUNIT_ASSERT_EQUAL(String("UFID"), dict.unsupportedData().front()); } + void testPropertyInterface2() + { + ID3v2::Tag tag; + ID3v2::UnsynchronizedLyricsFrame *frame1 = new ID3v2::UnsynchronizedLyricsFrame(); + frame1->setDescription("test"); + frame1->setText("la-la-la test"); + tag.addFrame(frame1); + + ID3v2::UnsynchronizedLyricsFrame *frame2 = new ID3v2::UnsynchronizedLyricsFrame(); + frame2->setDescription(""); + frame2->setText("la-la-la nodescription"); + tag.addFrame(frame2); + + ID3v2::AttachedPictureFrame *frame3 = new ID3v2::AttachedPictureFrame(); + frame3->setDescription("test picture"); + tag.addFrame(frame3); + + ID3v2::TextIdentificationFrame *frame4 = new ID3v2::TextIdentificationFrame("TIPL"); + frame4->setText("single value is invalid for TIPL"); + tag.addFrame(frame4); + + ID3v2::TextIdentificationFrame *frame5 = new ID3v2::TextIdentificationFrame("TMCL"); + StringList tmclData; + tmclData.append("VIOLIN"); + tmclData.append("a violinist"); + tmclData.append("PIANO"); + tmclData.append("a pianist"); + frame5->setText(tmclData); + tag.addFrame(frame5); + + PropertyMap properties = tag.properties(); + + CPPUNIT_ASSERT_EQUAL(2u, properties.unsupportedData().size()); + CPPUNIT_ASSERT(properties.unsupportedData().contains("TIPL")); + CPPUNIT_ASSERT(properties.unsupportedData().contains("APIC")); + + CPPUNIT_ASSERT(properties.contains("PERFORMER:VIOLIN")); + CPPUNIT_ASSERT(properties.contains("PERFORMER:PIANO")); + CPPUNIT_ASSERT_EQUAL(String("a violinist"), properties["PERFORMER:VIOLIN"].front()); + CPPUNIT_ASSERT_EQUAL(String("a pianist"), properties["PERFORMER:PIANO"].front()); + + CPPUNIT_ASSERT(properties.contains("LYRICS")); + CPPUNIT_ASSERT(properties.contains("LYRICS:TEST")); + + tag.removeUnsupportedProperties(properties.unsupportedData()); + CPPUNIT_ASSERT(tag.frameList("APIC").isEmpty()); + CPPUNIT_ASSERT(tag.frameList("TIPL").isEmpty()); + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);