From e7e3ab1a6836878c7d8c0a90dccbf2ad65ab6412 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 26 May 2015 17:40:35 +0100 Subject: [PATCH] Parse embedded tags from Akamai streams. Fixes #4804 --- src/engines/gstenginepipeline.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/engines/gstenginepipeline.cpp b/src/engines/gstenginepipeline.cpp index b81791713..f29dba067 100644 --- a/src/engines/gstenginepipeline.cpp +++ b/src/engines/gstenginepipeline.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include "bufferconsumer.h" @@ -601,12 +602,41 @@ void GstEnginePipeline::ErrorMessageReceived(GstMessage* msg) { emit Error(id(), message, domain, code); } +namespace { + +/* + * Streams served by Akamai tend to have a weird tag format embedded. + * + * Example: + * All Things Dance - text="Evolution" song_spot="T" MediaBaseId="0" + * itunesTrackId="0" amgTrackId="0" amgArtistId="0" TAID="0" TPID="0" + * cartcutId="0" + */ +QString ParseAkamaiTag(const QString& tag) { + QRegExp re(" - text=\"([^\"]+)"); + re.indexIn(tag); + QStringList captured = re.capturedTexts(); + if (captured.length() >= 2) { + return re.cap(1); + } + return tag; +} + +bool IsAkamaiTag(const QString& tag) { + return tag.contains("- text=\""); +} + +} + void GstEnginePipeline::TagMessageReceived(GstMessage* msg) { GstTagList* taglist = nullptr; gst_message_parse_tag(msg, &taglist); Engine::SimpleMetaBundle bundle; bundle.title = ParseTag(taglist, GST_TAG_TITLE); + if (IsAkamaiTag(bundle.title)) { + bundle.title = ParseAkamaiTag(bundle.title); + } bundle.artist = ParseTag(taglist, GST_TAG_ARTIST); bundle.comment = ParseTag(taglist, GST_TAG_COMMENT); bundle.album = ParseTag(taglist, GST_TAG_ALBUM);