Last active
March 21, 2024 18:13
-
-
Save unphased/8d1a45e670440587cdfc0274f3bc098d to your computer and use it in GitHub Desktop.
civitai download script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for i in "$@"; do | |
# Forcibly obtain filename via returned header truncated plain get | |
FILENAME=$(curl -s -H "Authorization: Bearer $(cat ~/civitai_apikey.txt)" -i -L --range '0-1' "$i" | grep -a Content-Disposition | sed -n 's/.*filename=["]*\([^"]*\)["]*.*/\1/p') | |
if [ -f "$FILENAME" ]; then | |
echo "!!!! File $FILENAME already exists. Continuing via -L -C - -O \$filename:" | |
curl -L -C - -o $FILENAME --retry 4 -H "Authorization: Bearer $(cat ~/civitai_apikey.txt)" "$i" | |
else | |
echo "========= Downloading into $FILENAME:" | |
curl -JLO --retry 4 -H "Authorization: Bearer $(cat ~/civitai_apikey.txt)" "$i" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment