diff options
author | Arno <arno@disconnect.de> | 2025-03-02 08:46:21 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2025-03-02 08:46:21 +0100 |
commit | d0eec831c9d7bb818de5a95ea84ba0e22cf02b37 (patch) | |
tree | 91f71eae5c02cb5860a1696c63ae2e59f363c8ba | |
parent | 65fec2cecdf8345c7b6b6e8ad5b83d6b5a6dad80 (diff) | |
download | SheMov-d0eec831c9d7bb818de5a95ea84ba0e22cf02b37.tar.gz SheMov-d0eec831c9d7bb818de5a95ea84ba0e22cf02b37.tar.bz2 SheMov-d0eec831c9d7bb818de5a95ea84ba0e22cf02b37.zip |
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.
-rw-r--r-- | movieinfopage.cpp | 10 |
1 files 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)){ |