Advertisement
Guest User

Untitled

a guest
Apr 14th, 2011
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.66 KB | None | 0 0
  1. #!/bin/bash
  2. # tvtget.sh - A script for fetching torrents from TVTorrents.com using the command line. (Requires wget)
  3. # written by Viktor Jackson, January 2011
  4. # Usage: tvtget.sh <infohash>
  5.  
  6. if [ "$#" -lt 1 ]
  7.          then
  8.          echo "# tvtget.sh - A script for fetching torrents from TVTorrents.com using the command line. (Requires wget)
  9. written by Viktor Jackson, January 2011
  10. Usage: tvtget.sh <infohash>"
  11.         exit 0
  12.  
  13. # Check that the infohash is valid (i.e. the right length)
  14. elif [ "${#1}" -ne 40 ]
  15.         then
  16.         echo "Invalid infohash!"
  17.         exit 1
  18. else
  19.  
  20. ### Variables ###
  21. TVT_DIGEST= # Your TVT digest key, for identification when downloading the torrent file
  22. 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=")
  23. TVT_TORRENTDIR=~/dl/tvt # Your torrent client's watch directory
  24. COOKIEFILE=$XDG_DATA_HOME/luakit/cookies.txt # Your plaintext cookie file, for connecting to TVT
  25. #################
  26.  
  27. # Make sure the tempdir exists
  28. mkdir -p $XDG_DATA_HOME/tvtget
  29.  
  30. # Quietly grab the torrent page to find the hash of the torrent
  31. wget -q --cookies=on --load-cookies=$COOKIEFILE -O $XDG_DATA_HOME/tvtget/tmp http://tvtorrents.com/loggedin/torrent.do?info_hash=$TVT_INFOHASH
  32. TVT_HASH=`grep -m 1 hash $XDG_DATA_HOME/tvtget/tmp | cut -d\' -f2`
  33.  
  34. # Change to the torrent directory amd grab the torrent file
  35. cd $TVT_TORRENTDIR
  36. WGETOUT=$(wget -nv --content-disposition=on http://torrent.tvtorrents.com/FetchTorrentServlet?digest=$TVT_DIGEST\&info_hash=$TVT_INFOHASH\&hash=$TVT_HASH 2>&1)
  37.  
  38. # Check wget exit status
  39. if [ "$?" -ne 0 ]
  40. then
  41. echo "ERROR! -> $WGETOUT"
  42. exit 1
  43. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement