From 715e1edbd63c4115970f3d856bf655f26da61ffe Mon Sep 17 00:00:00 2001 From: AustrianToast Date: Tue, 9 Jul 2024 00:50:33 +0200 Subject: [PATCH] move stuff to dedicated functions --- gallery-dl/rule34.sh | 50 ++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/gallery-dl/rule34.sh b/gallery-dl/rule34.sh index 2da64fb..3f94910 100755 --- a/gallery-dl/rule34.sh +++ b/gallery-dl/rule34.sh @@ -4,27 +4,37 @@ IGREEN="\033[0;92m" # Intense Green IYELLOW="\033[0;93m" # Intense Yellow NO_COLOR="\033[0m" # Text Reset -# for testing only -rm -f ./archive.sqlite3 ./archive-rule34.sqlite3 ./log.txt -rm -rf ./Download/* +setup_test() { + rm -f ./archive.sqlite3 ./archive-rule34.sqlite3 ./log.txt || exit 1 + rm -rf ./Download/* || exit 1 +} -[[ -f downloaded_r34.txt ]] || echo -e "${IYELLOW}no file to download from${NO_COLOR}" || exit 1 -cp downloaded_r34.txt to_download_r34.txt +download() { + while [ 1 ] + do + gallery-dl --config ./config.json --input-file-delete $1 -while [ 1 ] -do - gallery-dl --config ./config.json --input-file-delete to_download_r34.txt + if [ ! -s $1 ]; then + echo -e "${IGREEN}file empty${NO_COLOR}" + rm $1 + exit 0 + fi + echo -e "${IYELLOW}file not empty${NO_COLOR}" - if [ ! -s to_download_r34.txt ]; then - echo -e "${IGREEN}file empty${NO_COLOR}" - rm to_download_r34.txt - exit 0 - fi - echo -e "${IYELLOW}file not empty${NO_COLOR}" + if [ $(ping -qc 3 matrix.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 +} - if [ $(ping -qc 3 rule34.xxx > /dev/null 2>&1) ]; then - echo -e "${IYELLOW}no internet${NO_COLOR}" - exit 1 - fi - echo -e "${IGREEN}has internet${NO_COLOR}" -done +download_r34() { + [[ -f downloaded_r34.txt ]] || echo -e "${IYELLOW}download_r34: no file to download from${NO_COLOR}" || exit 1 + cp downloaded_r34.txt to_download_r34.txt + + download to_download_r34.txt +} + +setup_test +download_r34