Page 1 of 1

Parameters for Execute Plugin?

Posted: Mon Oct 12, 2009 2:03 am
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?

Re: Parameters for Execute Plugin?

Posted: Tue Oct 13, 2009 10:55 am
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.

Re: Parameters for Execute Plugin?

Posted: Tue Dec 08, 2009 1:13 am
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.

Re: Parameters for Execute Plugin?

Posted: Tue Dec 08, 2009 5:40 am
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

Re: Parameters for Execute Plugin?

Posted: Tue Dec 08, 2009 11:26 am
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

Re: Parameters for Execute Plugin?

Posted: Wed Dec 09, 2009 2:47 pm
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"]

Re: Parameters for Execute Plugin?

Posted: Mon Dec 28, 2009 11:31 am
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 :(