kuzyara

x-torrents.org

Nov 10th, 2012
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.19 KB | None | 0 0
  1. #!/bin/bash
  2. #************************************************#
  3. #         автор: [email protected]            #
  4. #                Ноябрь  , 2012                  #
  5. #                                                #
  6. #      Скачиваем 20 фильмов XTO                  #
  7. #            с наиб. кол-м сидов                 #
  8. #************************************************#
  9.  
  10. TR_HOST="x-torrents.org"
  11. TR_USER="Гаечка"
  12. TR_PASSWORD="pirate"
  13. DIR="/media/D/FILMS" #fullpath
  14.  
  15. SC_COOKIE="/tmp/gt-$TR_HOST-$TR_USER.ck"
  16. SC_UA="Mozilla/5.0 (X11; U; Linux x86_64; ru; rv:1.9.2.15) Gecko/20110303 Ubuntu/10.10 (maverick) Firefox/3.6.15"
  17.  
  18.  
  19. if [ -w $SC_COOKIE ]; then
  20.     echo "---Cookie exists. Cheking auth"
  21.     auth_page="`curl -b $SC_COOKIE  -c $SC_COOKIE -A "$SC_UA" $TR_HOST`"
  22. #   echo "$auth_page" > auth_page.html
  23.     result=`echo "$auth_page" | grep -o --max-count=1 "$TR_USER"`
  24. fi
  25. echo "---Username: $result"
  26. sleep 1
  27.  
  28. if [ -z "$result" ]; then
  29.     echo "---Cookie wrong. Makin auth";
  30.     auth_path="http://x-torrents.org/takelogin.php";
  31.     if [ -w $SC_COOKIE ]; then
  32.     cookie_data=`cat $SC_COOKIE`
  33.     curl --trace-ascii - -b $SC_COOKIE  -c $SC_COOKIE -A "$SC_UA" -d "username=$TR_USER" \
  34.         -d "password=$TR_PASSWORD" -d "returnto=/" "$auth_path">/dev/null
  35.     else
  36.     curl --trace-ascii - -c $SC_COOKIE -A "$SC_UA" -d "username=$TR_USER" \
  37.         -d "password=$TR_PASSWORD" -d "returnto=/" "$auth_path">/dev/null
  38.     fi
  39. fi
  40. sleep 1
  41.  
  42. echo "---Authorised. Getting list_id"
  43. tracker_page="`curl  -b $SC_COOKIE -c $SC_COOKIE -A "$SC_UA" "http://x-torrents.org/browse.php?search_method=0&search_in=0&cat=4&genre=0&incldead=0&sort=7&type=desc"`"
  44. echo "$tracker_page" > /tmp/tracker_page.html
  45. list_paths="`echo "$tracker_page" | \
  46.     tr -d "\n" | iconv -t utf8 -f cp1251 | \
  47.     grep -P -o '<td align="left" class="class10" >.*?</td>' | egrep -i "Проверена" | \
  48.     grep -P -o '(?<=class10" ><a href=")[^"]*' | head -n 20`"
  49. echo -e "---Pages_path:\n$list_paths";
  50. if [ -z "$list_paths" ]; then
  51.     echo "--Parsing error!"
  52.     exit
  53. fi
  54.  
  55.  
  56. rm -f $DIR/*.aria2
  57. rm -rf /tmp/*.torrent
  58.  
  59. echo "---Cycle begin"
  60. cd /tmp/ #curl -O /tmp/
  61. for path in $list_paths
  62. do
  63. echo "---Getting page: $path"
  64. torrent_page="`curl -b $SC_COOKIE -A "$SC_UA" "$TR_HOST$path"`"
  65. echo "$torrent_page" > /tmp/torrent_page.html
  66. torrent_path="`echo "$torrent_page" | grep -P -o '(?<=left"><a class="index" href=").*?(?="><font color="#ce0000">)'`"
  67. echo "---Getting .torrent file: $torrent_path"
  68. curl -O -b $SC_COOKIE -A "$SC_UA" "$TR_HOST$torrent_path"
  69. done
  70.  
  71. #loading 2GIS.Irkutsk
  72. #curl -s irkutsk.2gis.ru | grep -P -o "http://download.2gis.ru/arhives/2GISShell.*?\.exe" | xargs wget -cP /mnt/ALL/\!Софт/
  73. #find /mnt/ALL/\!Софт/2GIS* | sort | sed -n 2,+99p | xargs rm -f #delete old versions
  74.  
  75. echo "Delete old torrents"
  76. cat /tmp/*.torrent | \
  77.     grep -aPo "(?<=4:name)[0-9]+:.*?(?=[0-9]+:)" | \
  78.     sed "s/\([0-9]*\):\(.*\)/\2/" > /tmp/newtorrentfiles.txt
  79. ls -t1 "$DIR" > /tmp/torrentfiles.txt
  80. grep -v --file=/tmp/newtorrentfiles.txt /tmp/torrentfiles.txt | \
  81.     while read file; do echo rm -rf "$DIR/$file"; done;
  82.  
  83. #screen -d -m -L
  84. aria2c --no-conf --seed-time=0 --bt-max-peers=5 -V -j20 -d "$DIR" /tmp/*.torrent
Advertisement
Add Comment
Please, Sign In to add comment