From e0172a38f448e4b93bff38f7b5af33e59e3f6f3d Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 8 Sep 2012 13:41:11 +0200 Subject: [PATCH] File.duration --- pandora/archive/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 1abb77a8..1b254eaf 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -149,6 +149,8 @@ class File(models.Model): def save(self, *args, **kwargs): if self.auto: self.set_state() + if self.duration <= 0: + self.duration = sum([s.info.get('duration',0) for s in self.streams.filter(source=None)]) self.sort_path = utils.sort_string(self.path) if self.is_subtitle: self.available = self.data and True or False @@ -453,8 +455,6 @@ class Stream(models.Model): self.info = ox.avinfo(self.video.path) self.oshash = self.info.get('oshash') self.duration = self.info.get('duration', 0) - if self.duration <= 0: - self.duration = sum([s.info['duration'] for s in self.streams.filter(source=None)]) if 'video' in self.info and self.info['video']: self.aspect_ratio = self.info['video'][0]['width'] / self.info['video'][0]['height'] else: