Skip to content

Instantly share code, notes, and snippets.

@abixalmon
Last active May 15, 2017 12:41
Show Gist options
  • Save abixalmon/cc6b72f6b89f549aa1bf04758a69a5f6 to your computer and use it in GitHub Desktop.
Save abixalmon/cc6b72f6b89f549aa1bf04758a69a5f6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
$CLIENTID="YOUR_CLIENT_ID"
function reload_tor() {
echo "Reloading Tor"
service tor reload
sleep $[ ( $RANDOM % 5 ) + 20 ]
}
function ann_download() {
local i=$1
echo "Downloading - ${i}.xml"
torsocks curl -s --compressed -H 'User-Agent:' -H 'Host:' "http://api.anidb.net:9001/httpapi?request=anime&client=${CLIENTID}&clientver=1&protover=1&aid=${i}" -o anidb/${i}.xml
}
function show_ip() {
TOR_IP=$(torsocks curl -s 'https://api.ipify.org')
echo "IP: $TOR_IP"
}
function xml_size() {
local i=$1
SIZE=$(du -sb "anidb/${i}.xml" | awk '{ print $1 }')
}
function start_download() {
local i=$1
ann_download ${i}
xml_size ${i}
echo "Done - ${i}.xml : SIZE: ${SIZE}"
}
#reload_tor
show_ip
START_ID=1
END_ID=15000
for (( i=${START_ID}; i<=${END_ID}; i++ ))
do
ANIME_ID=$[ ( $RANDOM ) + 1 ]
while [ ${ANIME_ID} -ge ${END_ID} ]
do
ANIME_ID=$[ ( $RANDOM ) + 1 ]
done
if [ -e anidb/${ANIME_ID}.xml ]; then
xml_size ${ANIME_ID}
if [ ${SIZE} -gt 29 ]; then
echo "Already Downloaded - ${ANIME_ID}.xml : SIZE: ${SIZE}"
continue
fi
fi
start_download ${ANIME_ID}
while [ ${SIZE} -lt 30 ]
do
reload_tor
show_ip
start_download ${ANIME_ID}
done
sleep $[ ( $RANDOM % 4 ) + 1 ]
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment