Compare commits
2 Commits
25b214c0d7
...
EpisodeGro
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b830659bc | |||
| c423d8f3ed |
@@ -13,12 +13,17 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
|
||||
<PackageReference Include="TMDbLib" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="appSettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="TMDbLib">
|
||||
<HintPath>..\Libraries\TMDbLib.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -197,8 +197,42 @@ namespace AnimeAnnouncer
|
||||
|
||||
if(latestSeasonNumber != int.Parse(season))
|
||||
{
|
||||
Console.WriteLine($"Failing release due to TMDB's season number {latestSeasonNumber} not matching title season {season}");
|
||||
return;
|
||||
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