From 12c1eb86f212f90f139d20a296ce1b15f756e05d Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 21 Nov 2024 17:08:50 -0800 Subject: [PATCH] Fixed: New episodes in season follow season's monitored status Closes #7401 --- .../TvTests/RefreshEpisodeServiceFixture.cs | 60 +++++++++++++++++++ src/NzbDrone.Core/Tv/RefreshEpisodeService.cs | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs b/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs index 7779dfb54..ba21feca9 100644 --- a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs @@ -396,5 +396,65 @@ public void should_mark_updated_episodes_that_have_newly_added_absolute_episode_ _insertedEpisodes.Any(e => e.AbsoluteEpisodeNumberAdded).Should().BeFalse(); } + + [Test] + public void should_monitor_new_episode_if_season_is_monitored() + { + var series = GetSeries(); + series.Seasons = new List(); + series.Seasons.Add(new Season { SeasonNumber = 1, Monitored = true }); + + var episodes = Builder.CreateListOfSize(2) + .All() + .With(e => e.SeasonNumber = 1) + .Build() + .ToList(); + + var existingEpisode = new Episode + { + SeasonNumber = episodes[0].SeasonNumber, + EpisodeNumber = episodes[0].EpisodeNumber, + Monitored = true + }; + + Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) + .Returns(new List { existingEpisode }); + + Subject.RefreshEpisodeInfo(series, episodes); + + _updatedEpisodes.Should().HaveCount(1); + _insertedEpisodes.Should().HaveCount(1); + _insertedEpisodes.Should().OnlyContain(e => e.Monitored == true); + } + + [Test] + public void should_not_monitor_new_episode_if_season_is_not_monitored() + { + var series = GetSeries(); + series.Seasons = new List(); + series.Seasons.Add(new Season { SeasonNumber = 1, Monitored = false }); + + var episodes = Builder.CreateListOfSize(2) + .All() + .With(e => e.SeasonNumber = 1) + .Build() + .ToList(); + + var existingEpisode = new Episode + { + SeasonNumber = episodes[0].SeasonNumber, + EpisodeNumber = episodes[0].EpisodeNumber, + Monitored = true + }; + + Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) + .Returns(new List { existingEpisode }); + + Subject.RefreshEpisodeInfo(series, episodes); + + _updatedEpisodes.Should().HaveCount(1); + _insertedEpisodes.Should().HaveCount(1); + _insertedEpisodes.Should().OnlyContain(e => e.Monitored == false); + } } } diff --git a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs b/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs index 708a5f4c9..18b242835 100644 --- a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs +++ b/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs @@ -145,7 +145,7 @@ public void RefreshEpisodeInfo(Series series, IEnumerable remoteEpisode private bool GetMonitoredStatus(Episode episode, IEnumerable seasons, Series series) { - if ((episode.EpisodeNumber == 0 && episode.SeasonNumber != 1) || series.MonitorNewItems == NewItemMonitorTypes.None) + if (episode.EpisodeNumber == 0 && episode.SeasonNumber != 1) { return false; }