mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-20 18:02:44 +01:00
New: Add bypass if above Custom Format Score to Delay Profile
(cherry picked from commit 4ed4ca4804ce973c1b88c1c4ede8ae00547ac834)
This commit is contained in:
parent
8c93123126
commit
1f8877d192
@ -67,6 +67,8 @@ function EditDelayProfileModalContent(props) {
|
||||
usenetDelay,
|
||||
torrentDelay,
|
||||
bypassIfHighestQuality,
|
||||
bypassIfAboveCustomFormatScore,
|
||||
minimumCustomFormatScore,
|
||||
tags
|
||||
} = item;
|
||||
|
||||
@ -108,7 +110,7 @@ function EditDelayProfileModalContent(props) {
|
||||
</FormGroup>
|
||||
|
||||
{
|
||||
enableUsenet.value &&
|
||||
enableUsenet.value ?
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('UsenetDelay')}</FormLabel>
|
||||
|
||||
@ -120,11 +122,12 @@ function EditDelayProfileModalContent(props) {
|
||||
helpText={translate('UsenetDelayHelpText')}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
</FormGroup> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
enableTorrent.value &&
|
||||
enableTorrent.value ?
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('TorrentDelay')}</FormLabel>
|
||||
|
||||
@ -136,21 +139,48 @@ function EditDelayProfileModalContent(props) {
|
||||
helpText={translate('TorrentDelayHelpText')}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
</FormGroup> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('BypassDelayIfHighestQuality')}</FormLabel>
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('BypassDelayIfHighestQuality')}</FormLabel>
|
||||
|
||||
<FormInputGroup
|
||||
type={inputTypes.CHECK}
|
||||
name="bypassIfHighestQuality"
|
||||
{...bypassIfHighestQuality}
|
||||
helpText={translate('BypassDelayIfHighestQualityHelpText')}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormInputGroup
|
||||
type={inputTypes.CHECK}
|
||||
name="bypassIfHighestQuality"
|
||||
{...bypassIfHighestQuality}
|
||||
helpText={translate('BypassDelayIfHighestQualityHelpText')}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('BypassDelayIfAboveCustomFormatScore')}</FormLabel>
|
||||
|
||||
<FormInputGroup
|
||||
type={inputTypes.CHECK}
|
||||
name="bypassIfAboveCustomFormatScore"
|
||||
{...bypassIfAboveCustomFormatScore}
|
||||
helpText={translate('BypassDelayIfAboveCustomFormatScoreHelpText')}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
{
|
||||
bypassIfAboveCustomFormatScore.value ?
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('BypassDelayIfAboveCustomFormatScoreMinimumScore')}</FormLabel>
|
||||
|
||||
<FormInputGroup
|
||||
type={inputTypes.NUMBER}
|
||||
name="minimumCustomFormatScore"
|
||||
{...minimumCustomFormatScore}
|
||||
helpText={translate('BypassDelayIfAboveCustomFormatScoreMinimumScoreHelpText')}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -106,9 +106,10 @@ public void should_be_true_when_profile_does_not_have_a_delay()
|
||||
[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 @@ public void should_be_false_when_quality_is_last_allowed_in_profile_and_bypass_d
|
||||
[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 @@ public void should_be_false_when_release_is_proper_for_existing_movie_of_differe
|
||||
|
||||
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 @@ public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase se
|
||||
}
|
||||
}
|
||||
|
||||
// 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 @@ public class DelayProfile : ModelBase
|
||||
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 @@ public class DelayProfileResource : RestResource
|
||||
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 @@ public static DelayProfileResource ToResource(this DelayProfile model)
|
||||
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 @@ public static DelayProfile ToModel(this DelayProfileResource resource)
|
||||
UsenetDelay = resource.UsenetDelay,
|
||||
TorrentDelay = resource.TorrentDelay,
|
||||
BypassIfHighestQuality = resource.BypassIfHighestQuality,
|
||||
BypassIfAboveCustomFormatScore = resource.BypassIfAboveCustomFormatScore,
|
||||
MinimumCustomFormatScore = resource.MinimumCustomFormatScore,
|
||||
Order = resource.Order,
|
||||
Tags = new HashSet<int>(resource.Tags)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user