mirror of
https://github.com/notwa/rc
synced 2024-11-05 02:29:06 -08:00
This commit is contained in:
parent
cbca147b0b
commit
cea9e4a42f
1 changed files with 15 additions and 3 deletions
18
danny.sh
18
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
|
||||
|
|
Loading…
Reference in a new issue