@echo off
setlocal EnableExtensions EnableDelayedExpansion
chcp 65001 >nul
rem ===== Auto-generated by scripts/gen-pack-installers.mjs — do not edit =====
rem Pack: Artokun Flow — Character Dance / Motion Transfer (WAN Animate 2.2)
rem Run from your ComfyUI root (the folder containing custom_nodes\ and models\).
if not exist "custom_nodes" ( echo [ERROR] Run from your ComfyUI root ^(custom_nodes\ not found^). & pause & exit /b 1 )
where git >nul 2>&1 || ( echo [ERROR] git not found in PATH. & pause & exit /b 1 )
where curl >nul 2>&1 || ( echo [ERROR] curl not found in PATH. & pause & exit /b 1 )
rem Resolve the ComfyUI python: venv first, then portable embed, then PATH python.
set "PY=%CD%\.venv\Scripts\python.exe"
if not exist "%PY%" set "PY=%CD%\venv\Scripts\python.exe"
if not exist "%PY%" set "PY=%CD%\..\python_embeded\python.exe"
if not exist "%PY%" set "PY=python"
echo using python: %PY%

echo -------- custom nodes --------
call :clone "ComfyUI-WanVideoWrapper" "https://github.com/kijai/ComfyUI-WanVideoWrapper"
call :clone "ComfyUI-WanAnimatePreprocess" "https://github.com/kijai/ComfyUI-WanAnimatePreprocess"
call :clone "ComfyUI-KJNodes" "https://github.com/kijai/ComfyUI-KJNodes"
call :clone "ComfyUI-VideoHelperSuite" "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
call :clone "ComfyUI-ReActor" "https://github.com/Gourieff/ComfyUI-ReActor"
call :clone "comfyui-teskors-utils" "https://github.com/artokun/comfyui-teskors-utils"

echo -------- models --------
call :grab "models\diffusion_models\Wan2_2-Animate-14B_fp8_scaled_e4m3fn_KJ_v2.safetensors" "https://huggingface.co/wdsfdsdf/OFMHUB/resolve/main/WanModel.safetensors"
call :grab "models\vae\Wan2_1_VAE_bf16.safetensors" "https://huggingface.co/wdsfdsdf/OFMHUB/resolve/main/vae.safetensors"
call :grab "models\clip_vision\clip_vision_h.safetensors" "https://huggingface.co/wdsfdsdf/OFMHUB/resolve/main/klip_vision.safetensors"
call :grab "models\text_encoders\umt5_xxl_fp8_e4m3fn_scaled.safetensors" "https://huggingface.co/wdsfdsdf/OFMHUB/resolve/main/text_enc.safetensors"
call :grab "models\controlnet\Wan21_Uni3C_controlnet_fp16.safetensors" "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Wan21_Uni3C_controlnet_fp16.safetensors"
call :grab "models\loras\light.safetensors" "https://huggingface.co/wdsfdsdf/OFMHUB/resolve/main/light.safetensors"
call :grab "models\loras\wan.reworked.safetensors" "https://huggingface.co/wdsfdsdf/OFMHUB/resolve/main/wan.reworked.safetensors"
call :grab "models\loras\WanPusa.safetensors" "https://huggingface.co/wdsfdsdf/OFMHUB/resolve/main/WanPusa.safetensors"
call :grab "models\loras\WanFun.reworked.safetensors" "https://huggingface.co/wdsfdsdf/OFMHUB/resolve/main/WanFun.reworked.safetensors"
call :grab "models\detection\vitpose_h_wholebody_model.onnx" "https://huggingface.co/Kijai/vitpose_comfy/resolve/main/onnx/vitpose_h_wholebody_model.onnx"
call :grab "models\detection\vitpose_h_wholebody_data.bin" "https://huggingface.co/Kijai/vitpose_comfy/resolve/main/onnx/vitpose_h_wholebody_data.bin"
call :grab "models\detection\yolov10m.onnx" "https://huggingface.co/onnx-community/yolov10m/resolve/main/onnx/model.onnx"
call :grab "models\insightface\inswapper_128.onnx" "https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/inswapper_128.onnx"
call :grab "models\facerestore_models\GPEN-BFR-512.onnx" "https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/facerestore_models/GPEN-BFR-512.onnx"
call :grab "models\checkpoints\sam3.1_multiplex_fp16.safetensors" "https://huggingface.co/Comfy-Org/sam3.1/resolve/main/checkpoints/sam3.1_multiplex_fp16.safetensors"

echo DONE. Restart ComfyUI, then load workflow.json.
pause
exit /b

:clone
if not exist "custom_nodes\%~1" (
  echo   cloning %~1
  git clone --depth 1 "%~2" "custom_nodes\%~1"
  if exist "custom_nodes\%~1\requirements.txt" ( echo   installing %~1 requirements.txt & "%PY%" -m pip install -r "custom_nodes\%~1\requirements.txt" )
) else ( echo   %~1 present - skip )
goto :eof

:grab
if not exist "%~dp1" mkdir "%~dp1"
if not exist "%~1" ( echo   downloading %~nx1 & curl -L --ssl-no-revoke -o "%~1" "%~2" ) else ( echo   %~nx1 present - skip )
goto :eof
