Compare commits
5 Commits
MassTorren
...
c1103564bb
| Author | SHA1 | Date | |
|---|---|---|---|
| c1103564bb | |||
| 57c42bcc41 | |||
| 7bc2ef89a2 | |||
| 2e48daae3a | |||
| 5937ddcbd8 |
@@ -8,12 +8,12 @@ namespace AnimeAnnouncer.Cache
|
||||
|
||||
public int LatestSeasonNumber { get; set; }
|
||||
public int LastEpisodeNumber { get; set; }
|
||||
public string? PosterPath { get; internal set; }
|
||||
public string? BackdropPath { get; internal set; }
|
||||
public string? LatestSeasonPosterPath { get; internal set; }
|
||||
public string? LatestSeasonOverview { get; internal set; }
|
||||
public double VoteAverage { get; internal set; }
|
||||
public string? Overview { get; internal set; }
|
||||
public int? LatestOrdinalEpisodeNumber { get; internal set; }
|
||||
public string? PosterPath { get; set; }
|
||||
public string? BackdropPath { get; set; }
|
||||
public string? LatestSeasonPosterPath { get; set; }
|
||||
public string? LatestSeasonOverview { get; set; }
|
||||
public double VoteAverage { get; set; }
|
||||
public string? Overview { get; set; }
|
||||
public int? LatestOrdinalEpisodeNumber { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using Mastonet;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TMDbLib.Client;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
|
||||
namespace AnimeAnnouncer
|
||||
{
|
||||
@@ -144,9 +145,24 @@ namespace AnimeAnnouncer
|
||||
|
||||
latestEpisodeNumber = latestSeason.EpisodeCount;
|
||||
|
||||
//if nearing the end of a season, confirm it's marked with season finale
|
||||
|
||||
if(int.Parse(episode) >= (latestEpisodeNumber - 2))
|
||||
{
|
||||
var latestSeasonDetail = await tmdbClient.GetTvSeasonAsync(supposedShowId, latestSeasonNumber);
|
||||
|
||||
var seasonFinale = latestSeasonDetail.Episodes.LastOrDefault(e => e.EpisodeType.Equals("finale", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
if(seasonFinale != null && seasonFinale.EpisodeNumber != latestEpisodeNumber)
|
||||
{
|
||||
Console.WriteLine($"Overriding previous finale choice of {latestEpisodeNumber} due to season detail response where it's {seasonFinale.EpisodeNumber}");
|
||||
latestEpisodeNumber = seasonFinale.EpisodeNumber;
|
||||
}
|
||||
}
|
||||
|
||||
if(showResult.Seasons.Count > 1)
|
||||
{
|
||||
latestOrdinalEpisodeNumber = showResult.Seasons.Sum(s => s.EpisodeCount);
|
||||
latestOrdinalEpisodeNumber = showResult.Seasons.Where(s => s.SeasonNumber != 0).Sum(s => s.EpisodeCount);
|
||||
}
|
||||
|
||||
if(tmdbCache != null && searchResults != null)
|
||||
@@ -164,8 +180,8 @@ namespace AnimeAnnouncer
|
||||
Overview = showResult.Overview,
|
||||
VoteAverage = showResult.VoteAverage,
|
||||
ShowID = supposedShowId,
|
||||
LatestSeasonNumber = latestSeason.SeasonNumber,
|
||||
LastEpisodeNumber = latestSeason.EpisodeCount
|
||||
LatestSeasonNumber = latestSeasonNumber,
|
||||
LastEpisodeNumber = latestEpisodeNumber
|
||||
};
|
||||
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", cachedShow);
|
||||
Console.WriteLine($"{title} Added to cache");
|
||||
@@ -193,6 +209,12 @@ namespace AnimeAnnouncer
|
||||
return;
|
||||
}
|
||||
}
|
||||
//Sometimes TMDB metadata hasn't been filled in yet
|
||||
if(latestEpisodeNumber < 3)
|
||||
{
|
||||
Console.WriteLine("Skipping announcement due to a low episode number");
|
||||
return;
|
||||
}
|
||||
|
||||
// Announce if unique
|
||||
if(await tmdbCache.KeyExists($"ShowAnnounced-{supposedShowId}"))
|
||||
|
||||
Reference in New Issue
Block a user