[Request] Delete torrent and data on queue

Suggest, post, or discuss plugins for Deluge
Post Reply
evevlo
New User
New User
Posts: 7
Joined: Wed Jul 20, 2011 9:42 pm

[Request] Delete torrent and data on queue

Post by evevlo »

How to set deluge to delete torrent AND DATA after it is queued after seeding or simply after some time or ratio?
hoobergoober
New User
New User
Posts: 9
Joined: Sun Jul 24, 2011 9:01 pm

Re: Delete torrent and data on queue

Post by hoobergoober »

I'm curious why you would have any reason to do this. Don't you want the data that you torrent?
CSB
Leecher
Leecher
Posts: 66
Joined: Fri Dec 03, 2010 1:55 am

Re: Delete torrent and data on queue

Post by CSB »

evevlo wrote:How to set deluge to delete torrent AND DATA after it is queued after seeding or simply after some time or ratio?
This is possible using a plugin or client script, but without a coherent and understandable description of what you want specifically, all I can do is direct you here: http://dev.deluge-torrent.org/wiki/Development
evevlo
New User
New User
Posts: 7
Joined: Wed Jul 20, 2011 9:42 pm

Re: [Request] Delete torrent and data on queue

Post by evevlo »

I have RSS automatic downloader, that downloads torrents, after that i have set it up so 60 torrents are seeded at a time, when next rss torrent is downloaded oldest (at least it seams so) torrent that is set as queued. I would like these to be automatically deleted, but also with its files, not torrents only.
Also it could be done so it would automatically delete torrents AND FILES after some time of seeding (lets say 12 hours for example).
CSB
Leecher
Leecher
Posts: 66
Joined: Fri Dec 03, 2010 1:55 am

Re: [Request] Delete torrent and data on queue

Post by CSB »

So you want to have a maximum number of torrents seeding (or total?) for a particular tracker?

I wrote a plugin for myself to do something similar... it deletes torrents (not removing data) to adhere to per tracker maximum settings... torrents older than 1 day are removed first, in descending order of upload/seeding_time, and then removes the oldest torrents which have been seeding for less than 1 day starting with the ones which have been seeding the oldest.

Hopefully you can modify it to get what you want.

Code: Select all

from deluge.log import LOG as log
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
import deluge.configmanager
from deluge.core.rpcserver import export

DEFAULT_PREFS = {'trackers': {}
}

class Core(CorePluginBase):
    def enforceTrackerMaximum(self, tracker, maximum):
        tracker = str(tracker)
        torrents = component.get("Core").get_torrents_status({"state": ["Downloading","Seeding"], "tracker_host": tracker}, ["seeding_time", "total_uploaded"])
        exempt = []
        nonexempt = []
        exdur = 86400
        for id in torrents:
                if torrents[id]["seeding_time"] > exdur:
                        nonexempt.append([torrents[id]["total_uploaded"]/torrents[id]["seeding_time"], id])
                else:
                        exempt.append([torrents[id]["seeding_time"], id])

        exempt.sort()
        nonexempt.sort()

        over = len(torrents) - maximum
        nover = over - len(exempt)
        if nover > 0:
                rover = over - nover
        else:
                rover = over
        if rover > 0:
                for torrent in nonexempt[:rover]:
                        component.get("Core").remove_torrent(torrent[1], False)

        if nover > 0:
                pause_list = []
                for torrent in exempt[-nover:]:
                        pause_list.append(torrent[1])
                component.get("Core").pause_torrent(pause_list)

    def torrent_event(self, torrent_id):
        tracker = component.get("Core").get_torrent_status(torrent_id, ["tracker_host"])["tracker_host"]
        if tracker in self.config['trackers']:
                self.enforceTrackerMaximum(tracker, self.config['trackers'][tracker])

    def multitorrent_event(self):
        for tracker in self.config['trackers']:
                self.enforceTrackerMaximum(tracker, self.config['trackers'][tracker])


    def enable(self):
        self.config = deluge.configmanager.ConfigManager("trackermaximums.conf", DEFAULT_PREFS)

        component.get("EventManager").register_event_handler("TorrentAddedEvent", self.torrent_event)
        component.get("EventManager").register_event_handler("TorrentResumedEvent", self.torrent_event)

        component.get("EventManager").register_event_handler("SessionResumedEvent", self.multitorrent_event)

        for tracker in self.config['trackers']:
                self.enforceTrackerMaximum(tracker, self.config['trackers'][tracker])

    def disable(self):
        component.get("EventManager").deregister_event_handler("TorrentAddedEvent", self.torrent_event)
        component.get("EventManager").deregister_event_handler("TorrentResumedEvent", self.torrent_event)

        component.get("EventManager").deregister_event_handler("SessionResumedEvent", self.multitorrent_event)


    def update(self):
        pass

    @export
    def set_config(self, config):
        "sets the config dictionary"
        for key in config.keys():
            self.config[key] = config[key]
        self.config.save()

    @export
    def get_config(self):
        "returns the config dictionary"
        return self.config.config
evevlo
New User
New User
Posts: 7
Joined: Wed Jul 20, 2011 9:42 pm

Re: [Request] Delete torrent and data on queue

Post by evevlo »

Thank you,

I lurked some more and found this thing http://forum.deluge-torrent.org/viewtop ... =8&t=37157
anyway i think i will use your script, as it actually does what i want with more clever rule (i seed 60 torrents maximum, so 60 per tracker is enough) and just change it to remove_torrent(torrent[1], True) :)
deity
Member
Member
Posts: 10
Joined: Tue Nov 02, 2010 11:35 pm

Re: [Request] Delete torrent and data on queue

Post by deity »

How do you install a script plugin such as this? i only see the option to install a .egg
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: [Request] Delete torrent and data on queue

Post by Cas »

deity wrote:How do you install a script plugin such as this? i only see the option to install a .egg
To use the plugin code that CSB put up you would need to create your own plugin, which is not difficult: http://dev.deluge-torrent.org/wiki/Deve ... 1.3/Plugin
Post Reply