summaryrefslogtreecommitdiffstats
path: root/newmoviewizard.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2015-08-28 02:09:27 +0200
committerArno <arno@disconnect.de>2015-08-28 02:09:27 +0200
commit18f6e4027fa1383f336f902745f5a2e7796f9836 (patch)
treee43e93cad19a86c65e11b8050d468e7f7e13c706 /newmoviewizard.cpp
parent6bd88cc6ef5e4b7e5769d8ff9fbe41c0382f9ef4 (diff)
downloadSheMov-18f6e4027fa1383f336f902745f5a2e7796f9836.tar.gz
SheMov-18f6e4027fa1383f336f902745f5a2e7796f9836.tar.bz2
SheMov-18f6e4027fa1383f336f902745f5a2e7796f9836.zip
Extract title from Stream
If a title tag exists in a movie's metadata, extract it with ffmpeg and put it into mSubtitle when archiving new movies.
Diffstat (limited to 'newmoviewizard.cpp')
-rw-r--r--newmoviewizard.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp
index 6c15fef..2fec6e9 100644
--- a/newmoviewizard.cpp
+++ b/newmoviewizard.cpp
@@ -24,6 +24,7 @@
#include <QPixmap>
#include <QHeaderView>
#include <QSortFilterProxyModel>
+#include <QJsonObject>
#include "newmoviewizard.h"
#include "smtreeitem.h"
@@ -309,6 +310,9 @@ void MovieInfoPage::setupGui(){
//add + remove files
QHBoxLayout *fileButtonLayout = new QHBoxLayout;
fileButtonLayout->addStretch();
+ mExtractTitle = new QPushButton(tr("Title"));
+ fileButtonLayout->addWidget(mExtractTitle);
+ connect(mExtractTitle, SIGNAL(clicked()), this, SLOT(extractTitle()));
mAddOld = new QPushButton(tr("Add Old..."));
fileButtonLayout->addWidget(mAddOld);
connect(mAddOld, SIGNAL(clicked()), this, SLOT(addOld()));
@@ -425,6 +429,20 @@ void MovieInfoPage::initCompleters(){
mSeriesCompleterModel->setStringList(series);
}
+void MovieInfoPage::extractTitle(){
+ QModelIndexList curIdxList = mFileView->selectionModel()->selectedRows();
+ if(!curIdxList.isEmpty()){
+ QString fp = curIdxList.at(0).data(WizardTreeModel::FullPathRole).toString();
+ QJsonDocument jDoc = Helper::streamData(fp);
+ if(!jDoc.isNull()){
+ QJsonObject jObj1 = jDoc.object().value("format").toObject();
+ QJsonObject jObj2 = jObj1.value("tags").toObject();
+ QString title = jObj2.value("title").toString().toLower();
+ mSubtitle->setText(title);
+ }
+ }
+}
+
void MovieInfoPage::addOld(){
QFileDialog *oldFileDlg = new QFileDialog(this, tr("Select source"), mCurrentDir);
int retval = oldFileDlg->exec();