summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--newmoviewizard.cpp18
-rw-r--r--newmoviewizard.h2
2 files changed, 20 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();
diff --git a/newmoviewizard.h b/newmoviewizard.h
index df52905..7b31e51 100644
--- a/newmoviewizard.h
+++ b/newmoviewizard.h
@@ -59,6 +59,7 @@ class MovieInfoPage : public QWizardPage {
void initCompleters();
private slots:
+ void extractTitle();
void addOld();
void addFiles();
void removeFile();
@@ -70,6 +71,7 @@ class MovieInfoPage : public QWizardPage {
QLineEdit *mSubtitle;
QSpinBox *mSeriesNo;
QSpinBox *mQuality;
+ QPushButton *mExtractTitle;
QPushButton *mAddOld;
QPushButton *mAddFile;
QPushButton *mRemoveFile;