Clean up Deluge Settings

pull/232/head
Devin Buhl 8 years ago
parent b93a9719fe
commit 317f8917b9

@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
Subject.Definition = new DownloadClientDefinition(); Subject.Definition = new DownloadClientDefinition();
Subject.Definition.Settings = new DelugeSettings() Subject.Definition.Settings = new DelugeSettings()
{ {
TvCategory = null MovieCategory = null
}; };
_queued = new DelugeTorrent _queued = new DelugeTorrent

@ -31,25 +31,17 @@ namespace NzbDrone.Core.Download.Clients.Deluge
_proxy = proxy; _proxy = proxy;
} }
protected override string AddFromMagnetLink(RemoteMovie remoteEpisode, string hash, string magnetLink) protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink)
{ {
var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings); var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings);
if (!Settings.TvCategory.IsNullOrWhiteSpace()) if (!Settings.MovieCategory.IsNullOrWhiteSpace())
{ {
_proxy.SetLabel(actualHash, Settings.TvCategory, Settings); _proxy.SetLabel(actualHash, Settings.MovieCategory, Settings);
} }
_proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings); _proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings);
/*var isRecentEpisode = remoteEpisode.IsRecentEpisode();
if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First ||
!isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First)
{
_proxy.MoveTorrentToTopInQueue(actualHash, Settings);
}*/
return actualHash.ToUpper(); return actualHash.ToUpper();
} }
@ -57,66 +49,24 @@ namespace NzbDrone.Core.Download.Clients.Deluge
{ {
var actualHash = _proxy.AddTorrentFromFile(filename, fileContent, Settings); var actualHash = _proxy.AddTorrentFromFile(filename, fileContent, Settings);
if (!Settings.TvCategory.IsNullOrWhiteSpace()) if (!Settings.MovieCategory.IsNullOrWhiteSpace())
{ {
_proxy.SetLabel(actualHash, Settings.TvCategory, Settings); _proxy.SetLabel(actualHash, Settings.MovieCategory, Settings);
} }
_proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings); _proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings);
/*var isRecentEpisode = remoteEpisode.IsRecentEpisode();
if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First ||
!isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First)
{
_proxy.MoveTorrentToTopInQueue(actualHash, Settings);
}*/
return actualHash.ToUpper(); return actualHash.ToUpper();
} }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
{ {
var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings); throw new NotImplementedException("Episodes are not working with Radarr");
if (!Settings.TvCategory.IsNullOrWhiteSpace())
{
_proxy.SetLabel(actualHash, Settings.TvCategory, Settings);
}
_proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings);
var isRecentEpisode = remoteEpisode.IsRecentEpisode();
if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First ||
!isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First)
{
_proxy.MoveTorrentToTopInQueue(actualHash, Settings);
}
return actualHash.ToUpper();
} }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent)
{ {
var actualHash = _proxy.AddTorrentFromFile(filename, fileContent, Settings); throw new NotImplementedException("Episodes are not working with Radarr");
if (!Settings.TvCategory.IsNullOrWhiteSpace())
{
_proxy.SetLabel(actualHash, Settings.TvCategory, Settings);
}
_proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings);
var isRecentEpisode = remoteEpisode.IsRecentEpisode();
if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First ||
!isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First)
{
_proxy.MoveTorrentToTopInQueue(actualHash, Settings);
}
return actualHash.ToUpper();
} }
public override string Name => "Deluge"; public override string Name => "Deluge";
@ -127,9 +77,9 @@ namespace NzbDrone.Core.Download.Clients.Deluge
try try
{ {
if (!Settings.TvCategory.IsNullOrWhiteSpace()) if (!Settings.MovieCategory.IsNullOrWhiteSpace())
{ {
torrents = _proxy.GetTorrentsByLabel(Settings.TvCategory, Settings); torrents = _proxy.GetTorrentsByLabel(Settings.MovieCategory, Settings);
} }
else else
{ {
@ -149,7 +99,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
var item = new DownloadClientItem(); var item = new DownloadClientItem();
item.DownloadId = torrent.Hash.ToUpper(); item.DownloadId = torrent.Hash.ToUpper();
item.Title = torrent.Name; item.Title = torrent.Name;
item.Category = Settings.TvCategory; item.Category = Settings.MovieCategory;
item.DownloadClient = Definition.Name; item.DownloadClient = Definition.Name;
@ -280,7 +230,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
private ValidationFailure TestCategory() private ValidationFailure TestCategory()
{ {
if (Settings.TvCategory.IsNullOrWhiteSpace()) if (Settings.MovieCategory.IsNullOrWhiteSpace())
{ {
return null; return null;
} }
@ -297,14 +247,14 @@ namespace NzbDrone.Core.Download.Clients.Deluge
var labels = _proxy.GetAvailableLabels(Settings); var labels = _proxy.GetAvailableLabels(Settings);
if (!labels.Contains(Settings.TvCategory)) if (!labels.Contains(Settings.MovieCategory))
{ {
_proxy.AddLabel(Settings.TvCategory, Settings); _proxy.AddLabel(Settings.MovieCategory, Settings);
labels = _proxy.GetAvailableLabels(Settings); labels = _proxy.GetAvailableLabels(Settings);
if (!labels.Contains(Settings.TvCategory)) if (!labels.Contains(Settings.MovieCategory))
{ {
return new NzbDroneValidationFailure("TvCategory", "Configuration of label failed") return new NzbDroneValidationFailure("MovieCategory", "Configuration of label failed")
{ {
DetailedDescription = "Radarr as unable to add the label to Deluge." DetailedDescription = "Radarr as unable to add the label to Deluge."
}; };

@ -12,7 +12,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
RuleFor(c => c.Host).ValidHost(); RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0); RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.TvCategory).Matches("^[-a-z]*$").WithMessage("Allowed characters a-z and -"); RuleFor(c => c.MovieCategory).Matches("^[-a-z]*$").WithMessage("Allowed characters a-z and -");
} }
} }
@ -25,7 +25,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
Host = "localhost"; Host = "localhost";
Port = 8112; Port = 8112;
Password = "deluge"; Password = "deluge";
TvCategory = "movie-radarr"; MovieCategory = "movie-radarr";
} }
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)] [FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
@ -41,15 +41,9 @@ namespace NzbDrone.Core.Download.Clients.Deluge
public string Password { get; set; } public string Password { get; set; }
[FieldDefinition(4, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional")] [FieldDefinition(4, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional")]
public string TvCategory { get; set; } public string MovieCategory { get; set; }
[FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(DelugePriority), HelpText = "Priority to use when grabbing episodes that aired within the last 14 days")] [FieldDefinition(5, Label = "Use SSL", Type = FieldType.Checkbox)]
public int RecentTvPriority { get; set; }
[FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(DelugePriority), HelpText = "Priority to use when grabbing episodes that aired over 14 days ago")]
public int OlderTvPriority { get; set; }
[FieldDefinition(7, Label = "Use SSL", Type = FieldType.Checkbox)]
public bool UseSsl { get; set; } public bool UseSsl { get; set; }
public NzbDroneValidationResult Validate() public NzbDroneValidationResult Validate()

Loading…
Cancel
Save