Added some guard rails around airing list to avoid announcing old shows
This commit is contained in:
@@ -221,6 +221,8 @@ namespace AnimeAnnouncer
|
||||
};
|
||||
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", cachedShow);
|
||||
Console.WriteLine($"{title} Added to cache");
|
||||
if(latestSeason.AirDate < DateTime.Now && (latestSeason.AirDate + TimeSpan.FromDays(180)) > DateTime.Now &&
|
||||
(showResult.NextEpisodeToAir.AirDate + TimeSpan.FromDays(30)) > DateTime.Now)
|
||||
UpdateAiringShowList(cachedShow);
|
||||
}
|
||||
catch(Exception ex)
|
||||
@@ -266,6 +268,8 @@ namespace AnimeAnnouncer
|
||||
|
||||
seasonOverride = finaleConfirmed = true;
|
||||
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", cachedShow);
|
||||
|
||||
if(targetSeason != null && (targetSeason.Episodes.OrderBy(e => e.Order).First().AirDate + TimeSpan.FromDays(180)) > DateTime.Now && (showResult.NextEpisodeToAir.AirDate + TimeSpan.FromDays(30)) > DateTime.Now)
|
||||
UpdateAiringShowList(cachedShow);
|
||||
}
|
||||
else
|
||||
@@ -426,7 +430,7 @@ namespace AnimeAnnouncer
|
||||
}
|
||||
airingSoonList.Sort((showOne, showTwo) => showOne.LastAirDate.Value.CompareTo(showTwo.LastAirDate.Value));
|
||||
_ = tmdbCache.SetAiringSoon(airingSoonList);
|
||||
Console.WriteLine("Updated airing soon list");
|
||||
Console.WriteLine($"Updated airing soon list, setting {cachedShow.Title} Season {cachedShow.LatestSeasonNumber} to end on {cachedShow.LastAirDate ?? DateTime.MaxValue}");
|
||||
}
|
||||
private static bool HasAiringEndDate(int showID)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user