raumfish / rutorrent

Automatically exported from code.google.com/p/rutorrent
0 stars 0 forks source link

Enhancement/Plugin Request: Execute Script upon torrent completion #345

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
(I've removed the description template since this is an enhancement request and 
not a defect 
report)

I would like to request a plugin or enhancement to ruTorrent whereby a specific 
script on the 
server could be executed upon specific torrent events such as completion of a 
download.

Some potential usecases would include:
* When a download completes, the script located at /home/user/unRarFiles.sh is 
executed with 
the download path as the $1 parameter
* When a new torrent is auto-downloaded via the RSS plugin, the script located 
at 
/home/user/notifyDownload.sh is executed with the name of the torrent file as 
the $1 parameter 
and the email address user@host.com as the $2 parameter
* When a torrent is removed from ruTorrent/rTorrent, the script located at 
/home/user/smartRename.sh is executed with the download path as the $1 parameter
*etc
* When a specific torrent reaches 1.50 ratio, a script located at 
/home/user/shutdown.sh shuts 
down the system.

If I were to generalize the usecases into one set of requirements, they would 
be as follows:
* A discrete list of events that can be 'harvested' is created. (eg: 
AddTorrent, RemoveTorrent, 
TorrentCompleted, RatioReached, TorrentCreated, and any other event that could 
be useful)
* Each of these events come with their own set of parameters which help 
describe the particulars 
of that event. (eg: ${torrentpath} ${datapath} ${tracker} ${ratio} ${totalsize} 
${dateadded} and 
others specific to each event)
* A discrete list of rules can be defined that match against the above events. 
(LessThan, 
GreaterThan, Equals, RegEx, etc). These rules take the parameters of the above 
events and 
compare them against values provided by the user on the plugin configuration 
page.
* A path to a bashscript which is executed upon successful matching of the 
rule. The path must 
be executable by the webuser.
* Modification of UI elements to allow these rules to be specified alongside 
their associated 
events. EG: If I'm adding a torrent manually, I should see a dropdown to choose 
a pre-written 
rule/script to be executed upon download completion. Alternatively, when I 
configure an auto-
RSS download, I should be able to choose which rule/script to run upon 
successful torrent 
download AND upon torrent download completion (two events occur here, so there 
are two 
different scripting options). 

Using this generic model, any number of automations can be performed.
Personally I want to develop a script which will automate my downloading of 
files:
* RSS plugin scans feeds for a torrent matching my specific criteria and 
downloads it. a "Notify" 
script that I write can send an SMS message to my cellphone to notify me that 
the download has 
begun.
* Torrent completes. A "unzip/unrar" script runs which unpacks the contents of 
my data if it is 
rarred.
* Next, the unpacked file(s) are uploaded via SCP to another machine
* Finally, a "Notify" script is run that sends an SMS to my phone to notify me 
that the file has 
been successfully transmitted to the location.

Note that all 4 of the above steps only consumed 2 events: RSSDownload and 
TorrentCompletion.

I'm thinking of the dizzying array of options that are possible with such an 
Event/Rule/Script 
system and it seems like the possibilities are endless!

Original issue reported on code.google.com by tigerm...@gmail.com on 16 Mar 2010 at 9:16

GoogleCodeExporter commented 9 years ago
many of this is already possible by using .rtorrent.rc
some of it isn't really needed, and is covered by other functions.

but that's not to say it's not possible.  I personally think this is more of a 
bounty
issue.  It looks slightly complicated.  I'd open a bounty for it in the forums.

Original comment by Wonslung@gmail.com on 16 Mar 2010 at 9:34

GoogleCodeExporter commented 9 years ago
also, you should  check out the unpack plugin.  It has the ability to manually 
or
automatically unrar finished torrents.

Original comment by Wonslung@gmail.com on 16 Mar 2010 at 9:39

GoogleCodeExporter commented 9 years ago

Original comment by novik65 on 17 Mar 2010 at 8:33

GoogleCodeExporter commented 9 years ago
Some throubles with this.
1) Most of that you can do via .rtorrent.rc.
2) If user can attach script on specific event (in UI, i mean) - this is a large
security hole. If he can't (for example, script/event pair is configured in 
some php
file) - we hasn't any profit (see point 1).

Original comment by novik65 on 17 Mar 2010 at 8:38

GoogleCodeExporter commented 9 years ago
You guys are right that many of the usecases I came up with are already 
possible with other plugins (unpack) 
or modifications of the .rtorrent.rc file.
Despite this, it would still be really handy to have some generic way to run a 
customizable bashscript to 
answer specific events.

Novik brings up a good point about the potential security risks with this, 
although I would disagree that this 
is a security "hole."
If an admin of an rtorrent/rutorrent system is installing a 
shellscript-executing plugin, they should know that 
shellscripts will be executed as a result. This is no more of a security "hole" 
than giving someone SSH access 
so they can customize their .rtorrent.rc file on their own - any number of 
local exploits can be used to gain 
root privileges.
There are definite risks associated with the execution of shellscripts, but 
since only power-users would ever 
install such a plugin, they are likely knowledgeable enough to accept such a 
risk.

The benefit of such a plugin would be granting the user the ability to do 
anything that .rtorrent.rc *can't* do.

Original comment by tigerm...@gmail.com on 17 Mar 2010 at 2:44

GoogleCodeExporter commented 9 years ago
although .rtorrent.rc is configurable, but GUI doesn't have anything on this. 
Would
be nice to have few at least one pre-configured option upon torrent completion -
emailing with torrent name.

Original comment by zilvinas...@gmail.com on 19 Mar 2010 at 7:58

GoogleCodeExporter commented 9 years ago
+1 on this enhancement request.
In the meantime i call my script from move.php just before the mailto action.

If you use event.download.finished in rtorrent.rc, auto move doesn't move 
anymore, so we can't use rtorrent.rc for that

Original comment by bobby.dj...@gmail.com on 20 Aug 2014 at 12:00