Fixed: Use Category from qBittorrent when set instead of Label

This commit is contained in:
Mark McDowall 2016-12-13 23:32:34 -08:00
parent c1de7f26d1
commit 7f8093de92
3 changed files with 52 additions and 1 deletions

View File

@ -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<QBittorrentTorrent> { 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<QBittorrentTorrent> { torrent });
var item = Subject.GetItems().Single();
item.Category.Should().Be(category);
}
}
}

View File

@ -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;

View File

@ -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