1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 15:32:31 +01:00

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"); _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) if (episode.EpisodeNumber == 0 && episode.SeasonNumber != 1)
{ {
@ -117,17 +117,23 @@ namespace NzbDrone.Core.Tv
return season == null || season.Monitored; return season == null || season.Monitored;
} }
private static void AdjustMultiEpisodeAirTime(Series series, IEnumerable<Episode> allEpisodes) private void AdjustMultiEpisodeAirTime(Series series, IEnumerable<Episode> allEpisodes)
{ {
var groups = if (series.Network == "Netflix")
allEpisodes.Where(c => c.AirDateUtc.HasValue) {
.GroupBy(e => new { e.SeasonNumber, e.AirDate }) _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) .Where(g => g.Count() > 1)
.ToList(); .ToList();
foreach (var group in groups) foreach (var group in groups)
{ {
var episodeCount = 0; var episodeCount = 0;
foreach (var episode in group.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber)) foreach (var episode in group.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber))
{ {
episode.AirDateUtc = episode.AirDateUtc.Value.AddMinutes(series.Runtime * episodeCount); 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) if (series.Status == SeriesStatusType.Ended && allEpisodes.All(v => !v.AirDateUtc.HasValue) && series.FirstAired.HasValue)
{ {