diff --git a/management/commands/generate_clips.py b/management/commands/generate_clips.py index 4c96377..e2ecca9 100644 --- a/management/commands/generate_clips.py +++ b/management/commands/generate_clips.py @@ -1,7 +1,6 @@ import json import os import re -import subprocess from collections import defaultdict from django.core.management.base import BaseCommand @@ -34,7 +33,6 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('--lang', action='store', dest='lang', default=None, help='subtitle language') parser.add_argument('--prefix', action='store', dest='prefix', default="/srv/t_for_time", help='prefix to build clips in') - parser.add_argument('--censored', action='store', dest='censored', default=None, help='censor items from list') def handle(self, **options): prefix = options['prefix'] @@ -47,12 +45,8 @@ class Command(BaseCommand): tlang = None if lang == "en": lang = None - if options['censored']: - censored_list = itemlist.models.List.get(options["censored"]) - censored = list(censored_list.get_items(censored_list.user).all().values_list('public_id', flat=True)) clips = [] for i in item.models.Item.objects.filter(sort__type='original'): - original_target = "" qs = item.models.Item.objects.filter(data__title=i.data['title']).exclude(id=i.id) if qs.count() >= 1: clip = {} @@ -71,10 +65,6 @@ class Command(BaseCommand): if os.path.islink(target): os.unlink(target) os.symlink(source, target) - if type_ == "original": - original_target = target - if options['censored'] and e.public_id in censored: - target = '/srv/t_for_time/censored.mp4' clip[type_] = target durations.append(e.files.filter(selected=True)[0].duration) clip["duration"] = min(durations) @@ -87,7 +77,8 @@ class Command(BaseCommand): clip["duration"] = cd clip['tags'] = i.data.get('tags', []) clip['editingtags'] = i.data.get('editingtags', []) - name = os.path.basename(original_target) + name = os.path.basename(clip['original']) + seqid = re.sub("Hotel Aporia_(\d+)", "S\\1_", name) seqid = re.sub("Night March_(\d+)", "S\\1_", seqid) seqid = re.sub("_(\d+)H_(\d+)", "_S\\1\\2_", seqid) @@ -138,18 +129,3 @@ class Command(BaseCommand): } with open(os.path.join(prefix, 'voice_over.json'), 'w') as fd: json.dump(voice_over, fd, indent=2, ensure_ascii=False) - - if options['censored']: - censored_mp4 = '/srv/t_for_time/censored.mp4' - if not os.path.exists(censored_mp4): - cmd = [ - "ffmpeg", - "-nostats", "-loglevel", "error", - "-f", "lavfi", - "-i", "color=color=white:size=1920x1080:rate=24", - "-t", "3600", - "-c:v", "libx264", - "-pix_fmt", "yuv420p", - censored_mp4 - ] - subprocess.call(cmd) diff --git a/render.py b/render.py index 56fc94a..7c1493d 100644 --- a/render.py +++ b/render.py @@ -885,24 +885,19 @@ def render_infinity(options): prefix = options['prefix'] duration = int(options['duration']) - defaults = { - "offset": 100, - "max-items": 30, - "no_video": False, - } state_f = os.path.join(prefix, "infinity.json") if os.path.exists(state_f): with open(state_f) as fd: state = json.load(fd) else: - state = {} + state = { + "offset": 100, + "max-items": 30, + "no_video": False, + } for key in ("prefix", "duration", "debug", "single_file", "keep_audio", "stereo_downmix"): state[key] = options[key] - for key in defaults: - if key not in state: - state[key] = defaults[key] - while True: render_prefix = state["prefix"] + "/render/" current = [