diff --git a/AnimeAnnouncer/AnimeAnnouncer.csproj b/AnimeAnnouncer/AnimeAnnouncer.csproj index cb2c3bb..40e47e0 100644 --- a/AnimeAnnouncer/AnimeAnnouncer.csproj +++ b/AnimeAnnouncer/AnimeAnnouncer.csproj @@ -8,6 +8,7 @@ + diff --git a/AnimeAnnouncer/Program.cs b/AnimeAnnouncer/Program.cs index 6c0758e..3fd9a88 100644 --- a/AnimeAnnouncer/Program.cs +++ b/AnimeAnnouncer/Program.cs @@ -1,6 +1,7 @@ using System.ComponentModel; using AnimeAnnouncer.Cache; using AnimeAnnouncer.RSS; +using Mastonet; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using TMDbLib.Client; @@ -13,6 +14,7 @@ namespace AnimeAnnouncer private static TMDbClient tmdbClient; private static TMDBCache tmdbCache; + private static MastodonClient mastodonClient; static void Main(string[] args) { Console.WriteLine("Starting..."); @@ -39,6 +41,14 @@ namespace AnimeAnnouncer Console.WriteLine("Using cache"); } + String mastodonInstance = config["MastodonInstance"]; + + if(!String.IsNullOrEmpty(mastodonInstance)) + { + String mastodonToken = config["MastodonToken"]; + mastodonClient = new MastodonClient(mastodonInstance, mastodonToken); + } + nyaaIndexer.NewPost += OnNewPost; nyaaIndexer.RssReadFinished += OnRssReadFinished; nyaaIndexer.Start(true); @@ -126,13 +136,13 @@ namespace AnimeAnnouncer { try { - tmdbCache.SetCacheItem($"ShowCache-{title}", new TMDBCacheItem() + _ = tmdbCache.SetCacheItem($"ShowCache-{title}", new TMDBCacheItem() { Title = title, ShowID = supposedShowId, LatestSeasonNumber = latestSeason.SeasonNumber, LastEpisodeNumber = latestSeason.EpisodeCount - }).Start(); + }); Console.WriteLine($"{title} Added to cache"); } catch(Exception ex) @@ -156,9 +166,20 @@ namespace AnimeAnnouncer return; } - // + // Announce + if(mastodonClient != null) + { + try + { + _ = mastodonClient.PublishStatus($"

Finished Dubbed Airing Anime

{title} has finished airing! Season {season} Episode {episode} is now available for download. ", Visibility.Public); - //AnnounceFinishedSeason(title); + } + catch(Exception ex) + { + Console.WriteLine(ex.ToString()); + + } + } Console.WriteLine($"Choosing {title} as a finished season!"); } }