some changes

This commit is contained in:
2024-12-08 15:22:34 +01:00
parent befa59c03d
commit 712f30440b

View File

@ -2,60 +2,68 @@
IGREEN="\033[0;92m" # Intense Green
IYELLOW="\033[0;93m" # Intense Yellow
IRED='\033[0;91m' # Intense Red
NO_COLOR="\033[0m" # Text Reset
IN_FILE="$1_generated.txt"
SUCCESS_FILE="$1_success.txt"
FAIL_FILE="$1_failed.txt"
SUCCESS="false"
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
download() {
# echo "url: $1"
# echo "path: $2"
SUCCESS="false"
for ((n=0;n<5;n++)); do
gallery-dl --config ./gallery-dl/config.json --directory "$2" "$1"
if [ $(echo $?) == 0 ]; then
if [[ $(echo $?) -eq 0 ]]; then
echo "$1" >> "$SUCCESS_FILE"
$SUCCESS="true"
SUCCESS="true"
break
fi
echo -e "${IYELLOW}download failed${NO_COLOR}"
if [ $(ping -qc 3 v4.ip.hopeless-cloud.xyz > /dev/null 2>&1) != 0 ]; then
if [[ $(ping -qc 3 v4.ip.hopeless-cloud.xyz > /dev/null 2>&1) -ne 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
elif [[ $(ping -qc 3 v6.ip.hopeless-cloud.xyz > /dev/null 2>&1) -ne 0 ]]; then
echo -e "${IYELLOW}no internet${NO_COLOR}"
exit 1
fi
echo -e "${IGREEN}has internet${NO_COLOR}"
done
if [ $SUCCESS != \t\r\u\e ]; then
echo "$1" >> "$FAIL_FILE"
fi
[[ $SUCCESS != \t\r\u\e ]] && echo "$1" >> "$FAIL_FILE"
}
cargo run -- generate "$1"
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
if [[ -f $FAIL_FILE ]]; then
[[ -f "${FAIL_FILE}.old" ]] && rm -f "${FAIL_FILE}.old"
mv "$FAIL_FILE" "${FAIL_FILE}.old"
fi
if [[ -f $SUCCESS_FILE ]]; then
[[ -f "${SUCCESS_FILE}.old" ]] && rm -f "${SUCCESS_FILE}.old"
mv "$SUCCESS_FILE" "${SUCCESS_FILE}.old"
fi
[[ $(hostname) = \s\a\t\a\n ]] && cargo run -- generate "$1" || ./Hentai generate "$1"
if [[ $(echo $?) -ne 0 ]]; then
echo -e "${IRED}Hentai failed to execute properly${NO_COLOR}"
exit 1
fi
while IFS= read -r line; do
url=$(echo "$line" | awk '{print $1}')
path=$(echo "$line" | awk '{print $3}')
echo "url: $url"
echo "path: $path"
download $url $path
done < "$IN_FILE"
# [[ -s $FAIL_FILE ]] && curl -d 'bruh' ntfy.hopeless-cloud.xyz/Hentai
[[ $(hostname) != \s\a\t\a\n ]] && cp ./gallery-dl/archive-${1,,}.sqlite3 /data/backup