Buckets:
| """Resolve Godot executable-prefixed audio-worklet/worker filenames used by locateFile.""" | |
| import os,json,re,hashlib,requests,tempfile | |
| from pathlib import Path | |
| from urllib.parse import urljoin,unquote,urlparse | |
| from huggingface_hub import HfApi | |
| R=Path('/home/user/game-archive/reports');B='smodusermc/offline-games';api=HfApi(token=os.environ['HF_TOKEN']);results=[] | |
| for i in [114,128,129,133,140,165,166]: | |
| mp=R/f'game-{i}.json';m=json.loads(mp.read_text());records={f['path']:f for f in m['files']};html=Path(f'/tmp/large-source-survey/{i}.html').read_text();match=re.search(r'["\']?executable["\']?\s*:\s*["\']([^"\']+)',html) | |
| if not match:continue | |
| exe=match[1];u=urljoin(m['entry'],exe+'.js');response=requests.get(u,timeout=20);response.raise_for_status();js=response.text;probes=[] | |
| for literal,suffix in [('godot.audio.worklet.js','.audio.worklet.js'),('godot.audio.position.worklet.js','.audio.position.worklet.js'),('.worker.js','.worker.js')]: | |
| if literal in js:probes.append(suffix) | |
| for suffix in probes: | |
| url=urljoin(m['entry'],exe+suffix);key='site/'+unquote(urlparse(url).path).lstrip('/');j={'id':i,'path':key,'source_url':url,'discovery':'Executable prefix plus engine locateFile support suffix'} | |
| if key in records:j['status']='already_captured';results.append(j);continue | |
| try: | |
| r=requests.get(url,timeout=20);r.raise_for_status();data=r.content;assert not re.match(br'\s*(?:<!doctype|<html)',data,re.I),'HTML fallback';assert len(data)<8*1024**2;sha=hashlib.sha256(data).hexdigest();api.batch_bucket_files(B,add=[(data,key)]) | |
| with tempfile.TemporaryDirectory(dir='/home/user/.cache') as tmp: | |
| p=Path(tmp)/'support.js';api.download_bucket_files(B,[(key,p)],raise_on_missing_files=True);assert hashlib.file_digest(p.open('rb'),'sha256').hexdigest()==sha | |
| f={'path':key,'url':url,'bytes':len(data),'sha256':sha};records[key]=f;j.update(status='repaired_and_readback_verified',bytes=len(data),sha256=sha) | |
| except Exception as e:j.update(status='source_probe_unavailable',error=str(e)[:180],note='Engine code may contain unused worker/audio alternatives; not by itself proof that all variants are required.') | |
| results.append(j) | |
| m['files']=list(records.values());mp.write_text(json.dumps(m,indent=2));api.batch_bucket_files(B,add=[(mp,f'_reports/games/{i:04d}.json')]) | |
| q=R/'godot-support-repair.json';q.write_text(json.dumps(results,indent=2));api.batch_bucket_files(B,add=[(q,'_verification/godot-support-repair.json')]);print('GODOT SUPPORT',sum(x['status']=='repaired_and_readback_verified' for x in results),'restored',flush=True) | |
Xet Storage Details
- Size:
- 2.57 kB
- Xet hash:
- 1215a619b957c04335b641257e85791f3436196149867b0194bf9955c9f08226
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.