should be done
This commit is contained in:
@ -3,49 +3,57 @@
|
||||
IGREEN="\033[0;92m" # Intense Green
|
||||
IYELLOW="\033[0;93m" # Intense Yellow
|
||||
NO_COLOR="\033[0m" # Text Reset
|
||||
|
||||
# trap interrupt_function INT
|
||||
#
|
||||
# interrupt_function() {
|
||||
# rm -f to_download_*.txt
|
||||
# exit 1
|
||||
# }
|
||||
IN_FILE="$1_generated.txt"
|
||||
SUCCESS_FILE="$1_success.txt"
|
||||
FAIL_FILE="$1_failed.txt"
|
||||
BOOL_SUCCESS=0
|
||||
|
||||
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
|
||||
|
||||
input_file="$1.links"
|
||||
download() {
|
||||
# echo "url: $1"
|
||||
# echo "path: $2"
|
||||
|
||||
if [[ ! -f $input_file ]]; then
|
||||
echo -e "${IYELLOW}$input_file doesn't exist${NO_COLOR}"
|
||||
exit 1
|
||||
for ((n=0;n<5;n++)); do
|
||||
#echo "gallery-dl --config ./gallery-dl/config.json --directory $2 $1"
|
||||
gallery-dl --config ./gallery-dl/config.json --directory "$2" "$1"
|
||||
|
||||
if [ $(echo $?) == 0 ]; then
|
||||
echo "$1" >> "$SUCCESS_FILE"
|
||||
break
|
||||
fi
|
||||
echo -e "${IYELLOW}download failed${NO_COLOR}"
|
||||
|
||||
if [ $(ping -qc 3 v4.ip.hopeless-cloud.xyz > /dev/null 2>&1) != 0 ]; then
|
||||
echo -e "${IYELLOW}no internet${NO_COLOR}"
|
||||
exit 1
|
||||
elif [ $(ping -qc 3 v6.ip.hopeless-cloud.xyz > /dev/null 2>&1) != 0 ]; then
|
||||
echo -e "${IYELLOW}no internet${NO_COLOR}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${IGREEN}has internet${NO_COLOR}"
|
||||
done
|
||||
|
||||
echo "$1" >> "$FAIL_FILE"
|
||||
}
|
||||
|
||||
cargo run -- generate "$1"
|
||||
|
||||
if [[ -f $FAIL_FILE ]]; then
|
||||
[[ -f "${FAIL_FILE}.old" ]] && rm -f "${FAIL_FILE}.old"
|
||||
mv "$FAIL_FILE" "${FAIL_FILE}.old"
|
||||
fi
|
||||
|
||||
cp $input_file to_download_$1.txt
|
||||
while IFS= read -r line; do
|
||||
url=$(echo "$line" | awk '{print $1}')
|
||||
path=$(echo "$line" | awk '{print $3}')
|
||||
|
||||
for ((n=0;n<5;n++)); do
|
||||
gallery-dl --config ./gallery-dl/config.json --input-file-delete to_download_$1.txt
|
||||
download $url $path
|
||||
|
||||
if [ ! -s to_download_$1.txt ]; then
|
||||
echo -e "${IGREEN}file empty${NO_COLOR}"
|
||||
rm to_download_$1.txt
|
||||
break
|
||||
fi
|
||||
echo -e "${IYELLOW}file not empty${NO_COLOR}"
|
||||
exit
|
||||
done < "$IN_FILE"
|
||||
|
||||
if [ $(ping -qc 3 hopeless-cloud.xyz > /dev/null 2>&1) ]; then
|
||||
echo -e "${IYELLOW}no internet${NO_COLOR}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${IGREEN}has internet${NO_COLOR}"
|
||||
done
|
||||
|
||||
# [[ $(hostname) != \s\a\t\a\n ]] && cp ./gallery-dl/archive-${$1,,}.sqlite3 /data/backup
|
||||
|
||||
if [ -s to_download_$1.txt ]; then
|
||||
exit 1
|
||||
# exit with some kind of error
|
||||
# service should then send error and fitting message to ntfy
|
||||
fi
|
||||
[[ $(hostname) != \s\a\t\a\n ]] && cp ./gallery-dl/archive-${$1,,}.sqlite3 /data/backup
|
||||
|
Reference in New Issue
Block a user