Basic functionality commit
This commit is contained in:
@@ -1,10 +1,84 @@
|
||||
namespace AnimeAnnouncer
|
||||
using AnimeAnnouncer.RSS;
|
||||
using TMDbLib.Client;
|
||||
|
||||
namespace AnimeAnnouncer
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private static NyaaIndexer nyaaIndexer= new NyaaIndexer();
|
||||
|
||||
private const String TMDBApiKey = "";
|
||||
|
||||
private static TMDbClient tmdbClient = new TMDbClient(TMDBApiKey);
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
Console.WriteLine("Starting...");
|
||||
|
||||
nyaaIndexer.NewPost += OnNewPost;
|
||||
nyaaIndexer.RssReadFinished += OnRssReadFinished;
|
||||
nyaaIndexer.Start(true);
|
||||
|
||||
Console.WriteLine("Press enter to quit...");
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
static async void OnNewPost(RSS.NyaaItem item)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProcessNewItem(item).Wait();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
static void OnRssReadFinished()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static async Task ProcessNewItem(NyaaItem item)
|
||||
{
|
||||
Console.WriteLine($"Processing {item.Title}");
|
||||
|
||||
//Parse release name using Anitomy library
|
||||
var items = AnitomySharp.AnitomySharp.Parse(item.Title);
|
||||
var title = items.FirstOrDefault(p => p.Category == AnitomySharp.Element.ElementCategory.ElementAnimeTitle)?.Value;
|
||||
var episodeTitle = items.FirstOrDefault(p => p.Category == AnitomySharp.Element.ElementCategory.ElementEpisodeTitle)?.Value;
|
||||
var season = items.FirstOrDefault(p => p.Category == AnitomySharp.Element.ElementCategory.ElementAnimeSeason)?.Value;
|
||||
var episode = items.FirstOrDefault(p => p.Category == AnitomySharp.Element.ElementCategory.ElementEpisodeNumber)?.Value;
|
||||
if(title == null || season == null || episode == null)
|
||||
{
|
||||
Console.WriteLine("Skipping release due to inability to determine title, season, or episode number.");
|
||||
return;
|
||||
}
|
||||
|
||||
var searchResults = await tmdbClient.SearchTvShowAsync(title);
|
||||
|
||||
var supposedShowId = searchResults.Results.First().Id;
|
||||
|
||||
var showResult = await tmdbClient.GetTvShowAsync(supposedShowId);
|
||||
|
||||
var latestSeason = showResult.Seasons.OrderByDescending(s => s.SeasonNumber).First();
|
||||
|
||||
if(latestSeason.SeasonNumber != int.Parse(season))
|
||||
{
|
||||
Console.WriteLine($"Failing release due to TMDB's season number {latestSeason.SeasonNumber} not matching title season {season}");
|
||||
return;
|
||||
}
|
||||
|
||||
if(latestSeason.EpisodeCount != int.Parse(episode))
|
||||
{
|
||||
Console.WriteLine($"Failing release due to TMDB's last episode number of {latestSeason.EpisodeCount} not matching title episode number {episode}");
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//AnnounceFinishedSeason(title);
|
||||
Console.WriteLine($"Choosing {title} as a finished season!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user