mirror of
https://github.com/notwa/rc
synced 2025-02-05 07:43:22 -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
|
#!/bin/bash
|
||||||
|
set -o nounset
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
tags=$1
|
tags=$1
|
||||||
|
|
||||||
ip="67.202.114.134" # danbooru.donmai.us
|
ip="67.202.114.134" # danbooru.donmai.us
|
||||||
webpage="post/index?tags=$tags&limit=100&page="
|
webpage="post/index?tags=$tags&limit=100&page="
|
||||||
pages=0
|
pages=0
|
||||||
tempfile=`mktemp`
|
tempfile=`mktemp`
|
||||||
|
current=
|
||||||
|
|
||||||
# wget opts: less verbose, no directories, ignore robots.txt, output to stdout
|
term()
|
||||||
# can be replaced with curl
|
{
|
||||||
get='wget -nvd -erobots=off -O-'
|
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
|
page=1
|
||||||
while true; do
|
while true; do
|
||||||
|
@ -17,8 +27,10 @@ while true; do
|
||||||
image_urls=$(grep -oP '(?<=file_url":")([^"]+)' $tempfile)
|
image_urls=$(grep -oP '(?<=file_url":")([^"]+)' $tempfile)
|
||||||
for url in $image_urls; do
|
for url in $image_urls; do
|
||||||
name=$(echo "$url" | cut -d/ -f5)
|
name=$(echo "$url" | cut -d/ -f5)
|
||||||
|
current="$name"
|
||||||
if [ -e "$name" ]; then :
|
if [ -e "$name" ]; then :
|
||||||
else
|
else
|
||||||
|
echo "$name"
|
||||||
$get $url > $name
|
$get $url > $name
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Reference in a new issue