From d83027638723aa5c047ebf46347aeeed0148249e Mon Sep 17 00:00:00 2001 From: Sergio Costas Date: Sun, 7 Dec 2014 19:10:51 +0100 Subject: [PATCH] Now shows the duration of each title --- data/interface/wmain.ui | 21 ++++++++++++++++++--- src/devede/file_movie.py | 4 ++++ src/devede/project.py | 19 +++++++++++++++++-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/data/interface/wmain.ui b/data/interface/wmain.ui index f9ba54f..2053899 100644 --- a/data/interface/wmain.ui +++ b/data/interface/wmain.ui @@ -36,6 +36,8 @@ + + @@ -218,18 +220,18 @@ True True liststore_files - False + False True False 0 - False - column + Title + True @@ -241,6 +243,19 @@ + + + Duration + + + right + + + 3 + + + + diff --git a/src/devede/file_movie.py b/src/devede/file_movie.py index cb2f238..44b4169 100644 --- a/src/devede/file_movie.py +++ b/src/devede/file_movie.py @@ -183,6 +183,10 @@ class file_movie(devede.interface_manager.interface_manager): self.emit('title_changed',self.title_name) + def get_duration(self): + return self.original_length + + def get_estimated_size(self): """ Returns the estimated final file size, in kBytes, based on the final audio and video rate, and the subtitles """ diff --git a/src/devede/project.py b/src/devede/project.py index b255059..bec5c6d 100644 --- a/src/devede/project.py +++ b/src/devede/project.py @@ -21,6 +21,7 @@ import time import shutil import urllib.parse import pickle +import math import devede.file_movie import devede.ask @@ -219,6 +220,20 @@ class devede_project: self.add_several_files(ask_files.files) + def duration_to_string(self,duration): + + seconds = math.floor(duration%60) + minutes = math.floor((duration/60)%60) + hours = math.floor(duration/3600) + + output = str(seconds)+"s" + if ((hours != 0) or (minutes != 0)): + output = str(minutes)+"m "+output + if (hours != 0): + output = str(hours)+"h "+output + return output + + def add_several_files(self,file_list): error_list = [] for efile in file_list: @@ -229,7 +244,7 @@ class devede_project: error_list.append(os.path.basename(efile)) else: new_file.connect('title_changed',self.title_changed) - self.wliststore_files.append([new_file, new_file.title_name,True]) + self.wliststore_files.append([new_file, new_file.title_name,True,self.duration_to_string(new_file.get_duration())]) if (len(error_list)!=0): devede.message.message_window(_("The following files could not be added:"),_("Error while adding files"),error_list) self.set_interface_status(None) @@ -648,7 +663,7 @@ class devede_project: else: new_file.restore_file(efile) new_file.connect('title_changed',self.title_changed) - self.wliststore_files.append([new_file, new_file.title_name,True]) + self.wliststore_files.append([new_file, new_file.title_name,True,self.duration_to_string(new_file.get_duration())]) if (len(error_list)!=0): devede.message.message_window(_("The following files in the project could not be added again:"),_("Error while adding files"),error_list) self.set_interface_status(None)