diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs index e6f56a12b..3ceece6f6 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs @@ -401,5 +401,55 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests var item = Subject.GetItems().Single(); item.IsReadOnly.Should().BeFalse(); } + + [Test] + public void should_get_category_from_the_category_if_set() + { + const string category = "tv-sonarr"; + GivenMaxRatio(1.0f); + + var torrent = new QBittorrentTorrent + { + Hash = "HASH", + Name = _title, + Size = 1000, + Progress = 1.0, + Eta = 8640000, + State = "pausedUP", + Category = category, + SavePath = "", + Ratio = 1.0f + }; + + GivenTorrents(new List { torrent }); + + var item = Subject.GetItems().Single(); + item.Category.Should().Be(category); + } + + [Test] + public void should_get_category_from_the_label_if_the_category_is_not_available() + { + const string category = "tv-sonarr"; + GivenMaxRatio(1.0f); + + var torrent = new QBittorrentTorrent + { + Hash = "HASH", + Name = _title, + Size = 1000, + Progress = 1.0, + Eta = 8640000, + State = "pausedUP", + Label = category, + SavePath = "", + Ratio = 1.0f + }; + + GivenTorrents(new List { torrent }); + + var item = Subject.GetItems().Single(); + item.Category.Should().Be(category); + } } } diff --git a/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrent.cs index b7d06cd3c..1e82cb196 100644 --- a/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrent.cs @@ -101,7 +101,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent { var item = new DownloadClientItem(); item.DownloadId = torrent.Hash.ToUpper(); - item.Category = torrent.Label; + item.Category = torrent.Category.IsNotNullOrWhiteSpace() ? torrent.Category : torrent.Label; item.Title = torrent.Name; item.TotalSize = torrent.Size; item.DownloadClient = Definition.Name; diff --git a/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrentTorrent.cs b/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrentTorrent.cs index 7577345a8..266d22f95 100644 --- a/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrentTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrentTorrent.cs @@ -18,6 +18,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent public string State { get; set; } // Torrent state. See possible values here below public string Label { get; set; } // Label of the torrent + public string Category { get; set; } // Category of the torrent (3.3.5+) [JsonProperty(PropertyName = "save_path")] public string SavePath { get; set; } // Torrent save path