diff options
Diffstat (limited to 'movieinfopage.cpp')
-rw-r--r-- | movieinfopage.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/movieinfopage.cpp b/movieinfopage.cpp index ae77d00..4b02b05 100644 --- a/movieinfopage.cpp +++ b/movieinfopage.cpp @@ -232,10 +232,31 @@ void MovieInfoPage::extractMetadata(){ fn.replace(".mkv", ""); fn.replace(".mp4", ""); fn.replace(".", " "); - mSubtitle->setText(fn); + if(!extractFromTitle(fn)){ + mSubtitle->setText(fn); + } + } + } +} +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})\\)"); + curTitle = curTitle.replace(removals, ""); + 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('&'); + for(const auto &a : std::as_const(actors)){ + mPossbileActors.append(a.simplified().toLower()); } + mSubtitle->setText(subtitle); + mCreationDate->setDate(created); + return true; } + return false; } void MovieInfoPage::addOld(){ |