Buckets:
| """Decode loose audio/images and read back browser repairs, one bounded batch at a time.""" | |
| import os,json,re,hashlib,shutil | |
| from pathlib import Path | |
| from huggingface_hub import HfApi | |
| import soundfile as sf | |
| from PIL import Image | |
| H=Path('/home/user/game-archive');R=H/'reports';B='smodusermc/offline-games';api=HfApi(token=os.environ['HF_TOKEN']);ids=json.loads((R/'heavy-batch-plan.json').read_text())['ids'];stage=Path('/home/user/.cache/heavy-media');out=[] | |
| import subprocess,sys | |
| # A DOS help dialog is not a running game; explicitly advance it once. | |
| shutil.copy2(R/'verification-0143.json',R/'verification-0143-before-tutorial.json') | |
| subprocess.run([sys.executable,str(H/'tools/run_isolated.py'),'143'],check=True,env={**os.environ,'GAME_VERIFY_STAGE':'/home/user/.cache/game-verify-stage','VERIFY_SECONDS':'90'}) | |
| p=R/'heavy-batch-validation.json';state=json.loads(p.read_text());v=json.loads((R/'verification-0143.json').read_text());x=next(x for x in state['results'] if x['id']==143);x['runtime_status']=v.get('status');x['runtime_missing']=v.get('offline_missing_requests',{});x['runtime_followup']='Advanced DOS tutorial controls; no full playthrough claimed.';p.write_text(json.dumps(state,indent=2)) | |
| subprocess.run([sys.executable,str(H/'tools/repair_godot_support.py')],check=True) | |
| subprocess.run([sys.executable,str(H/'tools/check_gamemaker_audio.py')],check=True) | |
| for i in ids+[111]: | |
| m=json.loads((R/f'game-{i}.json').read_text());v=json.loads((R/f'verification-{i:04d}.json').read_text());extra={f['path'] for f in v.get('repairs',[]) if isinstance(f,dict) and 'path' in f};files=[f for f in m['files'] if i==111 or re.search(r'\.(ogg|wav|mp3|flac|png|jpe?g|webp|gif|bmp)$',f['path'],re.I) or f['path'] in extra];rows=[] | |
| for start in range(0,len(files),16): | |
| shutil.rmtree(stage,ignore_errors=True);stage.mkdir(parents=True);batch=files[start:start+16];api.download_bucket_files(B,[(f['path'],stage/f['path']) for f in batch],raise_on_missing_files=True) | |
| for f in batch: | |
| p=stage/f['path'];j={'path':f['path'],'browser_repair':f['path'] in extra} | |
| with p.open('rb') as stream:j['stored_sha256']=hashlib.file_digest(stream,'sha256').hexdigest() | |
| j['recorded_hash_match']=j['stored_sha256']==f.get('sha256') if f.get('sha256') else None | |
| try: | |
| if re.search(r'\.(ogg|wav|mp3|flac)$',f['path'],re.I): | |
| with sf.SoundFile(p) as audio: | |
| frames=0 | |
| while True: | |
| block=audio.read(65536,dtype='float32',always_2d=True) | |
| if len(block)==0:break | |
| frames+=len(block) | |
| j.update(kind='audio',decoded=True,frames=frames,sample_rate=audio.samplerate,channels=audio.channels) | |
| elif re.search(r'\.(png|jpe?g|webp|gif|bmp)$',f['path'],re.I): | |
| with Image.open(p) as image:image.load();j.update(kind='image',decoded=True,width=image.width,height=image.height) | |
| else:j.update(kind='binary_readback',decode_scope='Binary hash read-back only') | |
| except Exception as e:j.update(decoded=False,error=str(e)[:300]) | |
| rows.append(j) | |
| shutil.rmtree(stage,ignore_errors=True) | |
| if i==111: | |
| repair=R/'crashout-loader-repair.json';doc=json.loads(repair.read_text());doc['all_five_recorded_files_readback']=rows;doc['all_recorded_hashes_match']=all(x['recorded_hash_match'] is True for x in rows);repair.write_text(json.dumps(doc,indent=2));api.batch_bucket_files(B,add=[(repair,'_verification/crashout-loader-repair.json')]) | |
| out.append({'id':i,'files':rows});q=R/'heavy-batch-media.json';q.write_text(json.dumps({'results':out,'scope':'Full loose audio sample decoding with libsndfile; first image frame with Pillow. Embedded media inside game packages not individually decoded. Browser repairs receive additional hash read-back.'},indent=2));api.batch_bucket_files(B,add=[(q,'_verification/heavy-batch-media.json')]);print('MEDIA',i,len(rows),'failures',sum(x.get('decoded') is False or x['recorded_hash_match'] is False for x in rows),flush=True) | |
Xet Storage Details
- Size:
- 3.89 kB
- Xet hash:
- 5bf07627f1923e2fd373da5b7f18833d200a6685e3830af7db560fb51898e13b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.