From b1099e6974e00bbff01bd9e18d4a3a06c77c5a7c Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Fri, 7 Aug 2020 00:52:09 +0200 Subject: [PATCH] Handle metadata with tilde in title --- src/engine/gstenginepipeline.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index cd09ee2b3..c6d5a5515 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -897,13 +897,31 @@ void GstEnginePipeline::TagMessageReceived(GstMessage *msg) { bundle.bitrate = ParseUIntTag(taglist, GST_TAG_BITRATE) / 1000; bundle.lyrics = ParseStrTag(taglist, GST_TAG_LYRICS); - if (!bundle.title.isEmpty() && bundle.artist.isEmpty() && bundle.album.isEmpty() && bundle.title.contains(" - ")) { - QStringList title_splitted = bundle.title.split(" - "); - if (title_splitted.count() == 2) { - bundle.artist = title_splitted.first(); - bundle.title = title_splitted.last(); - bundle.artist = bundle.artist.trimmed(); - bundle.title = bundle.title.trimmed(); + if (!bundle.title.isEmpty() && bundle.artist.isEmpty() && bundle.album.isEmpty()) { + if (bundle.title.contains(" - ")) { + QStringList title_splitted = bundle.title.split(" - "); + bundle.artist = title_splitted.first().trimmed(); + bundle.title = title_splitted.last().trimmed(); + } + else if (bundle.title.contains('~') && bundle.title.count('~') >= 2) { + QStringList title_splitted = bundle.title.split('~'); + int i = 1; + for (const QString &part : title_splitted) { + switch (i) { + case 1: + bundle.artist = part; + break; + case 2: + bundle.title = part; + break; + case 3: + bundle.album = part; + break; + default: + break; + } + ++i; + } } }