Parse artist out of Akamai tags.

Fixes #4874
This commit is contained in:
John Maguire 2015-05-29 12:00:29 +01:00
parent fd645b37ab
commit 3f536d2571
1 changed files with 13 additions and 10 deletions

View File

@ -19,6 +19,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
#include <QPair>
#include <QRegExp> #include <QRegExp>
#include <QUuid> #include <QUuid>
@ -612,14 +613,13 @@ namespace {
* itunesTrackId="0" amgTrackId="0" amgArtistId="0" TAID="0" TPID="0" * itunesTrackId="0" amgTrackId="0" amgArtistId="0" TAID="0" TPID="0"
* cartcutId="0" * cartcutId="0"
*/ */
QString ParseAkamaiTag(const QString& tag) { QPair<QString, QString> ParseAkamaiTag(const QString& tag) {
QRegExp re(" - text=\"([^\"]+)"); QRegExp re("(.*) - text=\"([^\"]+)");
re.indexIn(tag); re.indexIn(tag);
QStringList captured = re.capturedTexts(); if (re.capturedTexts().length() >= 3) {
if (captured.length() >= 2) { return qMakePair(re.cap(1), re.cap(2));
return re.cap(1);
} }
return tag; return qMakePair(tag, QString());
} }
bool IsAkamaiTag(const QString& tag) { bool IsAkamaiTag(const QString& tag) {
@ -635,11 +635,14 @@ void GstEnginePipeline::TagMessageReceived(GstMessage* msg) {
Engine::SimpleMetaBundle bundle; Engine::SimpleMetaBundle bundle;
bundle.title = ParseTag(taglist, GST_TAG_TITLE); bundle.title = ParseTag(taglist, GST_TAG_TITLE);
if (IsAkamaiTag(bundle.title)) { if (IsAkamaiTag(bundle.title)) {
bundle.title = ParseAkamaiTag(bundle.title); QPair<QString, QString> artistTitlePair = ParseAkamaiTag(bundle.title);
bundle.artist = artistTitlePair.first;
bundle.title = artistTitlePair.second;
} else {
bundle.artist = ParseTag(taglist, GST_TAG_ARTIST);
bundle.comment = ParseTag(taglist, GST_TAG_COMMENT);
bundle.album = ParseTag(taglist, GST_TAG_ALBUM);
} }
bundle.artist = ParseTag(taglist, GST_TAG_ARTIST);
bundle.comment = ParseTag(taglist, GST_TAG_COMMENT);
bundle.album = ParseTag(taglist, GST_TAG_ALBUM);
gst_tag_list_free(taglist); gst_tag_list_free(taglist);