Fixed: Air-time adjustment for Amazon/Hulu releasing 4+ episodes on one day

pull/3072/head
Taloth Saldono 6 years ago
parent beea02cea9
commit 2505a19a88

@ -328,13 +328,14 @@ namespace NzbDrone.Core.Test.TvTests
Mocker.GetMock<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<int>()))
.Returns(new List<Episode>());
var now = DateTime.UtcNow;
var series = GetSeries();
var episodes = Builder<Episode>.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<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<int>()))
.Returns(new List<Episode>());
var now = DateTime.UtcNow;
var series = GetSeries();
series.Network = "Netflix";
var episodes = Builder<Episode>.CreateListOfSize(2)
var episodes = Builder<Episode>.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();

@ -119,12 +119,6 @@ namespace NzbDrone.Core.Tv
private void AdjustMultiEpisodeAirTime(Series series, IEnumerable<Episode> 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))

Loading…
Cancel
Save