feat: add torrent priority to completion script env vars (#6629)

This commit is contained in:
Niccolò Maggioni 2024-03-18 01:43:08 +01:00 committed by GitHub
parent 2548dd478f
commit 86498a71e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View File

@ -27,6 +27,7 @@ Transmission can be set to invoke a script when downloads complete. The environm
* `TR_TORRENT_ID`
* `TR_TORRENT_LABELS` - A comma-delimited list of the torrent's labels
* `TR_TORRENT_NAME` - Name of torrent (not filename)
* `TR_TORRENT_PRIORITY` - The priority of the torrent (Low is "-1", Normal is "0", High is "1")
* `TR_TORRENT_TRACKERS` - A comma-delimited list of the torrent's trackers' announce URLs
[Here is an example script](https://trac.transmissionbt.com/browser/trunk/extras/send-email-when-torrent-done.sh) that sends an email when a torrent finishes.

View File

@ -384,6 +384,7 @@ void torrentCallScript(tr_torrent const* tor, std::string const& script)
auto const trackers_str = buildTrackersString(tor);
auto const bytes_downloaded_str = std::to_string(tor->bytes_downloaded_.ever());
auto const localtime_str = fmt::format("{:%a %b %d %T %Y%n}", fmt::localtime(tr_time()));
auto const priority_str = std::to_string(tor->get_priority());
auto const env = std::map<std::string_view, std::string_view>{
{ "TR_APP_VERSION"sv, SHORT_VERSION_STRING },
@ -394,6 +395,7 @@ void torrentCallScript(tr_torrent const* tor, std::string const& script)
{ "TR_TORRENT_ID"sv, id_str },
{ "TR_TORRENT_LABELS"sv, labels_str },
{ "TR_TORRENT_NAME"sv, tor->name() },
{ "TR_TORRENT_PRIORITY"sv, priority_str },
{ "TR_TORRENT_TRACKERS"sv, trackers_str },
};