Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # tvtget.sh - A script for fetching torrents from TVTorrents.com using the command line. (Requires wget)
- # written by Viktor Jackson, January 2011
- # Usage: tvtget.sh <infohash>
- if [ "$#" -lt 1 ]
- then
- echo "# tvtget.sh - A script for fetching torrents from TVTorrents.com using the command line. (Requires wget)
- written by Viktor Jackson, January 2011
- Usage: tvtget.sh <infohash>"
- exit 0
- # Check that the infohash is valid (i.e. the right length)
- elif [ "${#1}" -ne 40 ]
- then
- echo "Invalid infohash!"
- exit 1
- else
- ### Variables ###
- TVT_DIGEST= # Your TVT digest key, for identification when downloading the torrent file
- TVT_INFOHASH=$1 # The id of the torrent you wish to download (found in the url of the torrent page on TVT, after "?info_hash=")
- TVT_TORRENTDIR=~/dl/tvt # Your torrent client's watch directory
- COOKIEFILE=$XDG_DATA_HOME/luakit/cookies.txt # Your plaintext cookie file, for connecting to TVT
- #################
- # Make sure the tempdir exists
- mkdir -p $XDG_DATA_HOME/tvtget
- # Quietly grab the torrent page to find the hash of the torrent
- wget -q --cookies=on --load-cookies=$COOKIEFILE -O $XDG_DATA_HOME/tvtget/tmp http://tvtorrents.com/loggedin/torrent.do?info_hash=$TVT_INFOHASH
- TVT_HASH=`grep -m 1 hash $XDG_DATA_HOME/tvtget/tmp | cut -d\' -f2`
- # Change to the torrent directory amd grab the torrent file
- cd $TVT_TORRENTDIR
- WGETOUT=$(wget -nv --content-disposition=on http://torrent.tvtorrents.com/FetchTorrentServlet?digest=$TVT_DIGEST\&info_hash=$TVT_INFOHASH\&hash=$TVT_HASH 2>&1)
- # Check wget exit status
- if [ "$?" -ne 0 ]
- then
- echo "ERROR! -> $WGETOUT"
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement