From 198934e465bea0e4443b0de34f5312b78172a512 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 28 Oct 2023 11:57:44 +0200 Subject: [PATCH] get all originals, also get those with only animation player --- management/commands/generate_clips.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/management/commands/generate_clips.py b/management/commands/generate_clips.py index 3b56c35..caec151 100644 --- a/management/commands/generate_clips.py +++ b/management/commands/generate_clips.py @@ -1,5 +1,6 @@ import json import os +import re from collections import defaultdict from django.core.management.base import BaseCommand @@ -18,9 +19,9 @@ class Command(BaseCommand): def handle(self, **options): prefix = options['prefix'] clips = [] - for i in item.models.Item.objects.filter(data__type__contains="Original"): + for i in item.models.Item.objects.filter(sort__type='original'): qs = item.models.Item.objects.filter(data__title=i.data['title']).exclude(id=i.id) - if qs.count() >= 2: + if qs.count() >= 1: clip = {} durations = [] for e in item.models.Item.objects.filter(data__title=i.data['title']): @@ -41,6 +42,18 @@ class Command(BaseCommand): clip["duration"] = min(durations) clip['tags'] = i.data.get('tags', []) clip['editingtags'] = i.data.get('editingtags', []) + name = os.path.basename(clip['original']) + + seqid = re.sub("Hotel Aporia_(\d+)", "S\\1_", name).split('_')[:2] + seqid = [b[1:] if b[0] in ('B', 'S') else '0' for b in seqid] + seqid[1] = ''.join([b for b in seqid[1] if b.isdigit()]) + if not seqid[1]: + seqid[1] = '0' + try: + clip['seqid'] = int(''.join(['%06d' % int(b) for b in seqid])) + except: + print(name, seqid, 'failed') + raise if "original" in clip and "foreground" in clip and "background" in clip: clips.append(clip) elif "original" in clip and "animation" in clip: @@ -51,6 +64,8 @@ class Command(BaseCommand): with open(os.path.join(prefix, 'clips.json'), 'w') as fd: json.dump(clips, fd, indent=2, ensure_ascii=False) + print("using", len(clips), "clips") + voice_over = defaultdict(dict) for vo in item.models.Item.objects.filter( data__type__contains="Voice Over",