diff options
author | Arno <arno@disconnect.de> | 2025-02-22 11:12:42 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2025-02-22 11:12:42 +0100 |
commit | a90ed071336371936abb25b6de892c543d3c30cf (patch) | |
tree | fee499fb262c9e5ea871e98d281b34c2e71f9440 /movieinfopage.cpp | |
parent | d2f5de6a4dcfafe765d77af745fec666f5bf60f2 (diff) | |
download | SheMov-a90ed071336371936abb25b6de892c543d3c30cf.tar.gz SheMov-a90ed071336371936abb25b6de892c543d3c30cf.tar.bz2 SheMov-a90ed071336371936abb25b6de892c543d3c30cf.zip |
Improve Metadata parsing
Check the filename for the common pattern <actors - title - date>. If
found, parse it and apply the result to the appropriate widgets.
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(){ |