Opened 15 years ago

Closed 13 years ago

#162 closed Enhancement (wontfix)

Execute script once torrent is completed

Reported by: will Owned by: somebody
Priority: Low Milestone: None Set
Component: Daemon Version: 1.34+
Severity: Minor Keywords: discuss


There are several topics in the forums describing functionality that would be better implemented outside the application, using custom scripts or utilities; automatic un-RARing, iTunes integration, etc.

My proposal is for the client to execute an external script/program every time a torrent finishes:

Index: macosx/Torrent.m
--- macosx/Torrent.m    (revision 993)
+++ macosx/Torrent.m    (working copy)
@@ -170,7 +170,13 @@
     //notification when downloading finished
     if ([self justFinished])
+       {
         [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
+               system([[NSString stringWithFormat: @"\"%@\" \"%@\"", 
+                               [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Application Support/Transmission/justFinished"],
+                               [self dataLocation]] fileSystemRepresentation]);
+       }
     //check to stop for ratio
     if ([self isSeeding] && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)

Obviously you could do it better, using the preferences to specify the location of the script, etc.

Change History (6)

comment:1 Changed 15 years ago by skorch

great idea. i personally would like transmission to move data files from completed torrents to a separate directory.

comment:2 Changed 15 years ago by livings124

  • Resolution set to wontfix
  • Status changed from new to closed

The nightlies can move files to a completed directory. I don't think adding script abilities is within the scope of what the app should do.

comment:3 Changed 13 years ago by jbergler

  • Component changed from Transmission to Daemon
  • Keywords discuss added
  • Milestone changed from Sometime to 1.40
  • Priority changed from Normal to Low
  • Resolution wontfix deleted
  • Severity changed from Normal to Minor
  • Status changed from closed to reopened
  • Version changed from 0.6 to 1.34+

I believe that this may again be of relevance with recent developments. I will reopen this for discussion.

Personally I believe this would be a great feature to be able to have with the daemon. Being able to run custom scripts on completion, maybe even on other events such as when a torrent finishes seeding.

Configuration should allow you to specify the command to execute along with arguments to pass, maybe in the format of /usr/bin/interpreterOfChoice /path/to/some/script $ARGNAME$ $ANOTHERARG$ $ANDONEMORE$

Somethings that might me useful to pass out are :

  • Path to file or folder of completed torrent.
  • Ratio torrent has currently seeded too.
  • Tracker URL
  • General other info from torrent that may be used for custom actions.

comment:4 Changed 13 years ago by charles

jbergler: by setting a milestone, you're essentially giving the Development team marching orders, which is a faux pas. In general, don't set the milestone unless (1) you're volunteering to write the code, and (2) the development team has agreed in principle.

transmission-remote can monitor the progress of torrents very clearly. A cron job can be set up to call transmission-remote every minute or so to check for newly-completed torrents, and to invoke a script upon completion, without adding the feature to the daemon.

Moreover, using cron + transmission-remote is a method that would work for the daemon, the gtk+ client, and the mac client. To my mind, that's preferable to a solution that only works with one of them. All this, without requiring any changes to any of those application's interfaces.

*All* of the data points you described (path, ratio, tracker url, general info from torrent) are all available in the transmision-remote scenario, or by calling the json-rpc by hand.

comment:5 Changed 13 years ago by charles

  • Milestone changed from 1.40 to None Set

comment:6 Changed 13 years ago by livings124

  • Resolution set to wontfix
  • Status changed from reopened to closed

Executing scripts are a bad idea, as changing the data can screw up seeding. There are ways to do this, as described above, but imho it shouldn't be added in formally, since it could cause too many problems (and you can't remove a feature after it's added).

Note: See TracTickets for help on using tickets.