mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 18:42:42 +01:00
Fixed: Now assuming that an Ended series without any airdates are direct-to-dvd.
This commit is contained in:
parent
a5a99f64ff
commit
6c44121b09
@ -306,5 +306,30 @@ public void should_ignore_episodes_with_absolute_episode_of_zero_in_distinct_by_
|
||||
_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 @@ public void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisode
|
||||
dupeFreeRemoteEpisodes = MapAbsoluteEpisodeNumbers(series, dupeFreeRemoteEpisodes);
|
||||
}
|
||||
|
||||
foreach (var episode in OrderEpsiodes(series, dupeFreeRemoteEpisodes))
|
||||
foreach (var episode in OrderEpisodes(series, dupeFreeRemoteEpisodes))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -90,6 +90,7 @@ public void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisode
|
||||
allEpisodes.AddRange(updateList);
|
||||
|
||||
AdjustMultiEpisodeAirTime(series, allEpisodes);
|
||||
AdjustDirectToDvdAirDate(series, allEpisodes);
|
||||
|
||||
_episodeService.DeleteMany(existingEpisodes);
|
||||
_episodeService.UpdateMany(updateList);
|
||||
@ -151,6 +152,18 @@ private static void AdjustMultiEpisodeAirTime(Series series, IEnumerable<Episode
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ private Episode GetEpisodeToUpdate(Series series, Episode episode, List<Episode>
|
||||
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…
Reference in New Issue
Block a user