Parameters for Execute Plugin?

Suggest, post, or discuss plugins for Deluge
Post Reply
Znuff
Member
Member
Posts: 11
Joined: Sun Nov 18, 2007 6:34 am

Parameters for Execute Plugin?

Post by Znuff »

Hi,

Is there any way to add parameters to the execute plugin?

Like, run C:\some_command.exe $torrent_directory or something like that?
damoxc
Top Bloke
Top Bloke
Posts: 117
Joined: Sat Jul 19, 2008 7:26 pm
Location: Hampshire, UK
Contact:

Re: Parameters for Execute Plugin?

Post by damoxc »

I was planning to add this but never got around to it I'm afraid.

The parameters are static and are as follows:

Code: Select all

./some_command $TORRENT_ID $TORRENT_NAME $TORRENT_PATH
So the parameter you wish is the third one passed to the command, but in future they may become configurable.
Znuff
Member
Member
Posts: 11
Joined: Sun Nov 18, 2007 6:34 am

Re: Parameters for Execute Plugin?

Post by Znuff »

Hi!

Apparently this $TORRENT_PATH returns the downloading location of the torrent. Shouldn't it return the path that the torrent is moved to after completion, if you have that option enabled?

Thanks.
Znuff
Member
Member
Posts: 11
Joined: Sun Nov 18, 2007 6:34 am

Re: Parameters for Execute Plugin?

Post by Znuff »

Nevermind.

In core.py, in the Execute.egg

Find:

Code: Select all

        info = torrent.get_status(["name", "save_path""])
Replace with:

Code: Select all

        info = torrent.get_status(["name", "save_path", "move_on_completed_path"])
Now, under:

Code: Select all

        path = info["save_path"]
Add:

Code: Select all

        finalpath = info["move_on_completed_path"]
Finally, replace:

Code: Select all

                p = Popen([command, torrent_id, torrent_name, path],
With:

Code: Select all

                p = Popen([command, torrent_id, torrent_name, path, finalpath],
Parameters will be:

Code: Select all

./some_command $TORRENT_ID $TORRENT_NAME $TORRENT_PATH $TORRENT_MOVED_PATH
damoxc
Top Bloke
Top Bloke
Posts: 117
Joined: Sat Jul 19, 2008 7:26 pm
Location: Hampshire, UK
Contact:

Re: Parameters for Execute Plugin?

Post by damoxc »

Znuff wrote:Nevermind.

In core.py, in the Execute.egg

Find:

Code: Select all

        info = torrent.get_status(["name", "save_path""])
Replace with:

Code: Select all

        info = torrent.get_status(["name", "save_path", "move_on_completed_path"])
Now, under:

Code: Select all

        path = info["save_path"]
Add:

Code: Select all

        finalpath = info["move_on_completed_path"]
Finally, replace:

Code: Select all

                p = Popen([command, torrent_id, torrent_name, path],
With:

Code: Select all

                p = Popen([command, torrent_id, torrent_name, path, finalpath],
Parameters will be:

Code: Select all

./some_command $TORRENT_ID $TORRENT_NAME $TORRENT_PATH $TORRENT_MOVED_PATH

Well spotted, I wasn't using move_completed at the time of writing, however I don't think the way you have fixed it is correct. I prefer:

Code: Select all

path = info["save_path"] if info["move_on_completed_path"] == info["save_path"] else info["move_on_completed_path"]
Meaning that the parameters would still be:

Code: Select all

./some_command $TORRENT_ID $TORRENT_NAME $TORRENT_PATH
Seems rather pointless passing in where the torrent used to be :-)

I've fixed this in svn (both trunk and 1.2) as of r5991
Znuff
Member
Member
Posts: 11
Joined: Sun Nov 18, 2007 6:34 am

Re: Parameters for Execute Plugin?

Post by Znuff »

Indeed, your fix is way better. My python-fu is weak.

Edit: actually I propose to CHECK if move_completed is TRUE first, else the users will get the move_path even if it's not enabled, but it's just completed.

edit2: there's something wrong. I have the default torrent path set to /torrents/downloading, I added a torrent, I change it's path to /torrents/MP3, but the Execute plugin reported my home directory?!

edit3: here we go, feel free to optimise:

Code: Select all

        if torrent.get_status(["move_completed"]):
           path = info["move_on_completed_path"]
        else:
           path = info["save_path"]
theslut
Member
Member
Posts: 20
Joined: Thu Dec 24, 2009 9:26 am

Re: Parameters for Execute Plugin?

Post by theslut »

How do i edit the source files for this? I also need to send the downloaded directory to a job but the only parameter that is being passed is the download location the torrent was picked up from. Not entirely useful :(
Post Reply