Integrate corrected char expressions into Liam code36
This commit is contained in:
@@ -12,8 +12,11 @@ ASSET_ROOT=MEDIA['assetRoot']
|
||||
BASIC_ROOT=MEDIA['bootstrapRoot']
|
||||
sha=lambda data:hashlib.sha256(data).hexdigest()
|
||||
|
||||
def derive(source):
|
||||
index=source/'manifest.json';assert sha(index.read_bytes())==PIN,'exact index drift'
|
||||
def derive(source,media_bundle='black-correct03'):
|
||||
media=json.loads((ROOT/'manifests/character-build-profiles.json').read_bytes())['mediaBundles'][media_bundle]
|
||||
pin=media['indexSha256'];asset_root=media['assetRoot']
|
||||
assert media.get('userAuthorizedDebug') is True,'authorized debug bundle required'
|
||||
index=source/'manifest.json';assert sha(index.read_bytes())==pin,'exact index drift'
|
||||
m=json.loads(index.read_bytes());row=next(r for r in m['conversationPackages'] if r['id']==m['fallbackPackageId'])
|
||||
runtime=source/row['runtimeManifest']['path'];assert sha(runtime.read_bytes())==row['runtimeManifest']['sha256']
|
||||
body=json.loads(runtime.read_bytes())['body'];name=str(Path(row['runtimeManifest']['path']).parent/body['path'])
|
||||
@@ -22,23 +25,25 @@ def derive(source):
|
||||
native=subprocess.check_output(['/home/ubuntu/gori-bin/ffmpeg','-v','error','-i',str(path),'-frames:v','1','-f','image2pipe','-vcodec','png','-'],timeout=30)
|
||||
image=Image.open(io.BytesIO(native)).convert('RGB').resize((180,320),Image.Resampling.LANCZOS)
|
||||
out=io.BytesIO();image.save(out,format='PNG',optimize=True);poster=out.getvalue();assert len(poster)<=100_000
|
||||
meta={'schemaVersion':1,'sourceIndexSha256':PIN,'posterSha256':sha(poster),'posterWidth':180,'posterHeight':320,
|
||||
meta={'schemaVersion':1,'sourceIndexSha256':pin,'posterSha256':sha(poster),'posterWidth':180,'posterHeight':320,
|
||||
'provenance':'Exact decoded neutral source frame0; CPU downsample, no generated media; user-authorized debug integration, not Pi certification',
|
||||
'body':{**body,'path':ASSET_ROOT+name}}
|
||||
'body':{**body,'path':asset_root+name}}
|
||||
return (json.dumps(meta,indent=2)+'\n').encode(),poster
|
||||
|
||||
def prepare(source,verify_only=False):
|
||||
raw,poster=derive(source)
|
||||
outputs={ROOT/'manifests/startup-black-tulle-correct03.json':raw,
|
||||
ROOT/'app/src/main/assets'/BASIC_ROOT/'manifest.json':raw,
|
||||
ROOT/'app/src/main/assets'/BASIC_ROOT/'poster.png':poster,
|
||||
ROOT/'app/src/main/res/drawable-nodpi/startup_black_tulle_poster.png':poster}
|
||||
def prepare(source,verify_only=False,media_bundle='black-correct03'):
|
||||
media=json.loads((ROOT/'manifests/character-build-profiles.json').read_bytes())['mediaBundles'][media_bundle]
|
||||
raw,poster=derive(source,media_bundle)
|
||||
outputs={ROOT/media.get('bootstrapMetadata','manifests/startup-black-tulle-correct03.json'):raw,
|
||||
ROOT/'app/src/main/assets'/media['bootstrapRoot']/'manifest.json':raw,
|
||||
ROOT/'app/src/main/assets'/media['bootstrapRoot']/'poster.png':poster,
|
||||
ROOT/media.get('resourceDirectory','app/src/main/res')/'drawable-nodpi'/(media['posterResource']+'.png'):poster}
|
||||
for path,data in outputs.items():
|
||||
if path.exists():assert path.read_bytes()==data,'Unknown bootstrap bytes preserved: '+str(path)
|
||||
else:
|
||||
assert not verify_only,'missing bootstrap: '+str(path)
|
||||
path.parent.mkdir(parents=True,exist_ok=True);path.write_bytes(data)
|
||||
return {'status':'passed','index_sha256':PIN,'bootstrap_sha256':sha(raw),'poster_sha256':sha(poster),'poster_bytes':len(poster),'paid_calls':0}
|
||||
return {'status':'passed','index_sha256':media['indexSha256'],'bootstrap_sha256':sha(raw),'poster_sha256':sha(poster),'poster_bytes':len(poster),'paid_calls':0}
|
||||
if __name__=='__main__':
|
||||
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--source',type=Path,required=True);parser.add_argument('--verify-only',action='store_true')
|
||||
args=parser.parse_args();print(json.dumps(prepare(args.source,args.verify_only),indent=2))
|
||||
parser.add_argument('--media-bundle',default='black-correct03')
|
||||
args=parser.parse_args();print(json.dumps(prepare(args.source,args.verify_only,args.media_bundle),indent=2))
|
||||
|
||||
Reference in New Issue
Block a user