get all originals, also get those with only animation player

This commit is contained in:
j 2023-10-28 11:57:44 +02:00
parent 056bc1e6ba
commit 198934e465

View file

@ -1,5 +1,6 @@
import json import json
import os import os
import re
from collections import defaultdict from collections import defaultdict
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
@ -18,9 +19,9 @@ class Command(BaseCommand):
def handle(self, **options): def handle(self, **options):
prefix = options['prefix'] prefix = options['prefix']
clips = [] 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) qs = item.models.Item.objects.filter(data__title=i.data['title']).exclude(id=i.id)
if qs.count() >= 2: if qs.count() >= 1:
clip = {} clip = {}
durations = [] durations = []
for e in item.models.Item.objects.filter(data__title=i.data['title']): 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["duration"] = min(durations)
clip['tags'] = i.data.get('tags', []) clip['tags'] = i.data.get('tags', [])
clip['editingtags'] = i.data.get('editingtags', []) 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: if "original" in clip and "foreground" in clip and "background" in clip:
clips.append(clip) clips.append(clip)
elif "original" in clip and "animation" in 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: with open(os.path.join(prefix, 'clips.json'), 'w') as fd:
json.dump(clips, fd, indent=2, ensure_ascii=False) json.dump(clips, fd, indent=2, ensure_ascii=False)
print("using", len(clips), "clips")
voice_over = defaultdict(dict) voice_over = defaultdict(dict)
for vo in item.models.Item.objects.filter( for vo in item.models.Item.objects.filter(
data__type__contains="Voice Over", data__type__contains="Voice Over",