From 2ee0ae1f9ecf2cb3c04b7b890101eb4ee5a87787 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 27 Apr 2019 19:13:27 -0700 Subject: [PATCH] New: Don't search for unaired anime episodes when searching for season Closes #2530 --- .../NzbSearchServiceFixture.cs | 18 ++++++++++++++++++ .../IndexerSearch/NzbSearchService.cs | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs index 736c00cbf..9c6eedbe1 100644 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs @@ -246,6 +246,24 @@ namespace NzbDrone.Core.Test.IndexerSearchTests criteria.Count.Should().Be(0); } + [Test] + public void season_search_for_anime_should_not_search_for_unaired_episodes() + { + WithEpisodes(); + _xemSeries.SeriesType = SeriesTypes.Anime; + _xemEpisodes.ForEach(e => e.AirDateUtc = DateTime.UtcNow.AddDays(5)); + _xemEpisodes.ForEach(e => e.EpisodeFileId = 0); + + var seasonNumber = 1; + var allCriteria = WatchForSearchCriteria(); + + Subject.SeasonSearch(_xemSeries.Id, seasonNumber, false, true, false); + + var criteria = allCriteria.OfType().ToList(); + + criteria.Count.Should().Be(0); + } + [Test] public void season_search_for_anime_should_not_search_for_episodes_with_files() { diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 520324956..3f51ef006 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -229,7 +229,8 @@ namespace NzbDrone.Core.IndexerSearch { var downloadDecisions = new List(); - foreach (var episode in episodes.Where(e => e.Monitored)) + // Only search for aired episodes when performing a season anime search + foreach (var episode in episodes.Where(e => e.Monitored && e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow))) { downloadDecisions.AddRange(SearchAnime(series, episode, userInvokedSearch, interactiveSearch)); }