diff --git a/autotests/taglibextractortest.cpp b/autotests/taglibextractortest.cpp --- a/autotests/taglibextractortest.cpp +++ b/autotests/taglibextractortest.cpp @@ -78,6 +78,7 @@ QCOMPARE(resultOpus.properties().value(Property::Copyright), QVariant(QStringLiteral("Copyright"))); QCOMPARE(resultOpus.properties().value(Property::Compilation), QVariant(QStringLiteral("Compilation"))); QCOMPARE(resultOpus.properties().value(Property::License), QVariant(QStringLiteral("License"))); + QCOMPARE(resultOpus.properties().value(Property::Lyrics), QVariant(QStringLiteral("Lyrics"))); QCOMPARE(resultOpus.properties().value(Property::Opus).toInt(), 1); QCOMPARE(resultOpus.properties().value(Property::TrackNumber).toInt(), 1); QCOMPARE(resultOpus.properties().value(Property::ReleaseYear).toInt(), 2015); @@ -115,6 +116,7 @@ QCOMPARE(resultFlac.properties().value(Property::Copyright), QVariant(QStringLiteral("Copyright"))); QCOMPARE(resultFlac.properties().value(Property::Compilation), QVariant(QStringLiteral("Compilation"))); QCOMPARE(resultFlac.properties().value(Property::License), QVariant(QStringLiteral("License"))); + QCOMPARE(resultFlac.properties().value(Property::Lyrics), QVariant(QStringLiteral("Lyrics"))); QCOMPARE(resultFlac.properties().value(Property::Opus).toInt(), 1); QCOMPARE(resultFlac.properties().value(Property::TrackNumber).toInt(), 1); QCOMPARE(resultFlac.properties().value(Property::ReleaseYear).toInt(), 2015); @@ -152,6 +154,7 @@ QCOMPARE(resultOgg.properties().value(Property::Copyright), QVariant(QStringLiteral("Copyright"))); QCOMPARE(resultOgg.properties().value(Property::Compilation), QVariant(QStringLiteral("Compilation"))); QCOMPARE(resultOgg.properties().value(Property::License), QVariant(QStringLiteral("License"))); + QCOMPARE(resultOgg.properties().value(Property::Lyrics), QVariant(QStringLiteral("Lyrics"))); QCOMPARE(resultOgg.properties().value(Property::Opus).toInt(), 1); QCOMPARE(resultOgg.properties().value(Property::TrackNumber).toInt(), 1); QCOMPARE(resultOgg.properties().value(Property::ReleaseYear).toInt(), 2015); @@ -180,6 +183,7 @@ QCOMPARE(resultMp3.properties().value(Property::Publisher), QVariant(QStringLiteral("Publisher"))); QCOMPARE(resultMp3.properties().value(Property::Langauge), QVariant(QStringLiteral("Language"))); QCOMPARE(resultMp3.properties().value(Property::Compilation), QVariant(QStringLiteral("Compilation"))); + QCOMPARE(resultMp3.properties().value(Property::Lyrics), QVariant(QStringLiteral("Lyrics"))); QCOMPARE(resultMp3.properties().value(Property::TrackNumber).toInt(), 1); QCOMPARE(resultMp3.properties().value(Property::ReleaseYear).toInt(), 2015); QCOMPARE(resultMp3.properties().value(Property::Channels).toInt(), 1); @@ -215,6 +219,7 @@ QCOMPARE(resultMpc.properties().value(Property::Copyright), QVariant(QStringLiteral("Copyright"))); QCOMPARE(resultMpc.properties().value(Property::Compilation), QVariant(QStringLiteral("Compilation"))); QCOMPARE(resultMpc.properties().value(Property::License), QVariant(QStringLiteral("License"))); + QCOMPARE(resultMpc.properties().value(Property::Lyrics), QVariant(QStringLiteral("Lyrics"))); QCOMPARE(resultMpc.properties().value(Property::TrackNumber).toInt(), 1); QCOMPARE(resultMpc.properties().value(Property::ReleaseYear).toInt(), 2015); QCOMPARE(resultMpc.properties().value(Property::Channels).toInt(), 1); @@ -239,6 +244,7 @@ QCOMPARE(resultMp4.properties().value(Property::Comment), QVariant(QStringLiteral("Comment"))); QCOMPARE(resultMp4.properties().value(Property::Composer), QVariant(QStringLiteral("Composer"))); QCOMPARE(resultMp4.properties().value(Property::Copyright), QVariant(QStringLiteral("Copyright"))); + QCOMPARE(resultMp4.properties().value(Property::Lyrics), QVariant(QStringLiteral("Lyrics"))); QCOMPARE(resultMp4.properties().value(Property::TrackNumber).toInt(), 1); QCOMPARE(resultMp4.properties().value(Property::ReleaseYear).toInt(), 2015); QCOMPARE(resultMp4.properties().value(Property::Channels).toInt(), 2); diff --git a/src/extractors/taglibextractor.h b/src/extractors/taglibextractor.h --- a/src/extractors/taglibextractor.h +++ b/src/extractors/taglibextractor.h @@ -58,6 +58,7 @@ TagLib::String label; TagLib::String author; TagLib::String license; + TagLib::String lyrics; TagLib::String compilation; TagLib::StringList genres; QVariant discNumber; diff --git a/src/extractors/taglibextractor.cpp b/src/extractors/taglibextractor.cpp --- a/src/extractors/taglibextractor.cpp +++ b/src/extractors/taglibextractor.cpp @@ -198,6 +198,17 @@ } } + // Lyrics. + lstID3v2 = mpegFile.ID3v2Tag()->frameListMap()["USLT"]; + if (!lstID3v2.isEmpty()) { + for (TagLib::ID3v2::FrameList::ConstIterator it = lstID3v2.begin(); it != lstID3v2.end(); ++it) { + if (!data.lyrics.isEmpty()) { + data.lyrics += ", "; + } + data.lyrics += (*it)->toString(); + } + } + // Compilation. lstID3v2 = mpegFile.ID3v2Tag()->frameListMap()["TCMP"]; if (!lstID3v2.isEmpty()) { @@ -283,6 +294,11 @@ data.rating = itRating->second.toStringList().toString().toInt() / 10; } + TagLib::String lyricsAtomName(TagLib::String("©lyr", TagLib::String::UTF8).to8Bit(), TagLib::String::Latin1); + TagLib::MP4::ItemListMap::Iterator itLyrics = allTags.find(lyricsAtomName); + if (itLyrics != allTags.end()) { + data.lyrics = itLyrics->second.toStringList().toString(", "); + } } void TagLibExtractor::extractMusePack(TagLib::FileStream& stream, ExtractedData& data) @@ -415,6 +431,14 @@ data.license += (*itMPC).second.toString(); } + itMPC = lstMusepack.find("LYRICS"); + if (itMPC != lstMusepack.end()) { + if (!data.lyrics.isEmpty()) { + data.lyrics += ", "; + } + data.lyrics += (*itMPC).second.toString(); + } + itMPC = lstMusepack.find("COMPILATION"); if (itMPC != lstMusepack.end()) { if (!data.compilation.isEmpty()) { @@ -596,6 +620,14 @@ data.license += (*itOgg).second.toString(", "); } + itOgg = lstOgg.find("LYRICS"); + if (itOgg != lstOgg.end()) { + if (!data.lyrics.isEmpty()) { + data.lyrics += ", "; + } + data.lyrics += (*itOgg).second.toString(", "); + } + itOgg = lstOgg.find("COMPILATION"); if (itOgg != lstOgg.end()) { if (!data.compilation.isEmpty()) { @@ -816,6 +848,11 @@ result->add(Property::Compilation, arr); } + QString lyricsString = convertWCharsToQString(data.lyrics).trimmed(); + if (!lyricsString.isEmpty()) { + result->add(Property::Lyrics, lyricsString); + } + if (data.opus.isValid()) { result->add(Property::Opus, data.opus); } diff --git a/src/properties.h b/src/properties.h --- a/src/properties.h +++ b/src/properties.h @@ -320,6 +320,10 @@ * For ratings stored in Metadata tags */ Rating, + /** + * Contains the lyrics of a song embedded in the file + */ + Lyrics, PropertyCount, LastProperty = PropertyCount-1, diff --git a/src/propertyinfo.cpp b/src/propertyinfo.cpp --- a/src/propertyinfo.cpp +++ b/src/propertyinfo.cpp @@ -407,6 +407,12 @@ d->valueType = QVariant::String; break; + case Property::Lyrics: + d->name = QStringLiteral("lyrics"); + d->displayName = i18nc("@label", "Lyrics"); + d->valueType = QVariant::String; + break; + case Property::Opus: d->name = QStringLiteral("opus"); d->displayName = i18nc("@label", "Opus"); @@ -600,6 +606,7 @@ { QStringLiteral("label"), Property::Label }, { QStringLiteral("compilation"), Property::Compilation }, { QStringLiteral("license"), Property::License }, + { QStringLiteral("lyrics"), Property::Lyrics }, { QStringLiteral("creationdate"), Property::CreationDate }, { QStringLiteral("keywords"), Property::Keywords }, { QStringLiteral("width"), Property::Width },