Added Mastodon announcement; Fixed async Task issue
This commit is contained in:
@@ -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="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" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using AnimeAnnouncer.Cache;
|
using AnimeAnnouncer.Cache;
|
||||||
using AnimeAnnouncer.RSS;
|
using AnimeAnnouncer.RSS;
|
||||||
|
using Mastonet;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using TMDbLib.Client;
|
using TMDbLib.Client;
|
||||||
@@ -13,6 +14,7 @@ namespace AnimeAnnouncer
|
|||||||
|
|
||||||
private static TMDbClient tmdbClient;
|
private static TMDbClient tmdbClient;
|
||||||
private static TMDBCache tmdbCache;
|
private static TMDBCache tmdbCache;
|
||||||
|
private static MastodonClient mastodonClient;
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Starting...");
|
Console.WriteLine("Starting...");
|
||||||
@@ -39,6 +41,14 @@ namespace AnimeAnnouncer
|
|||||||
Console.WriteLine("Using cache");
|
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.NewPost += OnNewPost;
|
||||||
nyaaIndexer.RssReadFinished += OnRssReadFinished;
|
nyaaIndexer.RssReadFinished += OnRssReadFinished;
|
||||||
nyaaIndexer.Start(true);
|
nyaaIndexer.Start(true);
|
||||||
@@ -126,13 +136,13 @@ namespace AnimeAnnouncer
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tmdbCache.SetCacheItem($"ShowCache-{title}", new TMDBCacheItem()
|
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", new TMDBCacheItem()
|
||||||
{
|
{
|
||||||
Title = title,
|
Title = title,
|
||||||
ShowID = supposedShowId,
|
ShowID = supposedShowId,
|
||||||
LatestSeasonNumber = latestSeason.SeasonNumber,
|
LatestSeasonNumber = latestSeason.SeasonNumber,
|
||||||
LastEpisodeNumber = latestSeason.EpisodeCount
|
LastEpisodeNumber = latestSeason.EpisodeCount
|
||||||
}).Start();
|
});
|
||||||
Console.WriteLine($"{title} Added to cache");
|
Console.WriteLine($"{title} Added to cache");
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
@@ -156,9 +166,20 @@ namespace AnimeAnnouncer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Announce
|
||||||
|
if(mastodonClient != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_ = mastodonClient.PublishStatus($"<p>Finished Dubbed Airing Anime</p> {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!");
|
Console.WriteLine($"Choosing {title} as a finished season!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user