Changeset 10640


Ignore:
Timestamp:
May 11, 2010, 1:36:21 PM (11 years ago)
Author:
charles
Message:

(trunk) #1796 "run script after torrent completion" -- (1) add to transmission-remote. (2) remove cli's custom script handler and have it use libtransmission instead.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/cli.c

    r10536 r10640  
    4848
    4949static const char * torrentPath  = NULL;
    50 static const char * finishCall   = NULL;
    5150static const char * sourceFile   = NULL;
    5251static const char * comment      = NULL;
     
    138137}
    139138
    140 static void
    141 torrentCompletenessChanged( tr_torrent       * torrent       UNUSED,
    142                             tr_completeness    completeness  UNUSED,
    143                             void             * user_data     UNUSED )
    144 {
    145     system( finishCall );
    146 }
    147 
    148139static tr_bool waitingOnWeb;
    149140
     
    454445    signal( SIGHUP, sigHandler );
    455446#endif
    456     tr_torrentSetCompletenessCallback( tor, torrentCompletenessChanged, NULL );
    457447    tr_torrentStart( tor );
    458448
     
    549539            case 'D': tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, FALSE );
    550540                      break;
    551             case 'f': finishCall = optarg;
     541            case 'f': tr_bencDictAddStr( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, optarg );
     542                      tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, TRUE );
    552543                      break;
    553544            case 'g': /* handled above */
  • trunk/daemon/remote.c

    r10635 r10640  
    192192static tr_option opts[] =
    193193{
    194     { 'a', "add",                   "Add torrent files by filename or URL", "a",  0, NULL },
    195     { 970, "alt-speed",             "Use the alternate Limits", "as",  0, NULL },
    196     { 971, "no-alt-speed",          "Don't use the alternate Limits", "AS",  0, NULL },
    197     { 972, "alt-speed-downlimit",   "max alternate download speed (in KiB/s)", "asd",  1, "<speed>" },
    198     { 973, "alt-speed-uplimit",     "max alternate upload speed (in KiB/s)", "asu",  1, "<speed>" },
    199     { 974, "alt-speed-scheduler",   "Use the scheduled on/off times", "asc",  0, NULL },
    200     { 975, "no-alt-speed-scheduler","Don't use the scheduled on/off times", "ASC",  0, NULL },
    201     { 976, "alt-speed-time-begin",  "Time to start using the alt speed limits (in hhmm)", NULL,  1, "<time>" },
    202     { 977, "alt-speed-time-end",    "Time to stop using the alt speed limits (in hhmm)", NULL,  1, "<time>" },
    203     { 978, "alt-speed-days",        "Numbers for any/all days of the week - eg. \"1-7\"", NULL,  1, "<days>" },
    204     { 963, "blocklist-update",      "Blocklist update", NULL, 0, NULL },
    205     { 'c', "incomplete-dir",        "Where to store new torrents until they're complete", "c", 1, "<dir>" },
    206     { 'C', "no-incomplete-dir",     "Don't store incomplete torrents in a different location", "C", 0, NULL },
    207     { 'b', "debug",                 "Print debugging information", "b",  0, NULL },
    208     { 'd', "downlimit",             "Set the max download speed in KiB/s for the current torrent(s) or globally", "d", 1, "<speed>" },
    209     { 'D', "no-downlimit",          "Disable max download speed for the current torrent(s) or globally", "D", 0, NULL },
    210     { 910, "encryption-required",   "Encrypt all peer connections", "er", 0, NULL },
    211     { 911, "encryption-preferred",  "Prefer encrypted peer connections", "ep", 0, NULL },
    212     { 912, "encryption-tolerated",  "Prefer unencrypted peer connections", "et", 0, NULL },
    213     { 'f', "files",                 "List the current torrent(s)' files", "f",  0, NULL },
    214     { 'g', "get",                   "Mark files for download", "g",  1, "<files>" },
    215     { 'G', "no-get",                "Mark files for not downloading", "G",  1, "<files>" },
    216     { 'i', "info",                  "Show the current torrent(s)' details", "i",  0, NULL },
    217     { 920, "session-info",          "Show the session's details", "si", 0, NULL },
    218     { 921, "session-stats",         "Show the session's statistics", "st", 0, NULL },
    219     { 'l', "list",                  "List all torrents", "l",  0, NULL },
    220     { 960, "move",                  "Move current torrent's data to a new folder", NULL, 1, "<path>" },
    221     { 961, "find",                  "Tell Transmission where to find a torrent's data", NULL, 1, "<path>" },
    222     { 'm', "portmap",               "Enable portmapping via NAT-PMP or UPnP", "m",  0, NULL },
    223     { 'M', "no-portmap",            "Disable portmapping", "M",  0, NULL },
    224     { 'n', "auth",                  "Set authentication info", "n",  1, "<user:pass>" },
    225     { 'N', "netrc",                 "Set authentication info from a .netrc file", "N",  1, "<filename>" },
    226     { 'o', "dht",                   "Enable distributed hash tables (DHT)", "o", 0, NULL },
    227     { 'O', "no-dht",                "Disable distributed hash tables (DHT)", "O", 0, NULL },
    228     { 'p', "port",                  "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", 1, "<port>" },
    229     { 962, "port-test",             "Port testing", "pt", 0, NULL },
    230     { 'P', "random-port",           "Random port for incomping peers", "P", 0, NULL },
    231     { 900, "priority-high",         "Set the files' priorities as high", "ph", 1, "<files>" },
    232     { 901, "priority-normal",       "Set the files' priorities as normal", "pn", 1, "<files>" },
    233     { 902, "priority-low",          "Set the files' priorities as low", "pl", 1, "<files>" },
    234     { 'r', "remove",                "Remove the current torrent(s)", "r",  0, NULL },
    235     { 930, "peers",                 "Set the maximum number of peers for the current torrent(s) or globally", "pr", 1, "<max>" },
    236     { 'R', "remove-and-delete",     "Remove the current torrent(s) and delete local data", NULL, 0, NULL },
    237     { 950, "seedratio",             "Let the current torrent(s) seed until a specific ratio", "sr", 1, "ratio" },
    238     { 951, "seedratio-default",     "Let the current torrent(s) use the global seedratio settings", "srd", 0, NULL },
    239     { 952, "no-seedratio",          "Let the current torrent(s) seed regardless of ratio", "SR", 0, NULL },
    240     { 953, "global-seedratio",      "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio", "gsr", 1, "ratio" },
    241     { 954, "no-global-seedratio",   "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio", "GSR", 0, NULL },
    242     { 's', "start",                 "Start the current torrent(s)", "s",  0, NULL },
    243     { 'S', "stop",                  "Stop the current torrent(s)", "S",  0, NULL },
    244     { 't', "torrent",               "Set the current torrent(s)", "t",  1, "<torrent>" },
    245     { 990, "start-paused",          "Start added torrents paused", NULL, 0, NULL },
    246     { 991, "no-start-paused",       "Start added torrents unpaused", NULL, 0, NULL },
    247     { 992, "trash-torrent",         "Delete torrents after adding", NULL, 0, NULL },
    248     { 993, "no-trash-torrent",      "Do not delete torrents after adding", NULL, 0, NULL },
    249     { 984, "honor-session",         "Make the current torrent(s) honor the session limits", "hl",  0, NULL },
    250     { 985, "no-honor-session",      "Make the current torrent(s) not honor the session limits", "HL",  0, NULL },
    251     { 'u', "uplimit",               "Set the max upload speed in KiB/s for the current torrent(s) or globally", "u", 1, "<speed>" },
    252     { 'U', "no-uplimit",            "Disable max upload speed for the current torrent(s) or globally", "U", 0, NULL },
    253     { 'v', "verify",                "Verify the current torrent(s)", "v",  0, NULL },
    254     { 'V', "version",               "Show version number and exit", "V", 0, NULL },
    255     { 'w', "download-dir",          "When adding a new torrent, set its download folder.  Otherwise, set the default download folder", "w",  1, "<path>" },
    256     { 'x', "pex",                   "Enable peer exchange (PEX)", "x",  0, NULL },
    257     { 'X', "no-pex",                "Disable peer exchange (PEX)", "X",  0, NULL },
    258     { 'z', "lds",                   "Enable local peer discovery (LPD)", "z",  0, NULL },
    259     { 'Z', "no-lds",                "Disable local peer discovery (LPD)", "Z",  0, NULL },
    260     { 940, "peer-info",             "List the current torrent(s)' peers", "pi",  0, NULL },
    261     {   0, NULL,                    NULL, NULL, 0, NULL }
     194    { 'a', "add",                    "Add torrent files by filename or URL", "a",  0, NULL },
     195    { 970, "alt-speed",              "Use the alternate Limits", "as",  0, NULL },
     196    { 971, "no-alt-speed",           "Don't use the alternate Limits", "AS",  0, NULL },
     197    { 972, "alt-speed-downlimit",    "max alternate download speed (in KiB/s)", "asd",  1, "<speed>" },
     198    { 973, "alt-speed-uplimit",      "max alternate upload speed (in KiB/s)", "asu",  1, "<speed>" },
     199    { 974, "alt-speed-scheduler",    "Use the scheduled on/off times", "asc",  0, NULL },
     200    { 975, "no-alt-speed-scheduler", "Don't use the scheduled on/off times", "ASC",  0, NULL },
     201    { 976, "alt-speed-time-begin",   "Time to start using the alt speed limits (in hhmm)", NULL,  1, "<time>" },
     202    { 977, "alt-speed-time-end",     "Time to stop using the alt speed limits (in hhmm)", NULL,  1, "<time>" },
     203    { 978, "alt-speed-days",         "Numbers for any/all days of the week - eg. \"1-7\"", NULL,  1, "<days>" },
     204    { 963, "blocklist-update",       "Blocklist update", NULL, 0, NULL },
     205    { 'c', "incomplete-dir",         "Where to store new torrents until they're complete", "c", 1, "<dir>" },
     206    { 'C', "no-incomplete-dir",      "Don't store incomplete torrents in a different location", "C", 0, NULL },
     207    { 'b', "debug",                  "Print debugging information", "b",  0, NULL },
     208    { 'd', "downlimit",              "Set the max download speed in KiB/s for the current torrent(s) or globally", "d", 1, "<speed>" },
     209    { 'D', "no-downlimit",           "Disable max download speed for the current torrent(s) or globally", "D", 0, NULL },
     210    { 910, "encryption-required",    "Encrypt all peer connections", "er", 0, NULL },
     211    { 911, "encryption-preferred",   "Prefer encrypted peer connections", "ep", 0, NULL },
     212    { 912, "encryption-tolerated",   "Prefer unencrypted peer connections", "et", 0, NULL },
     213    { 'f', "files",                  "List the current torrent(s)' files", "f",  0, NULL },
     214    { 'g', "get",                    "Mark files for download", "g",  1, "<files>" },
     215    { 'G', "no-get",                 "Mark files for not downloading", "G",  1, "<files>" },
     216    { 'i', "info",                   "Show the current torrent(s)' details", "i",  0, NULL },
     217    { 920, "session-info",           "Show the session's details", "si", 0, NULL },
     218    { 921, "session-stats",          "Show the session's statistics", "st", 0, NULL },
     219    { 'l', "list",                   "List all torrents", "l",  0, NULL },
     220    { 960, "move",                   "Move current torrent's data to a new folder", NULL, 1, "<path>" },
     221    { 961, "find",                   "Tell Transmission where to find a torrent's data", NULL, 1, "<path>" },
     222    { 'm', "portmap",                "Enable portmapping via NAT-PMP or UPnP", "m",  0, NULL },
     223    { 'M', "no-portmap",             "Disable portmapping", "M",  0, NULL },
     224    { 'n', "auth",                   "Set authentication info", "n",  1, "<user:pass>" },
     225    { 'N', "netrc",                  "Set authentication info from a .netrc file", "N",  1, "<filename>" },
     226    { 'o', "dht",                    "Enable distributed hash tables (DHT)", "o", 0, NULL },
     227    { 'O', "no-dht",                 "Disable distributed hash tables (DHT)", "O", 0, NULL },
     228    { 'p', "port",                   "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", 1, "<port>" },
     229    { 962, "port-test",              "Port testing", "pt", 0, NULL },
     230    { 'P', "random-port",            "Random port for incomping peers", "P", 0, NULL },
     231    { 900, "priority-high",          "Set the files' priorities as high", "ph", 1, "<files>" },
     232    { 901, "priority-normal",        "Set the files' priorities as normal", "pn", 1, "<files>" },
     233    { 902, "priority-low",           "Set the files' priorities as low", "pl", 1, "<files>" },
     234    { 'r', "remove",                 "Remove the current torrent(s)", "r",  0, NULL },
     235    { 930, "peers",                  "Set the maximum number of peers for the current torrent(s) or globally", "pr", 1, "<max>" },
     236    { 'R', "remove-and-delete",      "Remove the current torrent(s) and delete local data", NULL, 0, NULL },
     237    { 800, "torrent-done-script",    "Specify a script to run when a torrent finishes", NULL, 1, "<filename>" },
     238    { 801, "no-torrent-done-script", "Don't run a script when torrnets finish", NULL, 0, NULL },
     239    { 950, "seedratio",              "Let the current torrent(s) seed until a specific ratio", "sr", 1, "ratio" },
     240    { 951, "seedratio-default",      "Let the current torrent(s) use the global seedratio settings", "srd", 0, NULL },
     241    { 952, "no-seedratio",           "Let the current torrent(s) seed regardless of ratio", "SR", 0, NULL },
     242    { 953, "global-seedratio",       "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio", "gsr", 1, "ratio" },
     243    { 954, "no-global-seedratio",    "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio", "GSR", 0, NULL },
     244    { 's', "start",                  "Start the current torrent(s)", "s",  0, NULL },
     245    { 'S', "stop",                   "Stop the current torrent(s)", "S",  0, NULL },
     246    { 't', "torrent",                "Set the current torrent(s)", "t",  1, "<torrent>" },
     247    { 990, "start-paused",           "Start added torrents paused", NULL, 0, NULL },
     248    { 991, "no-start-paused",        "Start added torrents unpaused", NULL, 0, NULL },
     249    { 992, "trash-torrent",          "Delete torrents after adding", NULL, 0, NULL },
     250    { 993, "no-trash-torrent",       "Do not delete torrents after adding", NULL, 0, NULL },
     251    { 984, "honor-session",          "Make the current torrent(s) honor the session limits", "hl",  0, NULL },
     252    { 985, "no-honor-session",       "Make the current torrent(s) not honor the session limits", "HL",  0, NULL },
     253    { 'u', "uplimit",                "Set the max upload speed in KiB/s for the current torrent(s) or globally", "u", 1, "<speed>" },
     254    { 'U', "no-uplimit",             "Disable max upload speed for the current torrent(s) or globally", "U", 0, NULL },
     255    { 'v', "verify",                 "Verify the current torrent(s)", "v",  0, NULL },
     256    { 'V', "version",                "Show version number and exit", "V", 0, NULL },
     257    { 'w', "download-dir",           "When adding a new torrent, set its download folder.  Otherwise, set the default download folder", "w",  1, "<path>" },
     258    { 'x', "pex",                    "Enable peer exchange (PEX)", "x",  0, NULL },
     259    { 'X', "no-pex",                 "Disable peer exchange (PEX)", "X",  0, NULL },
     260    { 'z', "lds",                    "Enable local peer discovery (LPD)", "z",  0, NULL },
     261    { 'Z', "no-lds",                 "Disable local peer discovery (LPD)", "Z",  0, NULL },
     262    { 940, "peer-info",              "List the current torrent(s)' peers", "pi",  0, NULL },
     263    {   0, NULL,                     NULL, NULL, 0, NULL }
    262264};
    263265
     
    328330        case 'z': /* lds */
    329331        case 'Z': /* no-lds */
     332        case 800: /* torrent-done-script */
     333        case 801: /* no-torrent-done-script */
    330334        case 970: /* alt-speed */
    331335        case 971: /* no-alt-speed */
     
    17791783            switch( c )
    17801784            {
     1785                case 800: tr_bencDictAddStr( args, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, optarg );
     1786                          tr_bencDictAddBool( args, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, TRUE );
     1787                          break;
     1788                case 801: tr_bencDictAddBool( args, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, FALSE );
     1789                          break;
    17811790                case 970: tr_bencDictAddBool( args, TR_PREFS_KEY_ALT_SPEED_ENABLED, TRUE );
    17821791                          break;
  • trunk/daemon/transmission-remote.1

    r10635 r10640  
    102102.Ar days
    103103on which to enable the speed scheduler, using a list such as "2,4-6".
     104.It Fl -torrent-done-script Ar filename
     105Specify a
     106.Ar file
     107to run each time a torrent finishes
     108.It Fl -no-torrent-done-script
     109Don't run any script when a torrent finishes
    104110.It Fl c Fl -incomplete-dir Ar dir
    105111When adding new torrents, store their contents in
Note: See TracChangeset for help on using the changeset viewer.