Page 1 of 1

[Request] Delete torrent and data on queue

Posted: Mon Jul 25, 2011 2:36 pm
by evevlo
How to set deluge to delete torrent AND DATA after it is queued after seeding or simply after some time or ratio?

Re: Delete torrent and data on queue

Posted: Tue Jul 26, 2011 12:42 am
by hoobergoober
I'm curious why you would have any reason to do this. Don't you want the data that you torrent?

Re: Delete torrent and data on queue

Posted: Tue Jul 26, 2011 1:31 am
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

Re: [Request] Delete torrent and data on queue

Posted: Fri Jul 29, 2011 8:51 am
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).

Re: [Request] Delete torrent and data on queue

Posted: Fri Jul 29, 2011 6:02 pm
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

Re: [Request] Delete torrent and data on queue

Posted: Wed Aug 10, 2011 6:13 pm
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) :)

Re: [Request] Delete torrent and data on queue

Posted: Wed Nov 23, 2011 3:16 pm
by deity
How do you install a script plugin such as this? i only see the option to install a .egg

Re: [Request] Delete torrent and data on queue

Posted: Wed Nov 23, 2011 4:04 pm
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