Refresh series with recently aired episodes with TBA titles

Co-authored-by: Stevie Robinson <stevie.robinson@gmail.com>
This commit is contained in:
Bogdan 2024-07-19 23:51:28 +03:00 committed by Mark McDowall
parent fbda2d54c7
commit bde5f68142
1 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Tv namespace NzbDrone.Core.Tv
{ {
@ -28,6 +29,19 @@ namespace NzbDrone.Core.Tv
return true; 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)) if (series.LastInfoSync >= DateTime.UtcNow.AddHours(-6))
{ {
_logger.Trace("Series {0} last updated less than 6 hours ago, should not be refreshed.", series.Title); _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; 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)) if (lastEpisode != null && lastEpisode.AirDateUtc > DateTime.UtcNow.AddDays(-30))
{ {