diff --git a/management/commands/generate_clips.py b/management/commands/generate_clips.py index b9e46f3..4f2c9e0 100644 --- a/management/commands/generate_clips.py +++ b/management/commands/generate_clips.py @@ -26,7 +26,7 @@ class Command(BaseCommand): for e in item.models.Item.objects.filter(data__title=i.data['title']): if 'type' not in e.data: print("ignoring invalid video", e) - source = e.files.all()[0].data.path + source = e.files.filter(selected=True)[0].data.path ext = os.path.splitext(source)[1] type_ = e.data['type'][0].lower() target = os.path.join(prefix, type_, i.data['title'] + ext) @@ -35,7 +35,7 @@ class Command(BaseCommand): os.unlink(target) os.symlink(source, target) clip[type_] = target - durations.append(e.files.all()[0].duration) + durations.append(e.files.filter(selected=True)[0].duration) clip["duration"] = min(durations) clip['tags'] = i.data.get('tags', []) clip['editingtags'] = i.data.get('editingtags', []) @@ -52,7 +52,7 @@ class Command(BaseCommand): data__type__contains="Voice Over", ): fragment_id = int(vo.get('title').split('_')[0]) - source = vo.files.all()[0] + source = vo.files.filter(selected=True)[0] batch = vo.get('batch')[0].replace('Text-', '') src = source.data.path target = os.path.join(prefix, 'voice_over', batch, '%s.wav' % fragment_id)