Fixed: Now assuming that an Ended series without any airdates are direct-to-dvd.

pull/4/head
Taloth Saldono 10 years ago committed by Mark McDowall
parent a5a99f64ff
commit 6c44121b09

@ -306,5 +306,30 @@ namespace NzbDrone.Core.Test.TvTests
_insertedEpisodes.Should().HaveCount(episodes.Count);
}
[Test]
public void should_override_empty_airdate_for_direct_to_dvd()
{
var series = GetSeries();
series.Status = SeriesStatusType.Ended;
var episodes = Builder<Episode>.CreateListOfSize(10)
.All()
.With(v => v.AirDateUtc = null)
.BuildListOfNew();
Mocker.GetMock<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<Int32>()))
.Returns(new List<Episode>());
List<Episode> updateEpisodes = null;
Mocker.GetMock<IEpisodeService>().Setup(c => c.InsertMany(It.IsAny<List<Episode>>()))
.Callback<List<Episode>>(c => updateEpisodes = c);
Subject.RefreshEpisodeInfo(series, episodes);
updateEpisodes.Should().NotBeNull();
updateEpisodes.Should().NotBeEmpty();
updateEpisodes.All(v => v.AirDateUtc.HasValue).Should().BeTrue();
}
}
}

@ -47,7 +47,7 @@ namespace NzbDrone.Core.Tv
dupeFreeRemoteEpisodes = MapAbsoluteEpisodeNumbers(series, dupeFreeRemoteEpisodes);
}
foreach (var episode in OrderEpsiodes(series, dupeFreeRemoteEpisodes))
foreach (var episode in OrderEpisodes(series, dupeFreeRemoteEpisodes))
{
try
{
@ -90,6 +90,7 @@ namespace NzbDrone.Core.Tv
allEpisodes.AddRange(updateList);
AdjustMultiEpisodeAirTime(series, allEpisodes);
AdjustDirectToDvdAirDate(series, allEpisodes);
_episodeService.DeleteMany(existingEpisodes);
_episodeService.UpdateMany(updateList);
@ -151,6 +152,18 @@ namespace NzbDrone.Core.Tv
}
}
private static void AdjustDirectToDvdAirDate(Series series, IEnumerable<Episode> allEpisodes)
{
if (series.Status == SeriesStatusType.Ended && allEpisodes.All(v => !v.AirDateUtc.HasValue) && series.FirstAired.HasValue)
{
foreach (var episode in allEpisodes)
{
episode.AirDateUtc = series.FirstAired;
episode.AirDate = series.FirstAired.Value.ToString("yyyy-MM-dd");
}
}
}
private List<Episode> MapAbsoluteEpisodeNumbers(Series series, List<Episode> traktEpisodes)
{
var tvdbEpisodes = _tvdbProxy.GetEpisodeInfo(series.TvdbId);
@ -192,7 +205,7 @@ namespace NzbDrone.Core.Tv
return existingEpisodes.FirstOrDefault(e => e.SeasonNumber == episode.SeasonNumber && e.EpisodeNumber == episode.EpisodeNumber);
}
private IEnumerable<Episode> OrderEpsiodes(Series series, List<Episode> episodes)
private IEnumerable<Episode> OrderEpisodes(Series series, List<Episode> episodes)
{
if (series.SeriesType == SeriesTypes.Anime)
{

Loading…
Cancel
Save