Branchwell

Jotley / website / scripts / video-refresh / stage-tutorials.py

1from pathlib import Path
2import json,re,shutil,subprocess
3root=Path('/Volumes/Music/Jotley/Jotley-2.0-App-Store-Videos')
4capture=root/'capture-2.2-20261023'; workspace=root/'refresh-website-social-20261023';comp=workspace/'composition'
5receipts=[]
6def stage(source,target):
7 target.parent.mkdir(parents=True,exist_ok=True)
8 # A final-frame hold keeps short native UI excerpts visible through existing editorial holds.
9 subprocess.run(['ffmpeg','-v','error','-y','-i',str(source),'-vf','tpad=stop_mode=clone:stop_duration=25','-an','-c:v','libx264','-preset','fast','-crf','12','-pix_fmt','yuv420p','-movflags','+faststart',str(target)],check=True)
10 receipts.append({'source':str(source),'target':str(target),'treatment':'native dimensions, 1x playback; final-frame hold only'})
11def html_offsets(name,changes):
12 p=comp/name/'index.html';s=p.read_text()
13 for ident,offset in changes.items():
14 pattern=r'(<video\b[^>]*\bid="'+ident+r'"[^>]*\bdata-media-start=")[^"]*'
15 s,n=re.subn(pattern,lambda m:m[1]+str(offset),s)
16 assert n==1,(name,ident,n)
17 p.write_text(s)
18 receipts.append({'composition':name,'new_source_inpoints':changes,'timeline_duration':'unchanged','audio':'approved existing narration and mix retained'})
19a=comp/'tutorial-iphone-16x9/assets'
20for src,dst in [('Transcript-Generate','tg'),('Ask-AI','iphone-ask'),('Tag','tag'),('Search','search'),('Share','export')]:stage(capture/f'Jotley-2.2-iPhone-{src}.mp4',a/f'{dst}.mp4')
21html_offsets('tutorial-iphone-16x9',{'sv2':0.2,'sv3':6.3,'sv4':24.5,'sv7':4.6,'sv8':3.1,'sv11':8.3,'sv12':25.0})
22a=comp/'tutorial-ipad-16x9/assets'
23for folder,prefix,src,dst in [('ios','iPad','Summary','ipad-summary'),('ios','iPad','Ask-AI','ipad-ask'),('ios-land-final','iPad-Landscape','Summary','ipad-land-sum'),('ios-land-final','iPad-Landscape','Tag','ipad-land-tag')]:stage(capture/folder/f'Jotley-2.2-{prefix}-{src}.mp4',a/f'{dst}.mp4')
24(workspace/'tutorial-media-refresh.json').write_text(json.dumps(receipts,indent=2)+'\n')
25print(json.dumps(receipts,indent=2))