Guest User

rmtorrent

a guest
May 1st, 2013
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # script to check for complete torrents in transmission folder, then remove them and their associated files
  4.  
  5. ###########
  6. # CONFIG #
  7. ###########
  8. # Access Information for Transmission
  9. USERNAME=
  10. PASSWORD=
  11. #Installation directory of transmission
  12. INSTALLPATH="/volume1/@appstore/transmission"
  13. #Host on which transmission runs
  14. HOST=localhost
  15. #Port
  16. PORT=9091
  17.  
  18.  
  19. # use transmission-remote to get torrent list from transmission-remote list
  20. TORRENTLIST=`$INSTALLPATH/bin/transmission-remote $HOST:$PORT --auth=$USERNAME:$PASSWORD --list | awk '{print $1}' | grep '[0-9]'`
  21. # for each torrent in the list
  22. for TORRENTID in $TORRENTLIST
  23. do
  24. echo "* * * * * Operations on torrent ID $TORRENTID starting. * * * * *"
  25.  
  26. # check if torrent download is completed
  27. DL_COMPLETED=`$INSTALLPATH/bin/transmission-remote $HOST:$PORT --auth=$USERNAME:$PASSWORD --torrent $TORRENTID --info | grep "Percent Done: 100%"`
  28.  
  29. # check torrents current state is "Stopped", "Finished", or "Idle"
  30. STATE_STOPPED=`$INSTALLPATH/bin/transmission-remote $HOST:$PORT --auth=$USERNAME:$PASSWORD --torrent $TORRENTID --info | grep "State: Stopped\|Finished\|Idle"`
  31.  
  32. # if the torrent is "Stopped", "Finished", or "Idle" after downloading 100%"
  33. if [ "$DL_COMPLETED" != "" ] && [ "$STATE_STOPPED" != "" ]; then
  34. echo "Torrent #$TORRENTID is completed."
  35. # remove torrent and data from Transmission
  36. echo "Removing torrent from list."
  37. $INSTALLPATH/bin/transmission-remote $HOST:$PORT --auth=$USERNAME:$PASSWORD --torrent $TORRENTID --remove-and-delete
  38. else
  39. echo "Torrent #$TORRENTID is not completed. Ignoring."
  40. fi
  41. echo "* * * * * Operations on torrent ID $TORRENTID completed. * * * * *"
  42.  
  43. done
Advertisement
Add Comment
Please, Sign In to add comment