Skip to content

Instantly share code, notes, and snippets.

@yunginnanet
Last active April 4, 2025 02:58
Show Gist options
  • Save yunginnanet/1de4976733f347459b81fcc7deb9f70f to your computer and use it in GitHub Desktop.
Save yunginnanet/1de4976733f347459b81fcc7deb9f70f to your computer and use it in GitHub Desktop.
download civitai model from direct dl link
#!/bin/bash
# - - - - -
webui="/media/3crip/ML/stable-diffusion-webui/models"
comfy="/media/kayos/crucial/crip/Workshop/ComfyUI/models"
# - - - - -
set -e
if [[ -z "$1" ]]; then
echo -e "\e[0;33m[\e[1;31mx\e[0;33m]\e[0m need civitai download URL"
exit 1
fi
_url="$1"
_sub1="$2"
if [[ -z "$_sub1" ]]; then _sub1="Stable-diffusion"; fi
_sub2="$3"
if [[ -z "$_sub2" ]]; then _sub2="checkpoints"; fi
_ckpt="$(echo "${_url}" | awk -F '/' '{print $6}' | awk -F '?' '{print $1}' | sed 's|\.....\.safetensors|.safetensors|g')"
_target1="${webui}/${_sub1}/${_ckpt}"
_target2="${comfy}/${_sub2}/${_ckpt}"
function req() {
toilet --version 2>&1 || return 1
tte --version 2>&1 || return 1
}
if req >/dev/null; then
echo "${_ckpt}" | toilet -t -f fig.smblock | tte wipe
else
echo -e "\e[0;33m[\e[0;32m+\e[0;33m]\e[0m downloading ${_ckpt}"
fi
echo -e "\e[90m --> '${_target1}'\e[0m"
echo -e "\e[90m --+ '${_target2}'\e[0m"
curl -C - -o "${_target1}" "${_url}"
ln -v -s "${_target1}" "${_target2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment