Is this possible? Automatic sorting of download

Suggest, post, or discuss plugins for Deluge
Post Reply
nickeh
Member
Member
Posts: 32
Joined: Sun Oct 05, 2008 11:18 pm

Is this possible? Automatic sorting of download

Post by nickeh »

Hi!

I just had a look in my incoming folder and it's a mess with badly named folders from less serious torrent creators.

So I have an idea, it would be very easy to keep a tidy incoming folder if it would be possible to activate a feature that made subdirectories in the incoming folder for every tracker. And if in this folder deluge could create two directories one containing everything that is currently downloading or seeding and one folder where stuff that is removed from the client.

So say I download a bunch of torrents from tracker A and tracker B the folder structure would look like this

Incoming
-A
-B

And if we go deeper

Incoming
-A
---Download and seed
---Inactive
-B

Where if I have a torrent a,b and c where a is currently downloading, b is seeding and c is a torrent that I'm done seeding and it has been removed from the client

Incoming
-A
---Downloading and seeding
------ a
------ b
---Inactive
------ c

Because now when I try to clean up the messy incoming directory I have to keep track on witch files I still want to seed if we could sort out the torrents that the client is using I can feel safe to rename, move and delete anything in Inactive directory without ending seeding prematurely by mistake.

I know about the feature to move finished downloads but that moves when the torrent is downloaded right? What would be more useful is the above method where torrents get moved when no longer in the clients queue.
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: Is this possible? Automatic sorting of download

Post by johnnyg »

You could definitely write a ui client script or plugin to do this.
It would do something like this:
  1. Change torrent's download location to Incoming/<tracker>/Active
  2. Register for the TorrentRemoved event for that torrent
  3. When the event occurs do a system call to move it to Incoming/<tracker>/Inactive
nickeh
Member
Member
Posts: 32
Joined: Sun Oct 05, 2008 11:18 pm

Re: Is this possible? Automatic sorting of download

Post by nickeh »

It's a shame I don't have time to do this, maybe I will look at it when I don't have exams coming up.

If someone else wants to do this it would be nice, since I have a quite limited programming knowledge. Did a fair bit of programming but that was a long time ago...

However if I do get to writing a plugin for this I will probably need a lot of help from everyone here!

Best regards
Nicke
nickeh
Member
Member
Posts: 32
Joined: Sun Oct 05, 2008 11:18 pm

Re: Is this possible? Automatic sorting of download

Post by nickeh »

Okay, I had to take a break from the math studies so I started looking at this.

It's a real shame that the plugin documentation is in the shape it is... Tried some things just to see if i could get anything to work.
But it didn't really lead to anything.

So where to start? Are there any good simple plugins that show how to use signals from the core etc. ?
If I could see how to use the signals etc. new torrent added, and torrent removed this should really just be a matter of passing commands to the shell to create dirs and move stuff around...

Maybe this should be moved to plugins?
nickeh
Member
Member
Posts: 32
Joined: Sun Oct 05, 2008 11:18 pm

Re: Is this possible? Automatic sorting of download

Post by nickeh »

Okey now I've been looking into this a bit. And for the moment I'm trying to figure out how the plugin system works.
I've followed the wiki and managed to create plugins that show in the pluginlist in deluge but nothing more.

I was trying to do sort of a hello world by adding a log.debug("hello world") to the test plugin.

But nothing showed in the log.

This gave me two questions, am I supposed to see anything in the log if I add this to the def enable section?
And the other question if I edit my core.py created by the create plugin script how do I test it in deluge? Do I need to build the plugin in someway or does deluge execute the script I'm editing?

Would really be good if someone would describe the typical cycle of development.

As I've done it now I've just edited core.py , enabled the plugin in deluge and look in log for output...
Tried a bunch of different things but nothing gave any output
nickeh
Member
Member
Posts: 32
Joined: Sun Oct 05, 2008 11:18 pm

Re: Is this possible? Automatic sorting of download

Post by nickeh »

Okay, I got help on how to create and build plugins.

Now, I've been trying to find examples on how to use signals. Looked in forums and the plugins in svn but didn't find any good examples...
xenocrates

Re: Is this possible? Automatic sorting of download

Post by xenocrates »

I dont know python hardly at all, but I've managed to squabble together a quick code snippet. All this does is figures out your normal "Move Completed To" folder, and tacks on the tracker domain to the end of it, thus sorting your downloads by tracker name. For this to be more like what's wanted above, "Move Completed to:" needs to be enabled (Don't really know what this script does if it isn't). Deluge does complain that the folder doesn't exist when you go into the Options tab of a torrent, but creates it just fine once the torrent finishes. All I have to do now is figure out how to make it execute for every torrent I add... inotify, maybe? Just an option for the *nix crowd.

Code: Select all

#change move_on_completed_path to move_on_completed_path/tracker_host
from deluge.ui.client import sclient
sclient.set_core_uri()

c = sclient.get_config()
original_path = c['move_completed_path']

torrent_ids = sclient.get_session_state()

torrents = sclient.get_torrents_status({"move_on_completed_path":original_path}, ["name"])
for id in torrents:
    d = sclient.get_torrent_status(id, ['tracker_host', 'move_on_completed_path', 'name'])
    print d['tracker_host'],d['name']
    host = d['tracker_host']
    new_path = original_path + '/' + host
    sclient.set_torrent_move_on_completed_path(id,new_path)

print "done"
Anybody is welcome to use/improve this stuff. Like I said, I don't really know python all that well at all.
Vampboy
New User
New User
Posts: 8
Joined: Tue Jan 22, 2008 1:14 pm

Re: Is this possible? Automatic sorting of download

Post by Vampboy »

I know you probably hate the comparison, but before Deluge, I used uTorrent, and that had the ability to have downloaded content sorted into subdirs by Label. So if something was labeled "Audiobook" there would be a subdir in the finished download directory named "Audiobook" and it would put the finished download into that and maintain seeding it etc. Is this possible? Also, any way to apply a label automatically with the RSS plugin?
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: Is this possible? Automatic sorting of download

Post by johnnyg »

Under label options you can provide a "move completed to" folder which will move torrents with that label to that folder.
However currently you can only automatically apply labels by tracker.
shreaded_teddy

Re: Is this possible? Automatic sorting of download

Post by shreaded_teddy »

automatic label by torrent name would be awesome
Post Reply