@echo off
setlocal EnableExtensions EnableDelayedExpansion
chcp 65001 >nul
rem ===== Auto-generated by scripts/gen-pack-installers.mjs — do not edit =====
rem Pack: WAN MultiTalk — audio-driven talking avatar
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.git"
call :clone "ComfyUI-KJNodes" "https://github.com/kijai/ComfyUI-KJNodes.git"
call :clone "ComfyUI-VideoHelperSuite" "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git"
call :clone "audio-separation-nodes-comfyui" "https://github.com/christian-byrne/audio-separation-nodes-comfyui.git"

echo -------- pip (manifest extras) --------
"%PY%" -m pip install "imageio-ffmpeg"

echo -------- models --------
call :grab "models\diffusion_models\Wan2.1_14b_Image_to_Video_480p_GGUF_Q8.gguf" "https://huggingface.co/city96/Wan2.1-I2V-14B-480P-gguf/resolve/main/wan2.1-i2v-14b-480p-Q8_0.gguf"
call :grab "models\diffusion_models\WanVideo_2_1_Multitalk_14B_fp8_e4m3fn.safetensors" "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/WanVideo_2_1_Multitalk_14B_fp8_e4m3fn.safetensors"
call :grab "models\text_encoders\umt5_xxl_fp16.safetensors" "https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/text_encoders/umt5_xxl_fp16.safetensors"
call :grab "models\vae\Wan2_1_VAE_bf16.safetensors" "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Wan2_1_VAE_bf16.safetensors"
call :grab "models\clip_vision\clip_vision_h.safetensors" "https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/clip_vision/clip_vision_h.safetensors"
call :grab "models\loras\Wan21_I2V_14B_lightx2v_cfg_step_distill_lora_rank64.safetensors" "https://huggingface.co/lightx2v/Wan2.1-I2V-14B-480P-StepDistill-CfgDistill-Lightx2v/resolve/main/loras/Wan21_I2V_14B_lightx2v_cfg_step_distill_lora_rank64.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
