Fixed post torrent %F parameter.

This commit is contained in:
Roger Far 2024-01-05 11:27:52 -07:00
parent 8114baa7b8
commit 2b39f92106
2 changed files with 11 additions and 2 deletions

View file

@ -47,7 +47,7 @@ public class DbSettingsGeneral
public Int32 UnpackLimit { get; set; } = 1;
[DisplayName("Categories")]
[Description("Expose these categories through the QBittorrent API.")]
[Description("Expose these categories through the QBittorrent API. Define multiple categories by separating them with a comma.")]
public String? Categories { get; set; } = null;
[DisplayName("Run external program on torrent completion")]

View file

@ -713,9 +713,18 @@ public class Torrents
var downloadPath = DownloadPath(torrent);
var torrentPath = Path.Combine(downloadPath, torrent.RdName ?? "Unknown");
var filePath = torrentPath;
var files = Directory.GetFiles(filePath);
if (files.Length == 1)
{
filePath = Path.Combine(torrentPath, files[0]);
}
arguments = arguments.Replace("%N", $"\"{torrent.RdName}\"");
arguments = arguments.Replace("%L", $"\"{torrent.Category}\"");
arguments = arguments.Replace("%F", $"\"{torrentPath}\"");
arguments = arguments.Replace("%F", $"\"{filePath}\"");
arguments = arguments.Replace("%R", $"\"{downloadPath}\"");
arguments = arguments.Replace("%D", $"\"{torrentPath}\"");
arguments = arguments.Replace("%C", downloads.Count.ToString(CultureInfo.InvariantCulture).Replace(",", "").Replace(".", ""));