From 87795708b5caf63e63570cb62c6043a781ee89ae Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 7 Dec 2022 20:26:46 -0800 Subject: [PATCH] New: Allow Season packs to be grabbed automatically if all episodes will have aired within 24 hours Closes #5191 --- .../FullSeasonSpecificationFixture.cs | 10 +++++++++- .../Specifications/FullSeasonSpecification.cs | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/FullSeasonSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/FullSeasonSpecificationFixture.cs index 0c1c77b08..751984f06 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/FullSeasonSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/FullSeasonSpecificationFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; @@ -57,6 +57,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); } + [Test] + public void should_return_true_if_all_episodes_will_have_aired_in_the_next_24_hours() + { + _remoteEpisode.Episodes.Last().AirDateUtc = DateTime.UtcNow.AddHours(23); + + Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + } + [Test] public void should_return_false_if_one_episode_has_not_aired() { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs index 12762aa79..084ab0847 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using NLog; using NzbDrone.Common.Extensions; @@ -25,7 +25,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications { _logger.Debug("Checking if all episodes in full season release have aired. {0}", subject.Release.Title); - if (subject.Episodes.Any(e => !e.AirDateUtc.HasValue || e.AirDateUtc.Value.After(DateTime.UtcNow))) + if (subject.Episodes.Any(e => !e.AirDateUtc.HasValue || e.AirDateUtc.Value.After(DateTime.UtcNow.AddHours(24)))) { _logger.Debug("Full season release {0} rejected. All episodes haven't aired yet.", subject.Release.Title); return Decision.Reject("Full season release rejected. All episodes haven't aired yet.");