From d0eec831c9d7bb818de5a95ea84ba0e22cf02b37 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 2 Mar 2025 08:46:21 +0100 Subject: Improve Title matching Check for a date first. If there is one, remove and set it. If not, continue trying to extract other data from the title. --- movieinfopage.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/movieinfopage.cpp b/movieinfopage.cpp index 22a2b65..6051e08 100644 --- a/movieinfopage.cpp +++ b/movieinfopage.cpp @@ -243,12 +243,18 @@ void MovieInfoPage::extractMetadata(){ bool MovieInfoPage::extractFromTitle(const QString &title){ QString curTitle = title; static QRegularExpression removals("\\(4[kK]\\)"); - static QRegularExpression titleRe("^(.*)?\\s?-\\s?(.*?)\\s+\\((\\d{4}-\\d{2}-\\d{2})\\)"); + static QRegularExpression has_date("\\s*\\((\\d{4}-\\d{2}-\\d{2}\\))"); curTitle = curTitle.replace(removals, ""); + QDate created = QDate::currentDate(); + QRegularExpressionMatch dateMatch = has_date.match(curTitle); + if(dateMatch.hasMatch()){ + created = QDate::fromString(dateMatch.captured(1), Qt::ISODate); + curTitle.replace(has_date, ""); + } + static QRegularExpression titleRe("^(.*?)\\s*-\\s*(.*)"); QRegularExpressionMatch titleMatch = titleRe.match(curTitle); if(titleMatch.hasMatch()){ QString subtitle = titleMatch.captured(2).simplified().toLower(); - QDate created = QDate::fromString(titleMatch.captured(3), Qt::ISODate); QStringList actors = titleMatch.captured(1).split('&'); QStringList aRes; for(const auto &a : std::as_const(actors)){ -- cgit v1.2.3-70-g09d2