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)); }