1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-11 12:02:35 +02:00

Added: Enable Download Client Priorities (#2699)

Fixes #229
This commit is contained in:
Qstick 2018-04-14 23:03:32 -04:00 committed by Leonardo Galli
parent 17c100a7e7
commit 38932d82db
24 changed files with 242 additions and 53 deletions

View File

@ -33,7 +33,7 @@ public void Setup()
Port = 2222,
ApiKey = "1234-ABCD",
TvCategory = "tv",
RecentTvPriority = (int)NzbgetPriority.High
RecentMoviePriority = (int)NzbgetPriority.High
};
_queued = new NzbVortexQueueItem

View File

@ -31,7 +31,7 @@ public void Setup()
Username = "admin",
Password = "pass",
MovieCategory = "movie",
RecentTvPriority = (int)NzbgetPriority.High
RecentMoviePriority = (int)NzbgetPriority.High
};
_queued = new NzbgetQueueItem

View File

@ -89,6 +89,12 @@ protected void GivenSuccessfulDownload()
});
}
protected void GivenHighPriority()
{
Subject.Definition.Settings.As<QBittorrentSettings>().OlderMoviePriority = (int) QBittorrentPriority.First;
Subject.Definition.Settings.As<QBittorrentSettings>().RecentMoviePriority = (int) QBittorrentPriority.First;
}
protected void GivenMaxRatio(float maxRatio, bool removeOnMaxRatio = true)
{
Mocker.GetMock<IQBittorrentProxy>()
@ -265,6 +271,39 @@ public void Download_should_get_hash_from_magnet_url(string magnetUrl, string ex
id.Should().Be(expectedHash);
}
[Test]
public void Download_should_set_top_priority()
{
GivenHighPriority();
GivenSuccessfulDownload();
var remoteMovie = CreateRemoteMovie();
var id = Subject.Download(remoteMovie);
Mocker.GetMock<IQBittorrentProxy>()
.Verify(v => v.MoveTorrentToTopInQueue(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()), Times.Once());
}
[Test]
public void Download_should_not_fail_if_top_priority_not_available()
{
GivenHighPriority();
GivenSuccessfulDownload();
Mocker.GetMock<IQBittorrentProxy>()
.Setup(v => v.MoveTorrentToTopInQueue(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()))
.Throws(new HttpException(new HttpResponse(new HttpRequest("http://me.local/"), new HttpHeader(), new byte[0], System.Net.HttpStatusCode.Forbidden)));
var remoteMovie = CreateRemoteMovie();
var id = Subject.Download(remoteMovie);
id.Should().NotBeNullOrEmpty();
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_return_status_with_outputdirs()
{

View File

@ -37,7 +37,7 @@ public void Setup()
Username = "admin",
Password = "pass",
MovieCategory = "movie",
RecentTvPriority = (int)SabnzbdPriority.High
RecentMoviePriority = (int)SabnzbdPriority.High
};
_queued = new SabnzbdQueue
{

View File

@ -42,6 +42,14 @@ protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash
_proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings);
var isRecentMovie = remoteMovie.Movie.IsRecentMovie;
if (isRecentMovie && Settings.RecentMoviePriority == (int)DelugePriority.First ||
!isRecentMovie && Settings.OlderMoviePriority == (int)DelugePriority.First)
{
_proxy.MoveTorrentToTopInQueue(actualHash, Settings);
}
return actualHash.ToUpper();
}
@ -56,6 +64,14 @@ protected override string AddFromTorrentFile(RemoteMovie remoteMovie, string has
_proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings);
var isRecentMovie = remoteMovie.Movie.IsRecentMovie;
if (isRecentMovie && Settings.RecentMoviePriority == (int)DelugePriority.First ||
!isRecentMovie && Settings.OlderMoviePriority == (int)DelugePriority.First)
{
_proxy.MoveTorrentToTopInQueue(actualHash, Settings);
}
return actualHash.ToUpper();
}

