commit cbca147b0b229d7ec54f90e7732c9e3289018a76 Author: notwa Date: Sun Aug 19 01:43:15 2012 -0700 diff --git a/danny.sh b/danny.sh new file mode 100644 index 0000000..9c4d5ff --- /dev/null +++ b/danny.sh @@ -0,0 +1,39 @@ +#!/bin/bash +tags=$1 + +ip="67.202.114.134" # danbooru.donmai.us +webpage="post/index?tags=$tags&limit=100&page=" +pages=0 +tempfile=`mktemp` + +# wget opts: less verbose, no directories, ignore robots.txt, output to stdout +# can be replaced with curl +get='wget -nvd -erobots=off -O-' + +page=1 +while true; do + $get "http://$ip/${webpage}${page}" > "$tempfile" + + image_urls=$(grep -oP '(?<=file_url":")([^"]+)' $tempfile) + for url in $image_urls; do + name=$(echo "$url" | cut -d/ -f5) + if [ -e "$name" ]; then : + else + $get $url > $name + fi + done + + if (("$pages" == "0")); then + # first iteration, discover pagecount + pages=$(grep -oPm1 \ + '(?<=>)\d+(?= >>)' \ + $tempfile) + pages=${pages:-1} + echo $pages + fi + + let page++ + if (("$page" > "$pages")); then break; fi +done + +rm $tempfile