Forum
  • Search
  • Member List
  • Calendar
Hello There, Guest! Login Register — Login with Facebook

Remove finished torrent script (transmission)
Thank you for your donation

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode | Linear Mode
Remove finished torrent script (transmission)
25th Feb, 2015, 12:47 AM
Post: #1
Ragman Offline
Registered
Posts: 7
Joined: Feb 2015
Reputation: 0
Remove finished torrent script (transmission)
Fellow Xbianians,

I'm searching for a script that removes finished torrents from transmission. I came across some but they are for different devices.

script 1 (Click to View)
#!/bin/sh

# the folder to move completed downloads to

# port, username, password
SERVER="9091 --auth transmission:transmission"

# use transmission-remote to get torrent list from transmission-remote list
# use sed to delete first / last line of output, and remove leading spaces
# use cut to get first field from each line
TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=" " --fields=1`

transmission-remote $SERVER --list

# for each torrent in the list
for TORRENTID in $TORRENTLIST
do
echo Processing : $TORRENTID

# check if torrent download is completed
DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "Percent Done: 100%"`

# check torrents current state is
STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"`
echo $STATE_STOPPED

# if the torrent is "Stopped", "Finished", or "Idle after downloading 100%"
if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then
# move the files and remove the torrent from Transmission
echo "Torrent #$TORRENTID is completed"
echo "Removing torrent from list"
transmission-remote $SERVER --torrent $TORRENTID --remove
else
echo "Torrent #$TORRENTID is not completed. Ignoring."
fi
done
and this (Click to View)
#!/bin/bash
/usr/bin/transmission-remote 127.0.0.1:9091 -l | grep 100% | awk '{print $1}' | xargs -n 1 -I % /usr/bin/transmission-remote 127.0.0.1:9091 -t % -r
I was wondering if anyone got this to work on the xbian setup. I'm a bit o a linux & scripting noob just started digging in last week. it might be that "transmission-remote" doesn't get found in this? but what do i know...[/term]

I know your gonna say "just use rtorrent!" but i installed koper89's package and is doesn't communicate with SR or CP. I tried changing the socket stuff to ports, per directions in the thread, but this didn't help rutorrent just couldn't find rtorrent anymore.

If anyone has any directions on either one, it would be much apreciated.

Cheers,
Ragman
Find all posts by this user
Quote this message in a reply
25th Feb, 2015, 02:05 AM
Post: #2
Ragman Offline
Registered
Posts: 7
Joined: Feb 2015
Reputation: 0
RE: Remove finished torrent script (transmission)
So i've been searching around and tinkered a bit.
this is what i came up with:

Code:
#!/bin/bash
PORT="Your_Port"
USER="Your_Login"
PASS="Your_Password"

transmission-remote $PORT --auth $USER:$PASS  --torrent $TR_TORRENT_ID --remove

I read somewhere that the script that runs on_Done get fed the torrent var's. so $TR_TORRENT_ID should get the ID from the torrent that triggered the script.
Find all posts by this user
Quote this message in a reply
25th Feb, 2015, 03:22 AM
Post: #3
Ragman Offline
Registered
Posts: 7
Joined: Feb 2015
Reputation: 0
RE: Remove finished torrent script (transmission)
Been trying this out but no sigar...

Is there anyway to check if the script is even ran? checked for a log fil but there doesn't seem to be one

k made some changes to get a log going to see if the scrip starts.

Code:
#!/bin/bash

echo Testing Download finished Deleting $TR_TORRENT_NAME >> /home/xbian/NewTorrents.log
transmission-remote 9091 --auth xbian:raspberry  --torrent $TR_TORRENT_ID --remove

if i run the script in terminal it adds a line to the log file. but nothing comes up when a torrent finishes.

I checked the settings... its set to true and the path is /home/xbian/t-clean.sh
Find all posts by this user
Quote this message in a reply
25th Feb, 2015, 04:38 AM
Post: #4
Ragman Offline
Registered
Posts: 7
Joined: Feb 2015
Reputation: 0
RE: Remove finished torrent script (transmission)
Ha! i got it figured.

*I've stopped the transmission service in putty through the xbian GUI.

* Next i've made this script and put it into /home/xbian/t-clean.sh

Code:
#!/bin/bash
PORT="Your_Port"
USER="Your_Login"
PASS="Your_Password"

transmission-remote $PORT --auth $USER:$PASS  --torrent $TR_TORRENT_ID --remove
done

* next i've edit the /etc/transmission/settings.json

Code:
"script-torrent-done-enabled": true,
    "script-torrent-done-filename": "/home/xbian/t-clean.sh",

* Start Transmission again in the Xbian GUI

now it seems to works like a charm.
The longer script in my first post also works. Seems like i just needed to stop transmission before editing the files.

Cheers, thnx for the forum space to set up my trail of thoughed. ;P
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 11th May, 2025, 08:34 AM Powered By MyBB, © 2002-2025 MyBB Group.