1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-14 10:24:19 +01:00

Parse embedded tags from Akamai streams.

Fixes #4804
This commit is contained in:
John Maguire 2015-05-26 17:40:35 +01:00
parent 7876f5f2c2
commit e7e3ab1a68

View File

@ -19,6 +19,7 @@
#include <QCoreApplication>
#include <QDir>
#include <QRegExp>
#include <QUuid>
#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);