#!/bin/bash
# first known torrent
first=31630
# last known torrent when script was written (check at www.nyaa.eu)
last=291004
i=$first
while [ $i -le $last ] 
do  
wget -T 10 --retry-connrefused --random-wait -U "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2" -O "work.html" "http://www.nyaa.eu/?page=torrentinfo&tid=$i"
id=$i
seed=`cat work.html | grep -o -m1 -E 'tinfosn">[^[:space:]]*</span' | sed -e 's/tinfosn">//' | sed -e 's/<\/span//'`
leech=`cat work.html | grep -o -m1 -E 'tinfoln">[^[:space:]]*</span' | sed -e 's/tinfoln">//' | sed -e 's/<\/span//'`

if (( $seed >= 0 )); then
 wget --spider "http://website/livid-nyaa/add.php?p=password&id=$id&s=$seed&l=$leech"
 echo "$i" >> id.txt
fi
rm "work.html"
let i=1+$i
done
