Refresh series with recently aired episodes with TBA titles
Co-authored-by: Stevie Robinson <stevie.robinson@gmail.com>
This commit is contained in:
parent
fbda2d54c7
commit
bde5f68142
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
|
@ -28,6 +29,19 @@ namespace NzbDrone.Core.Tv
|
|||
return true;
|
||||
}
|
||||
|
||||
var episodes = _episodeService.GetEpisodeBySeries(series.Id);
|
||||
|
||||
var atLeastOneAiredEpisodeWithoutTitle = episodes.Any(e =>
|
||||
e.SeasonNumber > 0 &&
|
||||
e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow) &&
|
||||
e.Title.Equals("TBA", StringComparison.Ordinal));
|
||||
|
||||
if (atLeastOneAiredEpisodeWithoutTitle)
|
||||
{
|
||||
_logger.Trace("Series {0} with at least one aired episode with TBA title, should refresh.", series.Title);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (series.LastInfoSync >= DateTime.UtcNow.AddHours(-6))
|
||||
{
|
||||
_logger.Trace("Series {0} last updated less than 6 hours ago, should not be refreshed.", series.Title);
|
||||
|
@ -40,7 +54,7 @@ namespace NzbDrone.Core.Tv
|
|||
return true;
|
||||
}
|
||||
|
||||
var lastEpisode = _episodeService.GetEpisodeBySeries(series.Id).MaxBy(e => e.AirDateUtc);
|
||||
var lastEpisode = episodes.MaxBy(e => e.AirDateUtc);
|
||||
|
||||
if (lastEpisode != null && lastEpisode.AirDateUtc > DateTime.UtcNow.AddDays(-30))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue