Advertisement
SetazeR

GelUpdater

Feb 14th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.28 KB | None | 0 0
  1. #! /bin/bash
  2. 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)"
  3. if [ ! -d $1 ]
  4. then
  5. echo Creating $1
  6. mkdir "$1"
  7. fi
  8. if [ ! -d $1/new ]
  9. then
  10. mkdir "$1/new"
  11. fi
  12. echo Entering $1
  13. cd $1
  14. if [ -a lastpost.txt ]
  15. then
  16. lastpost=$(cat lastpost.txt)
  17. echo "Last Post ID: $lastpost"
  18. else
  19. lastpost=0
  20. echo "Looks like first run"
  21. fi
  22. 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/\"//'`
  23. echo Posts total: $postcount
  24. rm -f UrlsIds.txt
  25. let "pcount=postcount/100"
  26. 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
  27. sed -i ':a;N;$!ba;s/\n / /g' UrlsIds.txt
  28. done;
  29. grep -E -o -e ' [^\n]+' UrlsIds.txt |sed -e 's/ //g' > Ids.txt
  30. linen=0;
  31. while read LINE; do
  32. if [ $LINE -lt $lastpost ]
  33. then
  34. break
  35. fi
  36. let "linen=linen+1"
  37. done < Ids.txt
  38. head -n $linen urlsids.txt | sed -r -e 's/ [0-9]+//g' > new/dload.txt
  39. rm -f UrlsIds.txt
  40. cd new
  41. wget -nc -i dload.txt
  42. rm -f dload.txt
  43. cd ..
  44. head -n 1 ids.txt > lastpost.txt
  45. rm -f ids.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement