Script to Remove Torrent After Finished Download

Suggestions and discussion of future versions
Locked
markymark

Script to Remove Torrent After Finished Download

Post 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.
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: Script to Remove Torrent After Finished Download

Post 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?
markymark

Re: Script to Remove Torrent After Finished Download

Post 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
User avatar
silverdulcet
Member
Member
Posts: 41
Joined: Sat Jul 21, 2007 6:48 am
Contact:

Re: Script to Remove Torrent After Finished Download

Post 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.
jackobean
New User
New User
Posts: 9
Joined: Mon Jan 18, 2010 12:38 pm
Location: Melbourne, Australia

Re: Script to Remove Torrent After Finished Download

Post 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
akuiraz

Re: Script to Remove Torrent After Finished Download

Post 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
User avatar
StormPooper
New User
New User
Posts: 4
Joined: Sun Apr 08, 2012 1:14 am
Contact:

Re: Script to Remove Torrent After Finished Download

Post 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.
Server: Windows Home Server v1 (Server 2003)
Deluge: 1.3.4 + daemon + webui
Locked