mirror of https://github.com/Sonarr/Sonarr
Ignore older episodes in latest season
New: Ignore episodes that aired more than 90 days ago when adding with Latest Season Closes #826
This commit is contained in:
parent
9b617af713
commit
4ea5e9ce9b
|
@ -207,6 +207,22 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
|
||||||
VerifyNotMonitored(e => e.HasFile);
|
VerifyNotMonitored(e => e.HasFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_monitor_latest_season_if_all_episodes_aired_more_than_90_days_ago()
|
||||||
|
{
|
||||||
|
_episodes.ForEach(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-100));
|
||||||
|
|
||||||
|
var monitoringOptions = new MonitoringOptions
|
||||||
|
{
|
||||||
|
Monitor = MonitorTypes.LatestSeason
|
||||||
|
};
|
||||||
|
|
||||||
|
Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
|
||||||
|
|
||||||
|
Mocker.GetMock<IEpisodeService>()
|
||||||
|
.Verify(v => v.UpdateEpisodes(It.Is<List<Episode>>(l => l.All(e => !e.Monitored))));
|
||||||
|
}
|
||||||
|
|
||||||
private void VerifyMonitored(Func<Episode, bool> predicate)
|
private void VerifyMonitored(Func<Episode, bool> predicate)
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IEpisodeService>()
|
Mocker.GetMock<IEpisodeService>()
|
||||||
|
|
|
@ -77,7 +77,17 @@ namespace NzbDrone.Core.Tv
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MonitorTypes.LatestSeason:
|
case MonitorTypes.LatestSeason:
|
||||||
|
|
||||||
|
if (episodes.Where(e => e.SeasonNumber == lastSeason)
|
||||||
|
.All(e => e.AirDateUtc.HasValue && !e.AirDateUtc.Value.InLastDays(90)))
|
||||||
|
{
|
||||||
|
_logger.Debug("[{0}] Unmonitoring all episodes because latest season aired more than 90 days ago", series.Title);
|
||||||
|
ToggleEpisodesMonitoredState(episodes, e => false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.Debug("[{0}] Monitoring latest season episodes", series.Title);
|
_logger.Debug("[{0}] Monitoring latest season episodes", series.Title);
|
||||||
|
|
||||||
ToggleEpisodesMonitoredState(episodes, e => e.SeasonNumber > 0 && e.SeasonNumber == lastSeason);
|
ToggleEpisodesMonitoredState(episodes, e => e.SeasonNumber > 0 && e.SeasonNumber == lastSeason);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue