#!/usr/bin/env bash # # download_models.sh - fetch the MiniMax H3 model set for the Moxie Multimedia # Loader and place it (renamed) into this node pack's models/ folders. # # Usage (from anywhere - the script targets its own pack directory): # bash custom_nodes/MMnode/download_models.sh # # Files are downloaded to ".part" first and moved into place when # complete, so an interrupted run can be re-run safely (it resumes). # Already-complete files are skipped, so the script is idempotent. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" MODELS_DIR="$SCRIPT_DIR/models" # --------------------------------------------------------------------------- # Model manifest: subdir/filename <- URL # Add the turbo LoRA here once a URL is available, e.g.: # "loras/Moxie-Turbo.safetensors|https://.../Moxie-Turbo.safetensors" # --------------------------------------------------------------------------- MANIFEST=( "diffusion/Moxie-Multimedia.safetensors|https://huggingface.co/WarmBloodAban/Minimax-h3_Singularity/resolve/main/Minimax-h3_Singularity_ref2va_v1.3_Pruned_w4a8.safetensors" "clip/MM-VL.safetensors|https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/text_encoders/qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors" "vae/video_vae.safetensors|https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/vae/minimax_h3_video_vae_int8_convrot.safetensors" "audio_vae/audio_vae.safetensors|https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/vae/minimax_h3_audio_vae_fp32.safetensors" ) # --------------------------------------------------------------------------- # Downloader: curl first (resume via -C -), wget as fallback. # --------------------------------------------------------------------------- curl_supports_retry_all() { # --retry-all-errors exists since curl 7.71.0; compare versions safely. local v v="$(curl --version 2>/dev/null | head -n1 | awk '{print $2}')" [[ "$(printf '%s\n7.71.0\n' "$v" | sort -V | head -n1)" == "7.71.0" ]] } fetch() { local url="$1" output="$2" if command -v curl >/dev/null 2>&1; then local retry_all="" if curl_supports_retry_all; then retry_all="--retry-all-errors" # HuggingFace answers bursts with 429/503 fi curl -L --fail --retry 5 --retry-delay 5 $retry_all \ --connect-timeout 30 -C - -o "$output" "$url" elif command -v wget >/dev/null 2>&1; then wget -c -q --show-progress -O "$output" "$url" else echo "ERROR: neither curl nor wget is installed." >&2 return 1 fi } download_entry() { local entry="$1" local rel="${entry%%|*}" local url="${entry#*|}" local subdir="${rel%%/*}" local filename="${rel#*/}" local target_dir="$MODELS_DIR/$subdir" local target="$target_dir/$filename" local partial="$target.part" if [[ -f "$target" ]]; then echo "[skip] $subdir/$filename already present" return 0 fi mkdir -p "$target_dir" echo "[get ] $subdir/$filename" echo " from $url" if ! fetch "$url" "$partial"; then # A stale/incomplete .part can make resume fail (e.g. HTTP 416 when the # file was already fully fetched but the move never happened). if [[ -f "$partial" ]]; then echo " resume failed - deleting partial and restarting download" rm -f "$partial" fetch "$url" "$partial" else return 1 fi fi mv -f "$partial" "$target" echo "[done] $subdir/$filename ($(du -h "$target" | cut -f1))" } echo "Moxie Multimedia - model downloader" echo " pack models dir: $MODELS_DIR" echo failed=0 for entry in "${MANIFEST[@]}"; do if ! download_entry "$entry"; then echo "ERROR: failed to download $entry" >&2 failed=1 fi done echo if [[ "$failed" -eq 0 ]]; then echo "All models ready:" for entry in "${MANIFEST[@]}"; do local_rel="${entry%%|*}" printf ' %-40s %s\n' "$local_rel" "$(du -h "$MODELS_DIR/$local_rel" 2>/dev/null | cut -f1 || echo missing)" done echo echo "Restart ComfyUI so the loader picks the files up." else echo "Some downloads failed - re-run this script to resume." >&2 exit 1 fi