SHARE
TWEET

transmission

yuljk Sep 20th, 2019 28 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # port, username, password
  4. SERVER="localhost:9091 --auth user:pass"
  5.  
  6. # use transmission-remote to get torrent list from transmission-remote list
  7. TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d' -e '$d' | awk '{print $1}' | sed -e 's/[^0-9]*//g'`
  8.  
  9. # for each torrent in the list
  10. for TORRENTID in $TORRENTLIST
  11. do
  12.     INFO=$(transmission-remote $SERVER --torrent $TORRENTID --info)
  13.     echo -e "Processing #$TORRENTID - $(echo $INFO | sed -e 's/.*Name: \(.*\) Hash.*/\1/')"
  14.    
  15.     # check if torrent download is completed
  16.     DL_COMPLETED=`echo $INFO | grep "Done: 100%"`
  17.     # check torrents current state is
  18.     STATE_STOPPED=`echo $INFO | grep "State: Seeding\|State: Stopped\|State: Finished\|State: Idle"`
  19.  
  20.     # if the torrent is "Stopped", "Finished", or "Idle after downloading 100%"
  21.     if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then
  22.         echo "Torrent #$TORRENTID is completed. Removing torrent from list."
  23.         transmission-remote $SERVER --torrent $TORRENTID --remove
  24.     else
  25.         echo "Torrent #$TORRENTID is not completed. Ignoring."
  26.     fi
  27. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top