scripts

misc scripts and tools
git clone git://git.2f30.org/scripts.git
Log | Files | Refs

commit dbcf0944323ba3903fbc72efffac75d86332994d
parent 5218ed32986b0b887b5be030b3a81a7cb9f00ae4
Author: sin <sin@2f30.org>
Date:   Sat Jul  6 15:42:05 +0100

Exit when all links give 404

Diffstat:
4chandownload.sh | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/4chandownload.sh b/4chandownload.sh @@ -15,7 +15,7 @@ pullthread() { wget -O ${tmp} "$1" if [ ! $? -eq 0 ]; then rm ${tmp} ${tmp2} - return + return 1 fi egrep '//images.4chan.org/[a-z0-9]+/src/([0-9]*).(jpg|png|gif)' ${tmp} -o | uniq > ${tmp2} @@ -25,11 +25,14 @@ pullthread() { cat ${tmp} | xargs -P 5 -I _URL_ ${wget_cmd} _URL_ rm ${tmp} ${tmp2} + + return 0 } echo "4chan downloader" while :; do + done=1 for arg in "$@"; do loc=$(echo "$arg" | egrep -o '([0-9]*)$' | sed 's/\.html//g') mkdir -p ${loc} @@ -37,8 +40,15 @@ while :; do echo "Downloading to $loc" pullthread "$arg" + if [ $? -eq 0 ]; then + done=0 + fi cd - &>/dev/null + i=$((i+1)) done + if [ $done -eq 1 ]; then + exit 1 + fi echo "Waiting 30 seconds before next run" sleep 30 done