From cea9e4a42f786a700ac1c855ddbb59ae843ee158 Mon Sep 17 00:00:00 2001 From: notwa Date: Sun, 19 Aug 2012 02:48:06 -0700 Subject: [PATCH] --- danny.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/danny.sh b/danny.sh index 9c4d5ff..e7ee4a2 100644 --- a/danny.sh +++ b/danny.sh @@ -1,14 +1,24 @@ #!/bin/bash +set -o nounset +set -o errexit + tags=$1 ip="67.202.114.134" # danbooru.donmai.us webpage="post/index?tags=$tags&limit=100&page=" pages=0 tempfile=`mktemp` +current= -# wget opts: less verbose, no directories, ignore robots.txt, output to stdout -# can be replaced with curl -get='wget -nvd -erobots=off -O-' +term() +{ + rm $current # don't leave it incomplete so it may be redownloaded + exit 1 +} +trap 'term' TERM INT + +get='wget -q -erobots=off -O-' # mimic curl +#get='curl' page=1 while true; do @@ -17,8 +27,10 @@ while true; do image_urls=$(grep -oP '(?<=file_url":")([^"]+)' $tempfile) for url in $image_urls; do name=$(echo "$url" | cut -d/ -f5) + current="$name" if [ -e "$name" ]; then : else + echo "$name" $get $url > $name fi done