mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-17 21:26:22 -04:00
New: Add bypass if above Custom Format Score to Delay Profile
(cherry picked from commit 4ed4ca4804ce973c1b88c1c4ede8ae00547ac834)
This commit is contained in:
@@ -106,9 +106,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
[Test]
|
||||
public void should_be_false_when_quality_is_last_allowed_in_profile_and_bypass_disabled()
|
||||
{
|
||||
_remoteMovie.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteMovie.ParsedMovieInfo.Quality = new QualityModel(Quality.Bluray720p);
|
||||
|
||||
_remoteMovie.Release.PublishDate = DateTime.UtcNow;
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
@@ -116,8 +117,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
[Test]
|
||||
public void should_be_true_when_quality_is_last_allowed_in_profile_and_bypass_enabled()
|
||||
{
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
_delayProfile.BypassIfHighestQuality = true;
|
||||
|
||||
_remoteMovie.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteMovie.ParsedMovieInfo.Quality = new QualityModel(Quality.Bluray720p);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
@@ -193,5 +196,43 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_custom_format_score_is_above_minimum_but_bypass_disabled()
|
||||
{
|
||||
_remoteMovie.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteMovie.CustomFormatScore = 100;
|
||||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
_delayProfile.MinimumCustomFormatScore = 50;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_custom_format_score_is_above_minimum_and_bypass_enabled_but_under_minimum()
|
||||
{
|
||||
_remoteMovie.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteMovie.CustomFormatScore = 5;
|
||||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
_delayProfile.BypassIfAboveCustomFormatScore = true;
|
||||
_delayProfile.MinimumCustomFormatScore = 50;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_custom_format_score_is_above_minimum_and_bypass_enabled()
|
||||
{
|
||||
_remoteMovie.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteMovie.CustomFormatScore = 100;
|
||||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
_delayProfile.BypassIfAboveCustomFormatScore = true;
|
||||
_delayProfile.MinimumCustomFormatScore = 50;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(228)]
|
||||
public class add_custom_format_score_bypass_to_delay_profile : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Alter.Table("DelayProfiles").AddColumn("BypassIfAboveCustomFormatScore").AsBoolean().WithDefaultValue(false);
|
||||
Alter.Table("DelayProfiles").AddColumn("MinimumCustomFormatScore").AsInt32().Nullable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,19 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
|
||||
}
|
||||
}
|
||||
|
||||
// If quality meets or exceeds the best allowed quality in the profile accept it immediately
|
||||
if (delayProfile.BypassIfAboveCustomFormatScore)
|
||||
{
|
||||
var score = subject.CustomFormatScore;
|
||||
var minimum = delayProfile.MinimumCustomFormatScore;
|
||||
|
||||
if (score >= minimum && isPreferredProtocol)
|
||||
{
|
||||
_logger.Debug("Custom format score ({0}) meets minimum ({1}) for preferred protocol, will not delay", score, minimum);
|
||||
return Decision.Accept();
|
||||
}
|
||||
}
|
||||
|
||||
var oldest = _pendingReleaseService.OldestPendingRelease(subject.Movie.Id);
|
||||
|
||||
if (oldest != null && oldest.Release.AgeMinutes > delay)
|
||||
|
||||
@@ -107,6 +107,10 @@
|
||||
"BranchUpdate": "Branch to use to update Radarr",
|
||||
"BranchUpdateMechanism": "Branch used by external update mechanism",
|
||||
"BuiltIn": "Built In",
|
||||
"BypassDelayIfAboveCustomFormatScore": "Bypass if Above Custom Format Score",
|
||||
"BypassDelayIfAboveCustomFormatScoreHelpText": "Enable bypass when release has a score higher than the configured minimum custom format score",
|
||||
"BypassDelayIfAboveCustomFormatScoreMinimumScore": "Minimum Custom Format Score",
|
||||
"BypassDelayIfAboveCustomFormatScoreMinimumScoreHelpText": "Minimum Custom Format Score required to bypass delay for the preferred protocol",
|
||||
"BypassDelayIfHighestQuality": "Bypass if Highest Quality",
|
||||
"BypassDelayIfHighestQualityHelpText": "Bypass delay when release has the highest enabled quality in the quality profile with the preferred protocol",
|
||||
"BypassProxyForLocalAddresses": "Bypass Proxy for Local Addresses",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Indexers;
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace NzbDrone.Core.Profiles.Delay
|
||||
public int TorrentDelay { get; set; }
|
||||
public int Order { get; set; }
|
||||
public bool BypassIfHighestQuality { get; set; }
|
||||
public bool BypassIfAboveCustomFormatScore { get; set; }
|
||||
public int MinimumCustomFormatScore { get; set; }
|
||||
public HashSet<int> Tags { get; set; }
|
||||
|
||||
public DelayProfile()
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace Radarr.Api.V3.Profiles.Delay
|
||||
public int UsenetDelay { get; set; }
|
||||
public int TorrentDelay { get; set; }
|
||||
public bool BypassIfHighestQuality { get; set; }
|
||||
public bool BypassIfAboveCustomFormatScore { get; set; }
|
||||
public int MinimumCustomFormatScore { get; set; }
|
||||
public int Order { get; set; }
|
||||
public HashSet<int> Tags { get; set; }
|
||||
}
|
||||
@@ -37,6 +39,8 @@ namespace Radarr.Api.V3.Profiles.Delay
|
||||
UsenetDelay = model.UsenetDelay,
|
||||
TorrentDelay = model.TorrentDelay,
|
||||
BypassIfHighestQuality = model.BypassIfHighestQuality,
|
||||
BypassIfAboveCustomFormatScore = model.BypassIfAboveCustomFormatScore,
|
||||
MinimumCustomFormatScore = model.MinimumCustomFormatScore,
|
||||
Order = model.Order,
|
||||
Tags = new HashSet<int>(model.Tags)
|
||||
};
|
||||
@@ -59,6 +63,8 @@ namespace Radarr.Api.V3.Profiles.Delay
|
||||
UsenetDelay = resource.UsenetDelay,
|
||||
TorrentDelay = resource.TorrentDelay,
|
||||
BypassIfHighestQuality = resource.BypassIfHighestQuality,
|
||||
BypassIfAboveCustomFormatScore = resource.BypassIfAboveCustomFormatScore,
|
||||
MinimumCustomFormatScore = resource.MinimumCustomFormatScore,
|
||||
Order = resource.Order,
|
||||
Tags = new HashSet<int>(resource.Tags)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user