New: Allow user to choose whether delay profile should apply to release of the highest enabled quality (#6218)

(cherry picked from commit d668e923af83ab7f1589d947fec9f40a3919e0b8)

Co-authored-by: Taloth Saldono <Taloth@users.noreply.github.com>
This commit is contained in:
Robin Dadswell 2021-05-09 00:45:04 +01:00 committed by GitHub
parent df3253f55c
commit af99c78352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 8 deletions

View File

@ -40,6 +40,7 @@ function EditDelayProfileModalContent(props) {
enableTorrent,
usenetDelay,
torrentDelay,
bypassIfHighestQuality,
tags
} = item;
@ -110,6 +111,20 @@ function EditDelayProfileModalContent(props) {
</FormGroup>
}
{
<FormGroup>
<FormLabel>{translate('BypassDelayIfHighestQuality')}</FormLabel>
<FormInputGroup
type={inputTypes.CHECK}
name="bypassIfHighestQuality"
{...bypassIfHighestQuality}
helpText={translate('BypassDelayIfHighestQualityHelpText')}
onChange={onInputChange}
/>
</FormGroup>
}
{
id === 1 ?
<Alert>

View File

@ -13,6 +13,7 @@ namespace NzbDrone.Api.Profiles.Delay
public DownloadProtocol PreferredProtocol { get; set; }
public int UsenetDelay { get; set; }
public int TorrentDelay { get; set; }
public bool BypassIfHighestQuality { get; set; }
public int Order { get; set; }
public HashSet<int> Tags { get; set; }
}
@ -35,6 +36,7 @@ namespace NzbDrone.Api.Profiles.Delay
PreferredProtocol = model.PreferredProtocol,
UsenetDelay = model.UsenetDelay,
TorrentDelay = model.TorrentDelay,
BypassIfHighestQuality = model.BypassIfHighestQuality,
Order = model.Order,
Tags = new HashSet<int>(model.Tags)
};
@ -56,6 +58,7 @@ namespace NzbDrone.Api.Profiles.Delay
PreferredProtocol = resource.PreferredProtocol,
UsenetDelay = resource.UsenetDelay,
TorrentDelay = resource.TorrentDelay,
BypassIfHighestQuality = resource.BypassIfHighestQuality,
Order = resource.Order,
Tags = new HashSet<int>(resource.Tags)
};

View File

@ -104,10 +104,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
}
[Test]
public void should_be_true_when_quality_is_last_allowed_in_profile()
public void should_be_false_when_quality_is_last_allowed_in_profile_and_bypass_disabled()
{
_remoteMovie.ParsedMovieInfo.Quality = new QualityModel(Quality.Bluray720p);
_remoteMovie.Release.PublishDate = DateTime.UtcNow;
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
}
[Test]
public void should_be_true_when_quality_is_last_allowed_in_profile_and_bypass_enabled()
{
_delayProfile.BypassIfHighestQuality = true;
_remoteMovie.ParsedMovieInfo.Quality = new QualityModel(Quality.Bluray720p);
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
}

View File

@ -0,0 +1,17 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(194)]
public class add_bypass_to_delay_profile : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("DelayProfiles").AddColumn("BypassIfHighestQuality").AsBoolean().WithDefaultValue(false);
// Set to true for existing Delay Profiles to keep behavior the same.
Execute.Sql("UPDATE DelayProfiles SET BypassIfHighestQuality = 1;");
}
}
}

View File

@ -1,4 +1,3 @@
using System.Linq;
using NLog;
using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.Download.Pending;
@ -78,13 +77,16 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
}
// If quality meets or exceeds the best allowed quality in the profile accept it immediately
var bestQualityInProfile = profile.LastAllowedQuality();
var isBestInProfile = comparer.Compare(subject.ParsedMovieInfo.Quality.Quality, bestQualityInProfile) >= 0;
if (isBestInProfile && isPreferredProtocol)
if (delayProfile.BypassIfHighestQuality)
{
_logger.Debug("Quality is highest in profile for preferred protocol, will not delay.");
return Decision.Accept();
var bestQualityInProfile = profile.LastAllowedQuality();
var isBestInProfile = comparer.Compare(subject.ParsedMovieInfo.Quality.Quality, bestQualityInProfile) >= 0;
if (isBestInProfile && isPreferredProtocol)
{
_logger.Debug("Quality is highest in profile for preferred protocol, will not delay.");
return Decision.Accept();
}
}
var oldest = _pendingReleaseService.OldestPendingRelease(subject.Movie.Id);

View File

@ -94,6 +94,8 @@
"BranchUpdate": "Branch to use to update Radarr",
"BranchUpdateMechanism": "Branch used by external update mechanism",
"BuiltIn": "Built In",
"BypassDelayIfHighestQuality": "Bypass if Highest Quality",
"BypassDelayIfHighestQualityHelpText": "Bypass delay when release has the highest enabled quality in the quality profile",
"BypassProxyForLocalAddresses": "Bypass Proxy for Local Addresses",
"Calendar": "Calendar",
"CalendarOptions": "Calendar Options",

View File

@ -12,6 +12,7 @@ namespace NzbDrone.Core.Profiles.Delay
public int UsenetDelay { get; set; }
public int TorrentDelay { get; set; }
public int Order { get; set; }
public bool BypassIfHighestQuality { get; set; }
public HashSet<int> Tags { get; set; }
public DelayProfile()

View File

@ -13,6 +13,7 @@ namespace Radarr.Api.V3.Profiles.Delay
public DownloadProtocol PreferredProtocol { get; set; }
public int UsenetDelay { get; set; }
public int TorrentDelay { get; set; }
public bool BypassIfHighestQuality { get; set; }
public int Order { get; set; }
public HashSet<int> Tags { get; set; }
}
@ -35,6 +36,7 @@ namespace Radarr.Api.V3.Profiles.Delay
PreferredProtocol = model.PreferredProtocol,
UsenetDelay = model.UsenetDelay,
TorrentDelay = model.TorrentDelay,
BypassIfHighestQuality = model.BypassIfHighestQuality,
Order = model.Order,
Tags = new HashSet<int>(model.Tags)
};
@ -56,6 +58,7 @@ namespace Radarr.Api.V3.Profiles.Delay
PreferredProtocol = resource.PreferredProtocol,
UsenetDelay = resource.UsenetDelay,
TorrentDelay = resource.TorrentDelay,
BypassIfHighestQuality = resource.BypassIfHighestQuality,
Order = resource.Order,
Tags = new HashSet<int>(resource.Tags)
};