1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-18 17:53:23 -07:00
This commit is contained in:
notwa 2012-08-19 02:48:06 -07:00
parent cbca147b0b
commit cea9e4a42f

View File

@ -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