Fixed: Don't recalculate episode air times for Netflix series

This commit is contained in:
Mark McDowall 2015-01-10 12:00:00 -08:00
parent 67729c4d12
commit 4d19dddf88
2 changed files with 58 additions and 8 deletions

View File

@ -321,5 +321,49 @@ namespace NzbDrone.Core.Test.TvTests
_insertedEpisodes.First().Title.Should().Be("TBA");
}
[Test]
public void should_update_air_date_when_multiple_episodes_air_on_the_same_day()
{
Mocker.GetMock<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<Int32>()))
.Returns(new List<Episode>());
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)
.Build()
.ToList();
Subject.RefreshEpisodeInfo(series, episodes);
_insertedEpisodes.First().AirDateUtc.Should().Be(episodes.First().AirDateUtc);
_insertedEpisodes.Last().AirDateUtc.Should().Be(episodes.First().AirDateUtc.Value.AddMinutes(series.Runtime));
}
[Test]
public void should_not_update_air_date_when_multiple_episodes_air_on_the_same_day_for_netflix()
{
Mocker.GetMock<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<Int32>()))
.Returns(new List<Episode>());
var series = GetSeries();
series.Network = "Netflix";
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)
.Build()
.ToList();
Subject.RefreshEpisodeInfo(series, episodes);
_insertedEpisodes.Should().OnlyContain(e => e.AirDateUtc == episodes.First().AirDateUtc);
}
}
}

View File

@ -106,7 +106,7 @@ namespace NzbDrone.Core.Tv
}
}
private static bool GetMonitoredStatus(Episode episode, IEnumerable<Season> seasons)
private bool GetMonitoredStatus(Episode episode, IEnumerable<Season> seasons)
{
if (episode.EpisodeNumber == 0 && episode.SeasonNumber != 1)
{
@ -117,10 +117,15 @@ namespace NzbDrone.Core.Tv
return season == null || season.Monitored;
}
private static void AdjustMultiEpisodeAirTime(Series series, IEnumerable<Episode> allEpisodes)
private void AdjustMultiEpisodeAirTime(Series series, IEnumerable<Episode> allEpisodes)
{
var groups =
allEpisodes.Where(c => c.AirDateUtc.HasValue)
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)
.ToList();
@ -128,6 +133,7 @@ namespace NzbDrone.Core.Tv
foreach (var group in groups)
{
var episodeCount = 0;
foreach (var episode in group.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber))
{
episode.AirDateUtc = episode.AirDateUtc.Value.AddMinutes(series.Runtime * episodeCount);
@ -136,7 +142,7 @@ namespace NzbDrone.Core.Tv
}
}
private static void AdjustDirectToDvdAirDate(Series series, IEnumerable<Episode> allEpisodes)
private void AdjustDirectToDvdAirDate(Series series, IEnumerable<Episode> allEpisodes)
{
if (series.Status == SeriesStatusType.Ended && allEpisodes.All(v => !v.AirDateUtc.HasValue) && series.FirstAired.HasValue)
{