Page 1 of 1

Script to Remove Torrent After Finished Download

Posted: Sat May 23, 2009 12:56 am
by markymark
Hi Everyone,

I thought I would post this script I put together to suit my needs.
Where I am based bandwidth costs quite a bit so after I have downloaded a torrent I want to remove the torrent straight away.
I share at a good rate while I am leeching but then don't want to let it seed for too long after that.
Anyway if anyone wants something like that I have put together a python script (others may want to update it as I'm not an experienced python coder).

Code: Select all

#get list of torrents
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)
Basically just save the script to xxx.py then setup a cron job to run the script every 5min or so.
When it detects that a torrent is seeding it will remove the torrent from the manager.

Hope it's useful to someone else.

Re: Script to Remove Torrent After Finished Download

Posted: Sat May 23, 2009 3:16 am
by johnnyg
There's an auto-remove already in deluge for when the torrent reaches a certain ratio.
Surely that would be better as you ensure you're seeding to a certain ratio?

Re: Script to Remove Torrent After Finished Download

Posted: Sat May 23, 2009 9:10 am
by markymark
Yes I'm aware of that feature, however I wanted it to finish not long after the download has finished, irrespective to the ratio.
While some people might see that as not being very "generous", it is what my situation requires (as mentioned earlier).
I just download from public torrent sites that don't require a sharing ratio.

Anyway take it or leave it I thought I would let others decide.
Appreciate all the hard work that goes into making deluge what it is :D

Re: Script to Remove Torrent After Finished Download

Posted: Wed May 27, 2009 1:47 am
by silverdulcet
You can obtain part of the functionality your after without even running a script by setting the "Total active seeding:" to 0. This is under the Queue options of the Peferences menu. Once the torrent has completed downloading it will be Paused/Queued since you do not allow any torrents to seed. This does not stop the seeding that goes on while you are in the process of downloading the torrent. You'd still have to manually remove the completed torrents when they finish.

Re: Script to Remove Torrent After Finished Download

Posted: Thu Jun 03, 2010 1:19 pm
by jackobean
On a slightly different note, I have a script for moving torrents that have been removed from deluge to a new directory. It looks for files in the save dir that are no-longer referenced by deluge and moves them to a directory of your choosing. PM me if you are interested.

j

Re: Script to Remove Torrent After Finished Download

Posted: Sat Oct 16, 2010 12:53 pm
by akuiraz
unfortunately, this script no longer works using the latest API from the new release, 1.3.0... sclient is no longer used, although client is available...

any chance someone could update this scripts code for use with the latest Deluge API 1.3.0?

thanks

Re: Script to Remove Torrent After Finished Download

Posted: Sun Apr 08, 2012 9:58 am
by StormPooper
I know this is an old post, but just so you know, if you set 'Stop seed ratio' to 0 and tick 'Remove at ratio', it will delete the torrent as soon as it's finished. You can set this per torrent (as I do, for a very specific case), or globally, under 'Queue' in Options.