From 485e8ca24887b387b2a8f08a7561d2054651633b Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 10 Aug 2013 08:20:52 +0200 Subject: 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 --- archivemodel.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'archivemodel.cpp') 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 &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); -- cgit v1.2.3-70-g09d2