Added support for Anilist lookups and date confirmations for ending series
This commit is contained in:
@@ -19,7 +19,7 @@ public class Anilist
|
|||||||
Task.WaitAll(Authenticate());
|
Task.WaitAll(Authenticate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Media> RetrieveAiringShowInformation(String showName)
|
public async Task<Media?> RetrieveAiringShowInformation(String showName)
|
||||||
{
|
{
|
||||||
var results = await client.SearchMediaAsync(new SearchMediaFilter
|
var results = await client.SearchMediaAsync(new SearchMediaFilter
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@ public class Anilist
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
int currentYear = DateTime.Now.Year;
|
int currentYear = DateTime.Now.Year;
|
||||||
var result = results.Data.Where(p => p.SeasonYear >= currentYear).OrderByDescending(p => p.StartDate).First();
|
var result = results.Data.Where(p => p.SeasonYear >= currentYear).OrderByDescending(p => p.StartDate.ToDateTime()).ThenByDescending(p => p.Id).FirstOrDefault();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AnitomySharp.NET6" Version="0.5.1" />
|
<PackageReference Include="AnitomySharp.NET6" Version="0.5.1" />
|
||||||
|
<PackageReference Include="Kavita.AniListNet" Version="0.1.3" />
|
||||||
<PackageReference Include="Mastonet" Version="3.1.2" />
|
<PackageReference Include="Mastonet" Version="3.1.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
|
||||||
|
|||||||
@@ -219,17 +219,30 @@ namespace AnimeAnnouncer
|
|||||||
//potentially override TMDB episode count with more reliable anilist data
|
//potentially override TMDB episode count with more reliable anilist data
|
||||||
string? anilistPosterPath = null;
|
string? anilistPosterPath = null;
|
||||||
if (latestEpisodeNumber > 3 && anilistClient != null)
|
if (latestEpisodeNumber > 3 && anilistClient != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("Looking up Anilist title " + title);
|
Console.WriteLine("Looking up Anilist title " + title);
|
||||||
var anilistMedia = await anilistClient.RetrieveAiringShowInformation(title);
|
var anilistMedia = await anilistClient.RetrieveAiringShowInformation(title);
|
||||||
|
if (anilistMedia != null)
|
||||||
|
{
|
||||||
if (anilistMedia.Episodes.HasValue && anilistMedia.Episodes != lastEpisodeNumber)
|
if (anilistMedia.Episodes.HasValue && anilistMedia.Episodes != lastEpisodeNumber)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Overriding episode count of {lastEpisodeNumber} using Anilist's showID {anilistMedia.Id} titled {anilistMedia.Title.EnglishTitle} with {anilistMedia.Episodes} episodes.");
|
Console.WriteLine(
|
||||||
|
$"Overriding episode count of {lastEpisodeNumber} using Anilist's showID {anilistMedia.Id} titled {anilistMedia.Title.EnglishTitle} with {anilistMedia.Episodes} episodes.");
|
||||||
lastEpisodeNumber = anilistMedia.Episodes.Value;
|
lastEpisodeNumber = anilistMedia.Episodes.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
anilistPosterPath = anilistMedia.BannerImageUrl?.ToString();
|
anilistPosterPath = anilistMedia.BannerImageUrl?.ToString();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Console.WriteLine("0 anilist results found");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"An error occurred during Anilist lookup: {ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(showResult.Seasons.Count > 1)
|
if(showResult.Seasons.Count > 1)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user