@echo off
setlocal EnableExtensions EnableDelayedExpansion
chcp 65001 >nul
rem ===== Auto-generated by scripts/gen-pack-installers.mjs — do not edit =====
rem Pack: LTX-2.3 Video
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-GGUF" "https://github.com/city96/ComfyUI-GGUF"
call :clone "rgthree-comfy" "https://github.com/rgthree/rgthree-comfy"
call :clone "ComfyUI-Easy-Use" "https://github.com/yolain/ComfyUI-Easy-Use"
call :clone "ComfyUI-KJNodes" "https://github.com/kijai/ComfyUI-KJNodes"
call :clone "RES4LYF" "https://github.com/ClownsharkBatwing/RES4LYF"
call :clone "ComfyUI-LTXVideo" "https://github.com/Lightricks/ComfyUI-LTXVideo"
call :clone "ComfyUI-Custom-Scripts" "https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
call :clone "ComfyUI-VideoHelperSuite" "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
call :clone "ComfyUI-WanVideoWrapper" "https://github.com/kijai/ComfyUI-WanVideoWrapper"
call :clone "ComfyUI-Impact-Pack" "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
call :clone "Comfyui_TTP_Toolset" "https://github.com/TTPlanetPig/Comfyui_TTP_Toolset"
call :clone "ComfyMath" "https://github.com/evanspearman/ComfyMath"
call :clone "WhatDreamsCost-ComfyUI" "https://github.com/WhatDreamsCost/WhatDreamsCost-ComfyUI"

echo -------- models --------
call :grab "models\text_encoders\ltx-2.3_text_projection_bf16.safetensors" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/ltx-2.3_text_projection_bf16.safetensors?download=true"
call :grab "models\text_encoders\gemma_3_12B_it_fp4_mixed.safetensors" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/gemma_3_12B_it_fp4_mixed.safetensors?download=true"
call :grab "models\vae\LTX23_audio_vae_bf16.safetensors" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/LTX23_audio_vae_bf16.safetensors?download=true"
call :grab "models\vae\LTX23_video_vae_bf16.safetensors" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/LTX23_video_vae_bf16.safetensors?download=true"
call :grab "models\unet\ltx-2.3-22b-dev-Q4_K_S.gguf" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/ltx-2.3-22b-dev-Q4_K_S.gguf?download=true"
call :grab "models\unet\ltx-2.3-22b-dev-Q5_K_S.gguf" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/ltx-2.3-22b-dev-Q5_K_S.gguf?download=true"
call :grab "models\unet\ltx-2.3-22b-dev-Q8_0.gguf" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/ltx-2.3-22b-dev-Q8_0.gguf?download=true"
call :grab "models\latent_upscale_models\ltx-2.3-spatial-upscaler-x2-1.1.safetensors" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/ltx-2.3-spatial-upscaler-x2-1.1.safetensors?download=true"
call :grab "models\loras\ltx-2.3-22b-distilled-lora-384-1.1.safetensors" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/ltx-2.3-22b-distilled-lora-384-1.1.safetensors?download=true"
call :grab "models\loras\ltx-2-19b-ic-lora-detailer.safetensors" "https://huggingface.co/Aitrepreneur/FLX/resolve/main/ltx-2-19b-ic-lora-detailer.safetensors?download=true"

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
