Transfer torrents from deluge to rtorrent on completion

Suggest, post, or discuss plugins for Deluge
Post Reply
Sykness

Transfer torrents from deluge to rtorrent on completion

Post by Sykness »

Hello I'm trying to muddle my way through a guide that was posted here in 2012 but cant get the script to work.

Basic disclaimer: I have no idea what I'm doing :o

I basically want to leech in deluge until completion, then transfer the torrent to rtorrent to seed for long term.
I'm trying to use the Execute Plugin to run a script upon torrent completion

So as a dirty workaround I've cut up the script and have everything working except removing the torrent from deluge.

the script currently looks like this:

Code: Select all

#!/bin/bash
####################################################################
###             Please fill in the variables below!              ###
####################################################################

# Where do your torrents eventually download to? If they auto-move
# please specify that directory. Do *NOT* include trailing slash.
path1=/path/to/downloads/
path2=/path/to/downloads/tv/
path3=/path/to/downloads/movies/
path4=/path/to/downloads/music/
path5=/path/to/downloads/other/

# rTorrent's watch folders for deluge exported torrents. Please include trailing slash.
#watch=$HOME/torrents/watchr/
watch1=/path/to/watch/rtorrent
watch2=/path/to/watch/rtorrent/tv
watch3=/path/to/watch/rtorrent/movies
watch4=/path/to/watch/rtorrent/music
watch5=/path/to/watch/rtorrent/other

# Do not change this unless you have knowingly changed Deluge's
# state folder.
files=/path/to/deluge/state

if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
        torrentid=$1
        torrentname=$2
        torrentpath=$3

        if [ "$torrentpath" = "$path1" ]; then
                watch=$watch1
        elif [ "$torrentpath" = "$path2" ]; then
                watch=$watch2
        elif [ "$torrentpath" = "$path3" ]; then
                watch=$watch3
        elif [ "$torrentpath" = "$path4" ]; then
                watch=$watch4
        elif [ "$torrentpath" = "$path5" ]; then
                watch=$watch5
        else
                echo "Not Found"
                exit 2
        fi
 
        cp $files/$torrentid.torrent /path/to/tempworking
        sleep 10
        mv /path/to/tempworking/$torrentid.torrent $watch
To remove the torrent from deluge I found this:

Code: Select all

#!/bin/bash
#get list of torrents
sleep 5

from deluge.ui.client import sclient

sclient.set_core_uri()

torrent_ids = sclient.get_session_state()
for id in torrent_ids:
        t_state = str(sclient.get_torrent_status(id, ['state']).values())[2:-2]
                t_id = [id]
                        seed = "Seeding"
                                if t_state == seed:
                                                sclient.remove_torrent(t_id, False)
I first put this at the end of the first script but it removed the torrent before the other parts of the script could work.
I tried the Auto Remove plugins but they wont remove the torrent as soon as it starts seeding and I dont want to seed from both deluge and rtorrent at the same time.

Can you help me please?
Post Reply