View File

@ -1,4 +1,4 @@
using FluentValidation;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@ -43,7 +43,13 @@ public DelugeSettings()
[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 MovieCategory { get; set; }
[FieldDefinition(5, Label = "Use SSL", Type = FieldType.Checkbox)]
[FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(DelugePriority), HelpText = "Priority to use when grabbing movies that released within the last 21 days")]
public int RecentMoviePriority { get; set; }
[FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(DelugePriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
public int OlderMoviePriority { get; set; }
[FieldDefinition(7, Label = "Use SSL", Type = FieldType.Checkbox)]
public bool UseSsl { get; set; }
public NzbDroneValidationResult Validate()

View File

@ -31,7 +31,7 @@ public NzbVortex(INzbVortexProxy proxy,
protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents)
{
var priority = Settings.RecentTvPriority;
var priority = remoteMovie.Movie.IsRecentMovie ? Settings.RecentMoviePriority : Settings.OlderMoviePriority;
var response = _proxy.DownloadNzb(fileContents, filename, priority, Settings);

View File

@ -1,4 +1,4 @@
using FluentValidation;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@ -30,8 +30,8 @@ public NzbVortexSettings()
Host = "localhost";
Port = 4321;
TvCategory = "Movies";
RecentTvPriority = (int)NzbVortexPriority.Normal;
OlderTvPriority = (int)NzbVortexPriority.Normal;
RecentMoviePriority = (int)NzbVortexPriority.Normal;
OlderMoviePriority = (int)NzbVortexPriority.Normal;
}
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
@ -46,11 +46,11 @@ public NzbVortexSettings()
[FieldDefinition(3, Label = "Group", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional")]
public string TvCategory { get; set; }
[FieldDefinition(4, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(NzbVortexPriority), HelpText = "Priority to use when grabbing releases that aired within the last 14 days")]
public int RecentTvPriority { get; set; }
[FieldDefinition(4, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(NzbVortexPriority), HelpText = "Priority to use when grabbing movies that released within the last 21 days")]
public int RecentMoviePriority { get; set; }
[FieldDefinition(5, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(NzbVortexPriority), HelpText = "Priority to use when grabbing releases that aired over 14 days ago")]
public int OlderTvPriority { get; set; }
[FieldDefinition(5, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(NzbVortexPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
public int OlderMoviePriority { get; set; }
public NzbDroneValidationResult Validate()
{

View File

@ -35,7 +35,7 @@ protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filenam
{
var category = Settings.MovieCategory;
var priority = Settings.RecentTvPriority;
var priority = remoteMovie.Movie.IsRecentMovie ? Settings.RecentMoviePriority : Settings.OlderMoviePriority;
var addpaused = Settings.AddPaused;

View File

@ -29,8 +29,8 @@ public NzbgetSettings()
MovieCategory = "Movies";
Username = "nzbget";
Password = "tegbzn6789";
RecentTvPriority = (int)NzbgetPriority.Normal;
OlderTvPriority = (int)NzbgetPriority.Normal;
RecentMoviePriority = (int)NzbgetPriority.Normal;
OlderMoviePriority = (int)NzbgetPriority.Normal;
}
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
@ -48,11 +48,11 @@ public NzbgetSettings()
[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 MovieCategory { get; set; }
[FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(NzbgetPriority), HelpText = "Priority to use when grabbing releases that aired within the last 14 days")]
public int RecentTvPriority { get; set; }
[FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(NzbgetPriority), HelpText = "Priority to use when grabbing movies that released within the last 21 days")]
public int RecentMoviePriority { get; set; }
[FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(NzbgetPriority), HelpText = "Priority to use when grabbing releases that aired over 14 days ago")]
public int OlderTvPriority { get; set; }
[FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(NzbgetPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
public int OlderMoviePriority { get; set; }
[FieldDefinition(7, Label = "Use SSL", Type = FieldType.Checkbox)]
public bool UseSsl { get; set; }

View File

@ -40,6 +40,14 @@ protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash
_proxy.SetTorrentLabel(hash.ToLower(), Settings.MovieCategory, Settings);
}
var isRecentMovie = remoteMovie.Movie.IsRecentMovie;
if (isRecentMovie && Settings.RecentMoviePriority == (int)QBittorrentPriority.First ||
!isRecentMovie && Settings.OlderMoviePriority == (int)QBittorrentPriority.First)
{
_proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings);
}
SetInitialState(hash.ToLower());
return hash;
@ -49,9 +57,31 @@ protected override string AddFromTorrentFile(RemoteMovie remoteMovie, string has
{
_proxy.AddTorrentFromFile(filename, fileContent, Settings);
if (Settings.MovieCategory.IsNotNullOrWhiteSpace())
try
{
_proxy.SetTorrentLabel(hash.ToLower(), Settings.MovieCategory, Settings);
if (Settings.MovieCategory.IsNotNullOrWhiteSpace())
{
_proxy.SetTorrentLabel(hash.ToLower(), Settings.MovieCategory, Settings);
}
}
catch (Exception ex)
{
_logger.Warn(ex, "Failed to set the torrent label for {0}.", filename);
}
try
{
var isRecentMovie = remoteMovie.Movie.IsRecentMovie;
if (isRecentMovie && Settings.RecentMoviePriority == (int)QBittorrentPriority.First ||
!isRecentMovie && Settings.OlderMoviePriority == (int)QBittorrentPriority.First)
{
_proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings);
}
}
catch (Exception ex)
{
_logger.Warn(ex, "Failed to set the torrent priority for {0}.", filename);
}
SetInitialState(hash);
@ -165,6 +195,7 @@ protected override void Test(List<ValidationFailure> failures)
{
failures.AddIfNotNull(TestConnection());
if (failures.Any()) return;
failures.AddIfNotNull(TestPrioritySupport());
failures.AddIfNotNull(TestGetTorrents());
}
@ -241,6 +272,41 @@ private ValidationFailure TestConnection()
return null;
}
private ValidationFailure TestPrioritySupport()
{
var recentPriorityDefault = Settings.RecentMoviePriority == (int)QBittorrentPriority.Last;
var olderPriorityDefault = Settings.OlderMoviePriority == (int)QBittorrentPriority.Last;
if (olderPriorityDefault && recentPriorityDefault)
{
return null;
}
try
{
var config = _proxy.GetConfig(Settings);
if (!config.QueueingEnabled)
{
if (!recentPriorityDefault)
{
return new NzbDroneValidationFailure(nameof(Settings.RecentMoviePriority), "Queueing not enabled") { DetailedDescription = "Torrent Queueing is not enabled in your qBittorrent settings. Enable it in qBittorrent or select 'Last' as priority." };
}
else if (!olderPriorityDefault)
{
return new NzbDroneValidationFailure(nameof(Settings.OlderMoviePriority), "Queueing not enabled") { DetailedDescription = "Torrent Queueing is not enabled in your qBittorrent settings. Enable it in qBittorrent or select 'Last' as priority." };
}
}
}
catch (Exception ex)
{
_logger.Error(ex, "Failed to test qBittorrent");
return new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message);
}
return null;
}
private ValidationFailure TestGetTorrents()
{
try

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace NzbDrone.Core.Download.Clients.QBittorrent
{
@ -16,5 +16,8 @@ public class QBittorrentPreferences
[JsonProperty(PropertyName = "max_ratio_act")]
public bool RemoveOnMaxRatio { get; set; } // Action performed when a torrent reaches the maximum share ratio. [false = pause, true = remove]
[JsonProperty(PropertyName = "queueing_enabled")]
public bool QueueingEnabled { get; set; } = true;
}
}

View File

@ -40,10 +40,16 @@ public QBittorrentSettings()
[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 MovieCategory { get; set; }
[FieldDefinition(5, Label = "Initial State", Type = FieldType.Select, SelectOptions = typeof(QBittorrentState), HelpText = "Initial state for torrents added to qBittorrent")]
[FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(QBittorrentPriority), HelpText = "Priority to use when grabbing movies that released within the last 21 days")]
public int RecentMoviePriority { get; set; }
[FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(QBittorrentPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
public int OlderMoviePriority { get; set; }
[FieldDefinition(7, Label = "Initial State", Type = FieldType.Select, SelectOptions = typeof(QBittorrentState), HelpText = "Initial state for torrents added to qBittorrent")]
public int InitialState { get; set; }
[FieldDefinition(6, Label = "Use SSL", Type = FieldType.Checkbox, HelpText = "Use a secure connection. See Options -> Web UI -> 'Use HTTPS instead of HTTP' in qBittorrent.")]
[FieldDefinition(8, Label = "Use SSL", Type = FieldType.Checkbox, HelpText = "Use a secure connection. See Options -> Web UI -> 'Use HTTPS instead of HTTP' in qBittorrent.")]
public bool UseSsl { get; set; }
public NzbDroneValidationResult Validate()

View File

@ -35,7 +35,7 @@ public Sabnzbd(ISabnzbdProxy proxy,
protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents)
{
var category = Settings.MovieCategory;
var priority = Settings.RecentTvPriority;
var priority = remoteMovie.Movie.IsRecentMovie ? Settings.RecentMoviePriority : Settings.OlderMoviePriority;
var response = _proxy.DownloadNzb(fileContents, filename, category, priority, Settings);
@ -81,7 +81,8 @@ private IEnumerable<DownloadClientItem> GetQueue()
queueItem.CanBeRemoved = true;
queueItem.CanMoveFiles = true;
if (sabQueue.Paused || sabQueueItem.Status == SabnzbdDownloadStatus.Paused)
if ((sabQueue.Paused && sabQueueItem.Priority != SabnzbdPriority.Force) ||
sabQueueItem.Status == SabnzbdDownloadStatus.Paused)
{
queueItem.Status = DownloadItemStatus.Paused;

View File

@ -39,8 +39,8 @@ public SabnzbdSettings()
Host = "localhost";
Port = 8080;
MovieCategory = "movies";
RecentTvPriority = (int)SabnzbdPriority.Default;
OlderTvPriority = (int)SabnzbdPriority.Default;
RecentMoviePriority = (int)SabnzbdPriority.Default;
OlderMoviePriority = (int)SabnzbdPriority.Default;
}
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
@ -61,11 +61,11 @@ public SabnzbdSettings()
[FieldDefinition(5, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional")]
public string MovieCategory { get; set; }
[FieldDefinition(6, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(SabnzbdPriority), HelpText = "Priority to use when grabbing releases that aired within the last 14 days")]
public int RecentTvPriority { get; set; }
[FieldDefinition(6, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(SabnzbdPriority), HelpText = "Priority to use when grabbing movies that released within the last 21 days")]
public int RecentMoviePriority { get; set; }
[FieldDefinition(7, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(SabnzbdPriority), HelpText = "Priority to use when grabbing releases that aired over 14 days ago")]
public int OlderTvPriority { get; set; }
[FieldDefinition(7, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(SabnzbdPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
public int OlderMoviePriority { get; set; }
[FieldDefinition(8, Label = "Use SSL", Type = FieldType.Checkbox)]
public bool UseSsl { get; set; }

View File

@ -139,12 +139,30 @@ public override DownloadClientStatus GetStatus()
protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink)
{
_proxy.AddTorrentFromUrl(magnetLink, GetDownloadDirectory(), Settings);
var isRecentMovie = remoteMovie.Movie.IsRecentMovie;
if (isRecentMovie && Settings.RecentMoviePriority == (int)TransmissionPriority.First ||
!isRecentMovie && Settings.OlderMoviePriority == (int)TransmissionPriority.First)
{
_proxy.MoveTorrentToTopInQueue(hash, Settings);
}
return hash;
}
protected override string AddFromTorrentFile(RemoteMovie remoteMovie, string hash, string filename, byte[] fileContent)
{
_proxy.AddTorrentFromData(fileContent, GetDownloadDirectory(), Settings);
var isRecentMovie = remoteMovie.Movie.IsRecentMovie;
if (isRecentMovie && Settings.RecentMoviePriority == (int)TransmissionPriority.First ||
!isRecentMovie && Settings.OlderMoviePriority == (int)TransmissionPriority.First)
{
_proxy.MoveTorrentToTopInQueue(hash, Settings);
}
return hash;
}

View File

@ -1,4 +1,4 @@
using System.Text.RegularExpressions;
using System.Text.RegularExpressions;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
@ -57,7 +57,13 @@ public TransmissionSettings()
[FieldDefinition(6, Label = "Directory", Type = FieldType.Textbox, Advanced = true, HelpText = "Optional location to put downloads in, leave blank to use the default Transmission location")]
public string MovieDirectory { get; set; }
[FieldDefinition(7, Label = "Use SSL", Type = FieldType.Checkbox)]
[FieldDefinition(7, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(TransmissionPriority), HelpText = "Priority to use when grabbing movies that released within the last 21 days")]
public int RecentMoviePriority { get; set; }
[FieldDefinition(8, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(TransmissionPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
public int OlderMoviePriority { get; set; }
[FieldDefinition(9, Label = "Use SSL", Type = FieldType.Checkbox)]
public bool UseSsl { get; set; }
public NzbDroneValidationResult Validate()

View File

@ -39,7 +39,9 @@ public RTorrent(IRTorrentProxy proxy,
protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink)
{
_proxy.AddTorrentFromUrl(magnetLink, Settings.MovieCategory, RTorrentPriority.Normal, Settings.MovieDirectory, Settings);
var priority = (RTorrentPriority)(remoteMovie.Movie.IsRecentMovie ? Settings.RecentMoviePriority : Settings.OlderMoviePriority);
_proxy.AddTorrentFromUrl(magnetLink, Settings.MovieCategory, priority, Settings.MovieDirectory, Settings);
var tries = 10;
var retryDelay = 500;
@ -57,7 +59,9 @@ protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash
protected override string AddFromTorrentFile(RemoteMovie remoteMovie, string hash, string filename, byte[] fileContent)
{
_proxy.AddTorrentFromFile(filename, fileContent, Settings.MovieCategory, RTorrentPriority.Normal, Settings.MovieDirectory, Settings);
var priority = (RTorrentPriority)(remoteMovie.Movie.IsRecentMovie ? Settings.RecentMoviePriority : Settings.OlderMoviePriority);
_proxy.AddTorrentFromFile(filename, fileContent, Settings.MovieCategory, priority, Settings.MovieDirectory, Settings);
var tries = 10;
var retryDelay = 500;

View File

@ -1,4 +1,4 @@
using FluentValidation;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@ -53,6 +53,12 @@ public RTorrentSettings()
[FieldDefinition(7, Label = "Directory", Type = FieldType.Textbox, Advanced = true, HelpText = "Optional location to put downloads in, leave blank to use the default rTorrent location")]
public string MovieDirectory { get; set; }
[FieldDefinition(8, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(RTorrentPriority), HelpText = "Priority to use when grabbing movies that released within the last 21 days")]
public int RecentMoviePriority { get; set; }
[FieldDefinition(9, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(RTorrentPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
public int OlderMoviePriority { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -41,13 +41,13 @@ protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash
_proxy.AddTorrentFromUrl(magnetLink, Settings);
_proxy.SetTorrentLabel(hash, Settings.MovieCategory, Settings);
/*var isRecentEpisode = remoteEpisode.IsRecentEpisode();
var isRecentMovie = remoteMovie.Movie.IsRecentMovie;
if (isRecentEpisode && Settings.RecentTvPriority == (int)UTorrentPriority.First ||
!isRecentEpisode && Settings.OlderTvPriority == (int)UTorrentPriority.First)
if (isRecentMovie && Settings.RecentMoviePriority == (int)UTorrentPriority.First ||
!isRecentMovie && Settings.OlderMoviePriority == (int)UTorrentPriority.First)
{
_proxy.MoveTorrentToTopInQueue(hash, Settings);
}*/
}
_proxy.SetState(hash, (UTorrentState)Settings.IntialState, Settings);
@ -59,13 +59,13 @@ protected override string AddFromTorrentFile(RemoteMovie remoteMovie, string has
_proxy.AddTorrentFromFile(filename, fileContent, Settings);
_proxy.SetTorrentLabel(hash, Settings.MovieCategory, Settings);
/*var isRecentEpisode = remoteEpisode.IsRecentEpisode();
var isRecentMovie = remoteMovie.Movie.IsRecentMovie;
if (isRecentEpisode && Settings.RecentTvPriority == (int)UTorrentPriority.First ||
!isRecentEpisode && Settings.OlderTvPriority == (int)UTorrentPriority.First)
if (isRecentMovie && Settings.RecentMoviePriority == (int)UTorrentPriority.First ||
!isRecentMovie && Settings.OlderMoviePriority == (int)UTorrentPriority.First)
{
_proxy.MoveTorrentToTopInQueue(hash, Settings);
}*/
}
_proxy.SetState(hash, (UTorrentState)Settings.IntialState, Settings);

View File

@ -1,4 +1,4 @@
using FluentValidation;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@ -41,11 +41,11 @@ public UTorrentSettings()
[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 MovieCategory { get; set; }
[FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(UTorrentPriority), HelpText = "Priority to use when grabbing releases that aired within the last 14 days")]
public int RecentTvPriority { get; set; }
[FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(UTorrentPriority), HelpText = "Priority to use when grabbing movies that released within the last 21 days")]
public int RecentMoviePriority { get; set; }
[FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(UTorrentPriority), HelpText = "Priority to use when grabbing releases that aired over 14 days ago")]
public int OlderTvPriority { get; set; }
[FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(UTorrentPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
public int OlderMoviePriority { get; set; }
[FieldDefinition(7, Label = "Initial State", Type = FieldType.Select, SelectOptions = typeof(UTorrentState), HelpText = "Initial state for torrents added to uTorrent")]
public int IntialState { get; set; }

View File

@ -61,6 +61,24 @@ public Movie()
public string YouTubeTrailerId{ get; set; }
public string Studio { get; set; }
public bool IsRecentMovie
{
get
{
if (PhysicalRelease.HasValue)
{
return PhysicalRelease.Value >= DateTime.UtcNow.AddDays(-21);
}
if (InCinemas.HasValue)
{
return InCinemas.Value >= DateTime.UtcNow.AddDays(-120);
}
return true;
}
}
public bool HasFile => MovieFileId > 0;
public string FolderName()

View File

@ -4,7 +4,7 @@
<div class="col-sm-5">
<div class="input-group">
<label class="checkbox toggle well">
<input type="checkbox" name="fields.{{order}}.value"/>
<input type="checkbox" name="fields.{{order}}.value" validation-name="{{name}}"/>
<p>
<span>Yes</span>
<span>No</span>

View File

@ -2,7 +2,7 @@
<label class="col-sm-3 control-label">{{label}}</label>
<div class="col-sm-5">
<select name="fields.{{order}}.value" class="form-control">
<select name="fields.{{order}}.value" validation-name="{{name}}" class="form-control">
{{#each selectOptions}}
<option value="{{value}}">{{name}}</option>
{{/each}}