jollygamer321

download_full_db.sh 2

Nov 9th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.45 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #### Varliables ####
  4. NUMBER_OF_PAGES=3600
  5.  
  6.  
  7. #### Directories and file location ####
  8. COOKIE="$HOME/tvtz/cookie.txt"
  9. PAGES_DOWNLOAD="$HOME/tvtz/pages"
  10. ID_LIST="$HOME/tvtz/id_list"
  11.  
  12.  
  13. #### Funtions ####
  14. download_pages ()
  15. {
  16.     for i in `cat $ID_LIST`;
  17.     do
  18.         if [ $NUMBER_OF_PAGES -lt 1 ]
  19.         then
  20.             exit
  21.         else
  22.             if [ -f $PAGES_DOWNLOAD/$i.html ]
  23.             then
  24.                 continue
  25.             else
  26.                 curl -o $PAGES_DOWNLOAD/$i.html -b $COOKIE "http://tvtorrentz.org/details.php?id=$i&filelist=1"
  27.                 NUMBER_OF_PAGES=$(( NUMBER_OF_PAGES-1 ))
  28.                 echo $NUMBER_OF_PAGES
  29.                 sleep 8
  30.                 continue
  31.             fi
  32.         fi
  33.     done
  34. }
  35.  
  36. delete_pages ()
  37. {
  38.     mkdir ~/tvtz/temp/
  39.  
  40.     for i in `cat ~/tvtz/id_list`;
  41.     do
  42.         if [ -f ~/tvtz/pages/$i.html ]
  43.         then
  44.             mv ~/tvtz/pages/$i.html ~/tvtz/temp/
  45.             continue
  46.         fi
  47.     done
  48.  
  49.     mv ~/tvtz/pages/* ~/tvtz/pages_deleted
  50.     mv ~/tvtz/temp/* ~/tvtz/pages/
  51.     rm -R ~/tvtz/temp/
  52. }
  53.  
  54.  
  55. #### Program start ####
  56.  
  57. #Check cookie
  58. if [ -s $COOKIE ]
  59. then
  60.     continue
  61. else
  62.     if [ -s $HOME/.tvtz/tvtz_cookie.txt ]
  63.     then
  64.         cp $HOME/.tvtz/tvtz_cookie.txt $COOKIE
  65.         continue
  66.     else
  67.         printf "\nERROR: $COOKIE is empty or does not exist\n"
  68.         exit
  69.     fi
  70.     continue
  71. fi
  72.    
  73. curl -b $COOKIE "http://tvtorrentz.org/godzilla_api.php?ak=76b4f23b3c4711b3cb1fe4caa1bf4ab5&action=get_torrent_ids" > ~/tvtz/id_list
  74. if [ -s $ID_LIST ]
  75. then
  76.     download_pages
  77.     delete_pages
  78.     exit
  79. else
  80.     printf "\nERROR: $ID_LIST is empty or does not exist\n"
  81.     exit
  82. fi
  83.  
Add Comment
Please, Sign In to add comment