summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2013-08-10 08:20:52 +0200
committerArno <am@disconnect.de>2013-08-10 08:20:52 +0200
commit485e8ca24887b387b2a8f08a7561d2054651633b (patch)
tree95e7bf7e824c7d976027333b87f8a697f26b0ff9
parentf26f8c0a1a569a1397c3dde1f3fd7d0d7795f1f6 (diff)
downloadSheMov-485e8ca24887b387b2a8f08a7561d2054651633b.tar.gz
SheMov-485e8ca24887b387b2a8f08a7561d2054651633b.tar.bz2
SheMov-485e8ca24887b387b2a8f08a7561d2054651633b.zip
Fix issues with movie duration
* cast from double to int to insert seconds into the database (newmoviewizard.cpp) * update the database with the duration if the movie is local and we don't have a duration
-rw-r--r--archivemodel.cpp12
-rw-r--r--newmoviewizard.cpp2
2 files changed, 13 insertions, 1 deletions
diff --git a/archivemodel.cpp b/archivemodel.cpp
index 692629d..4f4c69e 100644
--- a/archivemodel.cpp
+++ b/archivemodel.cpp
@@ -857,6 +857,18 @@ void ArchiveFilesModel::populate(const QSet<int> &seriesPartIds){
if(data.at(FileType).toInt() == Movie){
SmTreeItem *newItem = new SmTreeItem(data, movies);
movies->appendChild(newItem);
+ if((data.at(DvdNo).toInt() < 0) && (data.at(SizeDur) == 0)){
+ QVariantMap m = Helper::ffmpegData(data.at(FullPath).toString());
+ QSqlQuery updDurQ = QSqlQuery(mDb);
+ updDurQ.prepare("UPDATE files SET iduration = :dur WHERE ifiles_id = :id");
+ // we have to cast this to int explicitly, otherwise Postgres will choke
+ int dur = m.value("duration").toDouble();
+ updDurQ.bindValue(":dur", dur);
+ updDurQ.bindValue(":id", data.at(FileId));
+ if(updDurQ.exec()){
+ data[SizeDur] = dur;
+ }
+ }
}else{
SmTreeItem *newItem = new SmTreeItem(data, pictures);
pictures->appendChild(newItem);
diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp
index 72b7d1e..9c12dca 100644
--- a/newmoviewizard.cpp
+++ b/newmoviewizard.cpp
@@ -128,7 +128,7 @@ void NewMovieWizard::accept(){
int type = fData.value(WizardTreeModel::FileType).toInt();
if(type == ArchiveFilesModel::Movie){
QVariantMap m = Helper::ffmpegData(fullPath);
- secs = m.value("duration").toInt();
+ secs = m.value("duration").toDouble();
}else{
QPixmap pix(fullPath);
picSize = QString("%1x%2").arg(QString::number(pix.width())).arg(QString::number(pix.height()));