Branchwell

Jotley / website · jotley.ai / scripts / video-refresh / stage-neutral-delivery.py

1#!/usr/bin/env python3
2"""Stage the four verified six-color marketing exports; retain the previous cut."""
3import hashlib
4import json
5from pathlib import Path
6import shutil
7import subprocess
8
9ROOT = Path(__file__).resolve().parents[2]
10BASE = ROOT / 'output/video-refresh-20261023/workspace'
11REVISION = BASE / 'neutral-refresh-20261023'
12EXPORT = REVISION / 'export'
13DELIVERY = BASE / 'delivery'
14
15
16def main():
17 paths = [Path(f'website/films/jotley-marketing-v10-{quality}.mp4') for quality in ['2160p', '1080p', '720p']]
18 paths.append(Path('social/jotley-marketing-v10-portrait-1080p.mp4'))
19 for relative in paths:
20 source = EXPORT / relative
21 evidence = json.loads(source.with_suffix('.verification.json').read_text())
22 assert evidence['full_decode'] and evidence['final_limited_audio']
23 assert evidence['sha256'] == hashlib.file_digest(source.open('rb'), 'sha256').hexdigest()
24 archive = REVISION / 'v9-delivery'
25 for relative in paths:
26 previous = Path(str(relative).replace('v10', 'v9'))
27 for extension in ['.mp4', '.verification.json']:
28 old = DELIVERY / previous.with_suffix(extension)
29 target = archive / previous.with_suffix(extension)
30 if old.exists():
31 target.parent.mkdir(parents=True, exist_ok=True)
32 shutil.move(old, target)
33 source = EXPORT / relative
34 shutil.copy2(source, DELIVERY / relative)
35 shutil.copy2(source.with_suffix('.verification.json'), (DELIVERY / relative).with_suffix('.verification.json'))
36 for folder in ['posters', 'website/images/films', 'qc']:
37 for old in (DELIVERY / folder).glob('*marketing-v9*'):
38 target = archive / folder / old.name
39 target.parent.mkdir(parents=True, exist_ok=True)
40 shutil.move(old, target)
41 old_audio = DELIVERY / 'qc/audio-preservation.json'
42 if old_audio.exists():
43 (archive / 'qc').mkdir(exist_ok=True)
44 shutil.move(old_audio, archive / 'qc/audio-preservation.json')
45 shutil.copy2(REVISION / 'revision.json', DELIVERY / 'qc/six-colors-revision.json')
46 shutil.copy2(REVISION / 'narration-receipt.json', DELIVERY / 'qc/six-colors-narration.json')
47 movie = EXPORT / 'website/films/jotley-marketing-v10-1080p.mp4'
48 for label, second in [('poster', 3), ('first', 0)]:
49 dest = BASE / f'website-ready/jotley-marketing-v10-{label}.webp'
50 subprocess.run(['ffmpeg', '-v', 'error', '-y', '-ss', str(second), '-i', str(movie), '-frames:v', '1',
51 '-c:v', 'libwebp', '-quality', '95', str(dest)], check=True)
52 shutil.copy2(dest, ROOT / 'public/media/films' / dest.name)
53 shutil.copy2(dest, DELIVERY / 'website/images/films' / dest.name)
54 print('Four v10 marketing exports staged; prior v9 cut preserved')
55
56
57if __name__ == '__main__':
58 main()