diff options
-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)){ |