From 210524b51a94129987bd7b1f0dfd752c78b9fc74 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 24 Mar 2015 17:11:46 -0700 Subject: [PATCH] Fixed: Scene numbered season searches when some episode weren't monitored --- .../MonitoredEpisodeSpecificationFixture.cs | 14 ++++++++++++++ .../RssSync/MonitoredEpisodeSpecification.cs | 2 +- .../Definitions/SearchCriteriaBase.cs | 1 + .../Definitions/SeasonSearchCriteria.cs | 8 ++++++++ .../IndexerSearch/NzbSearchService.cs | 7 +++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs index b1e57d534..36a46337d 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs @@ -123,5 +123,19 @@ public void should_return_false_if_episode_is_not_monitored_for_season_search() WithFirstEpisodeUnmonitored(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeFalse(); } + + [Test] + public void should_return_true_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_false() + { + WithFirstEpisodeUnmonitored(); + _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria { MonitoredEpisodesOnly = false }).Accepted.Should().BeTrue(); + } + + [Test] + public void should_return_false_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true() + { + WithFirstEpisodeUnmonitored(); + _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria{ MonitoredEpisodesOnly = true}).Accepted.Should().BeFalse(); + } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs index bea800ece..c377969a3 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs @@ -20,7 +20,7 @@ public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase { if (searchCriteria != null) { - if ((searchCriteria as SeasonSearchCriteria) == null) + if (!searchCriteria.MonitoredEpisodesOnly) { _logger.Debug("Skipping monitored check during search"); return Decision.Accept(); diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs index 3cfbca2e2..90d660942 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs @@ -17,6 +17,7 @@ public abstract class SearchCriteriaBase public Series Series { get; set; } public List SceneTitles { get; set; } public List Episodes { get; set; } + public virtual bool MonitoredEpisodesOnly { get; set; } public List QueryTitles { diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SeasonSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SeasonSearchCriteria.cs index cec5aad37..bf36769dc 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SeasonSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/SeasonSearchCriteria.cs @@ -4,6 +4,14 @@ public class SeasonSearchCriteria : SearchCriteriaBase { public int SeasonNumber { get; set; } + public override bool MonitoredEpisodesOnly + { + get + { + return true; + } + } + public override string ToString() { return string.Format("[{0} : S{1:00}]", Series.Title, SeasonNumber); diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 42f83500c..d30a74a0b 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -115,11 +115,18 @@ public List SeasonSearch(int seriesId, int seasonNumber) { var episode = sceneSeasonEpisodes.First(); var searchSpec = Get(series, sceneSeasonEpisodes.ToList()); + searchSpec.SeasonNumber = sceneSeasonEpisodes.Key; + searchSpec.MonitoredEpisodesOnly = true; + if (episode.SceneSeasonNumber.HasValue && episode.SceneEpisodeNumber.HasValue) + { searchSpec.EpisodeNumber = episode.SceneEpisodeNumber.Value; + } else + { searchSpec.EpisodeNumber = episode.EpisodeNumber; + } var decisions = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); downloadDecisions.AddRange(decisions);