Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- uag="Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729)"
- if [ ! -d $1 ]
- then
- echo Creating $1
- mkdir "$1"
- fi
- if [ ! -d $1/new ]
- then
- mkdir "$1/new"
- fi
- echo Entering $1
- cd $1
- if [ -a lastpost.txt ]
- then
- lastpost=$(cat lastpost.txt)
- echo "Last Post ID: $lastpost"
- else
- lastpost=0
- echo "Looks like first run"
- fi
- postcount=`curl -# "http://youhate.us/index.php?page=dapi&s=post&q=index&tags=$1&limit=1"|pcregrep -o 'posts\ count=\"[^"]+'|sed -e 's/posts\ count=//' -e 's/\"//'`
- echo Posts total: $postcount
- rm -f UrlsIds.txt
- let "pcount=postcount/100"
- for ((i=0; i<=$pcount; i++)) do wget "http://youhate.us/index.php?page=dapi&s=post&q=index&tags=$1&limit=100&pid=$i" -U "$uag" -O - |grep -E -o -e 'file_url=[^ ]+' -e ' id=[^ ]+'|sed -e 's/file_url=//g' -e 's/id=//g' -e 's/\"//g' >>UrlsIds.txt
- sed -i ':a;N;$!ba;s/\n / /g' UrlsIds.txt
- done;
- grep -E -o -e ' [^\n]+' UrlsIds.txt |sed -e 's/ //g' > Ids.txt
- linen=0;
- while read LINE; do
- if [ $LINE -lt $lastpost ]
- then
- break
- fi
- let "linen=linen+1"
- done < Ids.txt
- head -n $linen urlsids.txt | sed -r -e 's/ [0-9]+//g' > new/dload.txt
- rm -f UrlsIds.txt
- cd new
- wget -nc -i dload.txt
- rm -f dload.txt
- cd ..
- head -n 1 ids.txt > lastpost.txt
- rm -f ids.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement