#!/usr/bin/env python3 """Stage the four verified six-color marketing exports; retain the previous cut.""" import hashlib import json from pathlib import Path import shutil import subprocess ROOT = Path(__file__).resolve().parents[2] BASE = ROOT / 'output/video-refresh-20261023/workspace' REVISION = BASE / 'neutral-refresh-20261023' EXPORT = REVISION / 'export' DELIVERY = BASE / 'delivery' def main(): paths = [Path(f'website/films/jotley-marketing-v10-{quality}.mp4') for quality in ['2160p', '1080p', '720p']] paths.append(Path('social/jotley-marketing-v10-portrait-1080p.mp4')) for relative in paths: source = EXPORT / relative evidence = json.loads(source.with_suffix('.verification.json').read_text()) assert evidence['full_decode'] and evidence['final_limited_audio'] assert evidence['sha256'] == hashlib.file_digest(source.open('rb'), 'sha256').hexdigest() archive = REVISION / 'v9-delivery' for relative in paths: previous = Path(str(relative).replace('v10', 'v9')) for extension in ['.mp4', '.verification.json']: old = DELIVERY / previous.with_suffix(extension) target = archive / previous.with_suffix(extension) if old.exists(): target.parent.mkdir(parents=True, exist_ok=True) shutil.move(old, target) source = EXPORT / relative shutil.copy2(source, DELIVERY / relative) shutil.copy2(source.with_suffix('.verification.json'), (DELIVERY / relative).with_suffix('.verification.json')) for folder in ['posters', 'website/images/films', 'qc']: for old in (DELIVERY / folder).glob('*marketing-v9*'): target = archive / folder / old.name target.parent.mkdir(parents=True, exist_ok=True) shutil.move(old, target) old_audio = DELIVERY / 'qc/audio-preservation.json' if old_audio.exists(): (archive / 'qc').mkdir(exist_ok=True) shutil.move(old_audio, archive / 'qc/audio-preservation.json') shutil.copy2(REVISION / 'revision.json', DELIVERY / 'qc/six-colors-revision.json') shutil.copy2(REVISION / 'narration-receipt.json', DELIVERY / 'qc/six-colors-narration.json') movie = EXPORT / 'website/films/jotley-marketing-v10-1080p.mp4' for label, second in [('poster', 3), ('first', 0)]: dest = BASE / f'website-ready/jotley-marketing-v10-{label}.webp' subprocess.run(['ffmpeg', '-v', 'error', '-y', '-ss', str(second), '-i', str(movie), '-frames:v', '1', '-c:v', 'libwebp', '-quality', '95', str(dest)], check=True) shutil.copy2(dest, ROOT / 'public/media/films' / dest.name) shutil.copy2(dest, DELIVERY / 'website/images/films' / dest.name) print('Four v10 marketing exports staged; prior v9 cut preserved') if __name__ == '__main__': main()