From 530a07d5d319ede3c64c6ed350586c9921323cf9 Mon Sep 17 00:00:00 2001 From: AustrianToast Date: Sun, 20 Apr 2025 23:58:26 +0200 Subject: [PATCH] make use of config for customisability --- Hentai.conf | 5 +++++ download_website.sh | 39 +++++++++++++-------------------------- 2 files changed, 18 insertions(+), 26 deletions(-) create mode 100644 Hentai.conf diff --git a/Hentai.conf b/Hentai.conf new file mode 100644 index 0000000..83e54d9 --- /dev/null +++ b/Hentai.conf @@ -0,0 +1,5 @@ +# Config for Hentai + +log_dir="$HOME/.cache/Hentai" +tmp_dir="/tmp" + diff --git a/download_website.sh b/download_website.sh index 040aed7..37d733f 100755 --- a/download_website.sh +++ b/download_website.sh @@ -1,28 +1,27 @@ #!/usr/bin/bash +source "$HOME"/.config/Hentai.conf + 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" + +IN_FILE="${tmp_dir}/${1}_generated.txt" +SUCCESS_FILE="${log_dir}/${1}_success.txt" +FAIL_FILE="${log_dir}/${1}_failed.txt" download() { - SUCCESS="false" - for ((n=0;n<5;n++)); do if [[ $1 =~ "iwara.tv" ]]; then if yt-dlp --config-locations ./yt-dlp/iwara.conf -o "${2}/%(id)s.%(ext)s" "$1"; then echo "$1" >> "$SUCCESS_FILE" - SUCCESS="true" - break + return 0 fi else if gallery-dl --config ./gallery-dl/config.json --directory "$2" "$1"; then echo "$1" >> "$SUCCESS_FILE" - SUCCESS="true" - break + return 0 fi fi echo -e "${IYELLOW}download failed${NO_COLOR}" @@ -38,26 +37,14 @@ download() { fi done - [[ $SUCCESS != \t\r\u\e ]] && echo "$1" >> "$FAIL_FILE" + echo "$1" >> "$FAIL_FILE" } -if [[ -f $FAIL_FILE ]]; then - [[ -f "${FAIL_FILE}.old" ]] && rm -f "${FAIL_FILE}.old" - mv "$FAIL_FILE" "${FAIL_FILE}.old" -fi +[[ -z $2 ]] && exit 1 +Hentai generate "$1" "$tmp_dir" || exit 1 -if [[ -f $SUCCESS_FILE ]]; then - [[ -f "${SUCCESS_FILE}.old" ]] && rm -f "${SUCCESS_FILE}.old" - mv "$SUCCESS_FILE" "${SUCCESS_FILE}.old" -fi - -[[ -f $IN_FILE ]] && rm $IN_FILE -Hentai generate "$1" - -if [[ $(echo $?) -ne 0 ]]; then - echo -e "${IRED}Hentai failed to execute properly${NO_COLOR}" - exit 1 -fi +[[ -f $FAIL_FILE ]] && rm -f "$FAIL_FILE" +[[ -f $SUCCESS_FILE ]] && rm -f "$SUCCESS_FILE" while IFS= read -r line; do url=$(awk '{print $1}' <<< "$line")