"""One-shot: mirror the H3 nsfw LoRAs from civitai to HF (token-gated files).""" import os import time import urllib.request from huggingface_hub import HfApi REPO = "nikdevs/minimax-h3-loras" TOKEN = os.environ["CIVITAI_TOKEN"] FILES = { # HMPussy v0.5 — both files needed together "hmpussy/vagassist_e40.safetensors": "https://civitai.com/api/download/models/3215304?type=Model&format=SafeTensor&fileId=3097094", "hmpussy/hmpussy_v6_epoch30.safetensors": "https://civitai.com/api/download/models/3215304?type=Model&format=SafeTensor&fileId=3097100", # H3 Riding POV i2v v1.0 (the H3 one, NOT the LTXV versions) "riding/riding_pose_H3_i2v_v1.0.safetensors": "https://civitai.com/api/download/models/3203205?fileId=3084588", } api = HfApi() api.create_repo(REPO, exist_ok=True, private=False) existing = {s.rfilename for s in api.repo_info(REPO).siblings} for name, url in FILES.items(): if name in existing: print(f"[skip] {name}", flush=True) continue t0 = time.time() print(f"[dl] {name}", flush=True) req = urllib.request.Request(url + f"&token={TOKEN}", headers={"User-Agent": "Mozilla/5.0"}) local = "/tmp/" + name.split("/")[-1] with urllib.request.urlopen(req, timeout=600) as r, open(local, "wb") as f: while chunk := r.read(1 << 22): f.write(chunk) print(f"[dl] {os.path.getsize(local)//1_000_000}MB in {time.time()-t0:.0f}s, uploading", flush=True) api.upload_file(path_or_fileobj=local, path_in_repo=name, repo_id=REPO) os.remove(local) print(f"[up] {name} done", flush=True) print("H3 LORA MIRROR DONE", flush=True) time.sleep(10 ** 6)