Support categories with Transmission

pull/1793/head
Bogdan 11 months ago
parent d153746a98
commit efd5e92ca5

@ -38,6 +38,6 @@ namespace NzbDrone.Core.Download.Clients.Transmission
}
public override string Name => "Transmission";
public override bool SupportsCategories => false;
public override bool SupportsCategories => true;
}
}

@ -28,7 +28,10 @@ namespace NzbDrone.Core.Download.Clients.Transmission
protected override string AddFromMagnetLink(TorrentInfo release, string hash, string magnetLink)
{
_proxy.AddTorrentFromUrl(magnetLink, GetDownloadDirectory(), Settings);
var category = GetCategoryForRelease(release) ?? Settings.Category;
var downloadDirectory = GetDownloadDirectory(category);
_proxy.AddTorrentFromUrl(magnetLink, downloadDirectory, Settings);
_proxy.SetTorrentSeedingConfiguration(hash, release.SeedConfiguration, Settings);
if (Settings.Priority == (int)TransmissionPriority.First)
@ -41,7 +44,10 @@ namespace NzbDrone.Core.Download.Clients.Transmission
protected override string AddFromTorrentFile(TorrentInfo release, string hash, string filename, byte[] fileContent)
{
_proxy.AddTorrentFromData(fileContent, GetDownloadDirectory(), Settings);
var category = GetCategoryForRelease(release) ?? Settings.Category;
var downloadDirectory = GetDownloadDirectory(category);
_proxy.AddTorrentFromData(fileContent, downloadDirectory, Settings);
_proxy.SetTorrentSeedingConfiguration(hash, release.SeedConfiguration, Settings);
if (Settings.Priority == (int)TransmissionPriority.First)
@ -73,14 +79,14 @@ namespace NzbDrone.Core.Download.Clients.Transmission
return outputPath + torrent.Name.Replace(":", "_");
}
protected string GetDownloadDirectory()
protected string GetDownloadDirectory(string category)
{
if (Settings.Directory.IsNotNullOrWhiteSpace())
{
return Settings.Directory;
}
if (!Settings.Category.IsNotNullOrWhiteSpace())
if (category.IsNullOrWhiteSpace())
{
return null;
}
@ -88,7 +94,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
var config = _proxy.GetConfig(Settings);
var destDir = config.DownloadDir;
return $"{destDir.TrimEnd('/')}/{Settings.Category}";
return $"{destDir.TrimEnd('/')}/{category}";
}
protected ValidationFailure TestConnection()

Loading…
Cancel
Save