Page 1 of 1

get save_path from console

Posted: Wed Jan 08, 2014 3:26 am
by laharah
Hi there!

I'm currently switching away from uTorrent to deluge. I've written a script to transfer my state data, however I'm using this opportunity to re-organize and rename my shows and movies. The plan is to use filebot. However, I'd like to keep seeding all these files after the re-organization. I'm writing a script to sort each torrent with filebot, and then remove and then re-add the torrent using the new values.

The problem is that I can't seem to be able to find a way to get the save_path from the console. Is there any way to get this info?

Going forward, I'm planning to have the script execute on each file as it completes, where I can get the file name and save path from the execute variables. But I can't seem to find a way to get the variables from the console info.

On a related note, I'm wondering if there's a "move" command that I can execute. It would make everything a lot easier. Barring all this I'm going to have to do it from the torrent.state file, but I'd rather do it through some sort of API if I can, seeing as how editing the torrents.state file while deluge is running sounds pretty dangerous. In the end I may have to write my own plugin altogether, but I'd rather not have to.

Any help, ideas or insight you guys could give me would be appreciated!

-Laharah

Re: get save_path from console

Posted: Wed Jan 08, 2014 4:42 pm
by Cas
You can use a client script rather than plugin, there are examples around the forum

Re: get save_path from console

Posted: Thu Jan 09, 2014 8:31 am
by laharah
Cas wrote:You can use a client script rather than plugin, there are examples around the forum

I've been chipping away at a client script and it looks like I should be able to do everything I want to using a UI client, thanks for pointing me in the right direction!

I'm Having some trouble with folder renaming and changing the save_path though. for some reason client.core.move_storage() does nothing if the folder already exsists, and rename_folder is causing trouble too. Is there a known method for pointing a torrent at renamed files and folders?

Re: get save_path from console

Posted: Thu Jan 09, 2014 12:07 pm
by Cas
You can add the torrent and point to an existing path or if already added make sure the torrent is paused, delete any folder created then use move storage. (libtorrent will create the folder structure as soon as the torrent is added, I think this was fixed in 0.16)

Re: get save_path from console

Posted: Thu Jan 09, 2014 6:28 pm
by laharah
Cas wrote:You can add the torrent and point to an existing path or if already added make sure the torrent is paused, delete any folder created then use move storage. (libtorrent will create the folder structure as soon as the torrent is added, I think this was fixed in 0.16)
Thanks for your help! My code is coming along nicely! I've sorted my rename, problem; Turns out on deluge windows you need to add a trailing '/' when specifying a top-level folder you want to rename, otherwise it adds a second folder under top-level called "/" where it puts all your files.

I've got one last sort of general question. is there some sort of minimum time that you have to wait before doing additional client.core calls? I ask because I can execute certain calls like:

Code: Select all

client.core.force_recheck([torrent_id])
when I run them by themselves, but if I have a function that makes several client.core calls the later ones don't seem to ever execute. For example this is a callback from get_torrent_status() after adding a new torrent:

Code: Select all

def rename_top_level(info, torrent_id, topLevelTitle):
    if len(info['files']) > 1:
        mainFolder = info['files'][0]['path'].split('/')[0]
        client.core.rename_folder(torrent_id, mainFolder + '/', topLevelTitle)
    else:
        client.core.rename_files(torrent_id, [(0, topLevelTitle)])
    client.core.force_recheck([torrent_id])
    client.core.resume_torrent([torrent_id])
    print 'renaming done for', torrent_id
when I run this, neither force_recheck() nor resume_torrent() happen. Do I have to wait for a callback before I can send the next commands? Sometimes that doesn't even seem to work. I'm brand new to twisted so if the answer is obvious I apologize.