From 2505a19a88d936094ae83775aa68d87f4107dc62 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 20 Apr 2019 23:50:22 +0200 Subject: [PATCH] Fixed: Air-time adjustment for Amazon/Hulu releasing 4+ episodes on one day --- .../TvTests/RefreshEpisodeServiceFixture.cs | 15 ++++++++------- src/NzbDrone.Core/Tv/RefreshEpisodeService.cs | 12 ++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs b/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs index 592b56dc3..8f08e7e1d 100644 --- a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs @@ -328,13 +328,14 @@ namespace NzbDrone.Core.Test.TvTests Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) .Returns(new List()); + var now = DateTime.UtcNow; var series = GetSeries(); var episodes = Builder.CreateListOfSize(2) .All() .With(e => e.SeasonNumber = 1) - .With(e => e.AirDate = DateTime.Now.ToShortDateString()) - .With(e => e.AirDateUtc = DateTime.UtcNow) + .With(e => e.AirDate = now.ToShortDateString()) + .With(e => e.AirDateUtc = now) .Build() .ToList(); @@ -345,19 +346,19 @@ namespace NzbDrone.Core.Test.TvTests } [Test] - public void should_not_update_air_date_when_multiple_episodes_air_on_the_same_day_for_netflix() + public void should_not_update_air_date_when_more_than_three_episodes_air_on_the_same_day() { Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) .Returns(new List()); + var now = DateTime.UtcNow; var series = GetSeries(); - series.Network = "Netflix"; - var episodes = Builder.CreateListOfSize(2) + var episodes = Builder.CreateListOfSize(4) .All() .With(e => e.SeasonNumber = 1) - .With(e => e.AirDate = DateTime.Now.ToShortDateString()) - .With(e => e.AirDateUtc = DateTime.UtcNow) + .With(e => e.AirDate = now.ToShortDateString()) + .With(e => e.AirDateUtc = now) .Build() .ToList(); diff --git a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs b/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs index b81292219..843fffa18 100644 --- a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs +++ b/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs @@ -119,12 +119,6 @@ namespace NzbDrone.Core.Tv private void AdjustMultiEpisodeAirTime(Series series, IEnumerable allEpisodes) { - if (series.Network == "Netflix") - { - _logger.Debug("Not adjusting episode air times for Netflix series {0}", series.Title); - return; - } - var groups = allEpisodes.Where(c => c.AirDateUtc.HasValue) .GroupBy(e => new { e.SeasonNumber, e.AirDate }) .Where(g => g.Count() > 1) @@ -132,6 +126,12 @@ namespace NzbDrone.Core.Tv foreach (var group in groups) { + if (group.Key.SeasonNumber != 0 && group.Count() > 3) + { + _logger.Debug("Not adjusting multi-episode air times for series {0} season {1} since more than 3 episodes 'aired' on the same day", series.Title, group.Key.SeasonNumber); + continue; + } + var episodeCount = 0; foreach (var episode in group.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber))