From 86498a71e5074affdb1eedd48074ce8eee8d8089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Mon, 18 Mar 2024 01:43:08 +0100 Subject: [PATCH] feat: add torrent priority to completion script env vars (#6629) --- docs/Scripts.md | 1 + libtransmission/torrent.cc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/Scripts.md b/docs/Scripts.md index d6c8adaa2..865958e54 100644 --- a/docs/Scripts.md +++ b/docs/Scripts.md @@ -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. diff --git a/libtransmission/torrent.cc b/libtransmission/torrent.cc index c1e5eb501..6cb5b7745 100644 --- a/libtransmission/torrent.cc +++ b/libtransmission/torrent.cc @@ -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{ { "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 }, };