47 lines
1.4 KiB
Bash
Executable File
47 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/bash
|
|
|
|
IGREEN="\033[0;92m" # Intense Green
|
|
IYELLOW="\033[0;93m" # Intense Yellow
|
|
IRED='\033[0;91m' # Intense Red
|
|
NO_COLOR="\033[0m" # Text Reset
|
|
|
|
[[ -z $1 ]] && exit 1
|
|
|
|
if [[ -z $2 ]]; then
|
|
output=$([[ $(hostname) = \s\a\t\a\n ]] && cargo run -- add_url "$1" || ./Hentai add_url "$1")
|
|
else
|
|
output=$([[ $(hostname) = \s\a\t\a\n ]] && cargo run -- add_custom_name "$1" "$2" || ./Hentai add_custom_name "$1" "$2")
|
|
fi
|
|
|
|
echo "$output"
|
|
[[ $output =~ "#" ]] || exit 1
|
|
|
|
url=$(echo "$output" | awk '{print $1}')
|
|
path=$(echo "$output" | awk '{print $3}')
|
|
|
|
if [[ $(hostname) = \s\a\t\a\n ]]; then
|
|
[[ -d ./Artists ]] || mkdir ./Artists
|
|
rm -rf ./gallery-dl/*.sqlite3 ./gallery-dl/log.txt ./Artists/* || exit 1
|
|
fi
|
|
|
|
echo "command: gallery-dl --config ./gallery-dl/config.json --directory $path $url"
|
|
|
|
for ((n=0;n<5;n++)); do
|
|
if ! gallery-dl --config ./gallery-dl/config.json --directory "$2" "$1"; then
|
|
echo -e "${IGREEN}Success${NO_COLOR}"
|
|
exit 0
|
|
fi
|
|
echo -e "${IYELLOW}download failed${NO_COLOR}"
|
|
|
|
if ! ping -c 3 v4.ip.hopeless-cloud.xyz > /dev/null 2>&1; then
|
|
echo -e "${IRED}no internet${NO_COLOR}"
|
|
exit 1
|
|
fi
|
|
if ! ping -c 3 v6.ip.hopeless-cloud.xyz > /dev/null 2>&1; then
|
|
echo -e "${IRED}no internet${NO_COLOR}"
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "${IGREEN}has internet${NO_COLOR}"
|
|
done
|