mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
Fixed: Don't recalculate episode air times for Netflix series
This commit is contained in:
parent
67729c4d12
commit
4d19dddf88
@ -321,5 +321,49 @@ public void should_use_tba_for_episode_title_when_null()
|
|||||||
|
|
||||||
_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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -106,7 +106,7 @@ public void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 @@ private static bool GetMonitoredStatus(Episode episode, IEnumerable<Season> seas
|
|||||||
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);
|
||||||
.Where(g => g.Count() > 1)
|
return;
|
||||||
.ToList();
|
}
|
||||||
|
|
||||||
|
var groups = allEpisodes.Where(c => c.AirDateUtc.HasValue)
|
||||||
|
.GroupBy(e => new {e.SeasonNumber, e.AirDate})
|
||||||
|
.Where(g => g.Count() > 1)
|
||||||
|
.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 @@ private static void AdjustMultiEpisodeAirTime(Series series, IEnumerable<Episode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user