Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #### Varliables ####
- NUMBER_OF_PAGES=3600
- #### Directories and file location ####
- TOP_DIR="$HOME/tvtz"
- PAGES_DOWNLOAD="$TOP_DIR/pages"
- PAGES_DELETE="$TOP_DIR/pages_delete"
- COOKIE="$TOP_DIR/cookie.txt"
- ID_LIST="$TOP_DIR/id_list.txt"
- #### Funtions ####
- download_pages ()
- {
- for i in `cat $ID_LIST`;
- do
- if [ $NUMBER_OF_PAGES -lt 1 ]
- then
- exit
- else
- if [ -f $PAGES_DOWNLOAD/$i.html ]
- then
- continue
- else
- curl -o $PAGES_DOWNLOAD/$i.html -b $COOKIE "http://tvtorrentz.org/details.php?id=$i&filelist=1"
- NUMBER_OF_PAGES=$(( NUMBER_OF_PAGES-1 ))
- echo $NUMBER_OF_PAGES
- sleep 8
- continue
- fi
- fi
- done
- }
- delete_pages ()
- {
- mkdir $TOP_DIR/temp/
- for i in `cat $ID_LIST`;
- do
- if [ -f $PAGES_DOWNLOAD/$i.html ]
- then
- mv $PAGES_DOWNLOAD/$i.html $TOP_DIR/temp/
- continue
- fi
- done
- mv -v $PAGES_DOWNLOAD/* $PAGES_DELETE/
- mv $TOP_DIR/temp/* $PAGES_DOWNLOAD/
- rm -R $TOP_DIR/temp/
- }
- #### Program start ####
- #Check directories
- if [ ! -d $TOP_DIR ]
- then
- mkdir -v -p $TOP_DIR
- fi
- if [ ! -d $PAGES_DOWNLOAD ]
- then
- mkdir -v -p $PAGES_DOWNLOAD
- fi
- if [ ! -d $PAGES_DELETE ]
- then
- mkdir -v -p $PAGES_DELETE
- fi
- #Check cookie
- if [ ! -s $COOKIE ]
- then
- if [ -s $HOME/.tvtz/tvtz_cookie.txt ]
- then
- cp -v $HOME/.tvtz/tvtz_cookie.txt $COOKIE
- else
- printf "\nERROR: $COOKIE is empty or does not exist\n"
- exit
- fi
- fi
- #Get ID_LIST
- curl -b $COOKIE "http://tvtorrentz.org/godzilla_api.php?ak=76b4f23b3c4711b3cb1fe4caa1bf4ab5&action=get_torrent_ids" > $ID_LIST
- #Check ID_LIST and run functions
- if [ -s $ID_LIST ]
- then
- download_pages
- delete_pages
- exit
- else
- printf "\nERROR: $ID_LIST is empty or does not exist\n"
- exit
- fi
Add Comment
Please, Sign In to add comment