import hashlib,json,sys from pathlib import Path from huggingface_hub import hf_hub_download root=Path(sys.argv[1]);assets=json.loads(Path(sys.argv[2]).read_text()) for a in assets: cache=root/'source/checkpoints' if a['repo'] in ('openai/whisper-small','nvidia/bigvgan_v2_44khz_128band_512x'):cache=cache/'hf_cache' p=Path(hf_hub_download(a['repo'],a['file'],revision=a['revision'],cache_dir=str(cache))) if p.stat().st_size!=a['bytes'] or hashlib.file_digest(p.open('rb'),'sha256').hexdigest()!=a['sha256']:raise RuntimeError('Hashprüfung fehlgeschlagen: '+a['file']) ref=cache/('models--'+a['repo'].replace('/','--'))/'refs/main';ref.parent.mkdir(parents=True,exist_ok=True);ref.write_text(a['revision'])