use duration of files while we dont have streams, fixes #1208

This commit is contained in:
j 2013-01-31 08:52:37 +00:00
parent c576e347a8
commit d63e5cba32

View file

@ -544,6 +544,10 @@ class Item(models.Model):
streams = self.streams() streams = self.streams()
i['durations'] = [s.duration for s in streams] i['durations'] = [s.duration for s in streams]
i['duration'] = sum(i['durations']) i['duration'] = sum(i['durations'])
if not streams:
i['duration'] = self.files.filter(
Q(selected=True)|Q(wanted=True)
).aggregate(Sum('duration'))['duration__sum']
i['parts'] = len(i['durations']) i['parts'] = len(i['durations'])
if i['parts']: if i['parts']:
i['videoRatio'] = streams[0].aspect_ratio i['videoRatio'] = streams[0].aspect_ratio