Added implementation of episode groups with overrides for finale
This commit is contained in:
@@ -196,10 +196,44 @@ namespace AnimeAnnouncer
|
||||
|
||||
|
||||
if(latestSeasonNumber != int.Parse(season))
|
||||
{
|
||||
var titleSeason = int.Parse(season);
|
||||
bool seasonOverride = false;
|
||||
if(latestSeasonNumber ==1 && titleSeason > 1 && latestEpisodeNumber > 3)
|
||||
{ //Check episode groups to see if this is a single-season default show
|
||||
var showResult = await tmdbClient.GetTvShowAsync(supposedShowId, TMDbLib.Objects.TvShows.TvShowMethods.EpisodeGroups);
|
||||
var seasonEpisodeGroup = showResult.EpisodeGroups.Results.FirstOrDefault(eg => eg.Name == "Seasons");
|
||||
if(seasonEpisodeGroup != null)
|
||||
{ //Evaluate using new episode group
|
||||
var targetEpisodeGroup = await tmdbClient.GetTvEpisodeGroupsAsync(seasonEpisodeGroup.Id);
|
||||
if(targetEpisodeGroup != null)
|
||||
{
|
||||
var targetSeason = targetEpisodeGroup.Groups.FirstOrDefault(g => g.Order == titleSeason);
|
||||
if(targetSeason != null)
|
||||
{ //Episode_Type isn't making it with the current client, guess based on ordering
|
||||
var targetFinale = targetSeason.Episodes.OrderByDescending(g => g.Order).FirstOrDefault(e => e.EpisodeType.Equals("finale", StringComparison.InvariantCultureIgnoreCase));
|
||||
//Confirm it's aired within the last week
|
||||
if(targetFinale != null && targetEpisodeGroup.Groups.OrderByDescending(g => g.Order).FirstOrDefault() == targetSeason)
|
||||
{ //confirm the episode is marked as finale and that this season is the latest one in the episode group
|
||||
Console.WriteLine($"!!Choosing S{titleSeason}E{targetFinale.Order + 1} for finale using episode groups");
|
||||
cachedShow.LatestSeasonNumber = latestSeasonNumber = titleSeason;
|
||||
cachedShow.LastEpisodeNumber = latestEpisodeNumber = targetFinale.Order + 1;
|
||||
seasonOverride = true;
|
||||
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", cachedShow);
|
||||
}
|
||||
else
|
||||
Console.WriteLine("Could not find a finale episode.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(!seasonOverride)
|
||||
{
|
||||
Console.WriteLine($"Failing release due to TMDB's season number {latestSeasonNumber} not matching title season {season}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(latestEpisodeNumber != int.Parse(episode))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user