Compare commits
2 Commits
6a518b0c9b
...
965bd58799
| Author | SHA1 | Date | |
|---|---|---|---|
| 965bd58799 | |||
| 039e3189eb |
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using AnimeAnnouncer.Cache;
|
||||
@@ -81,6 +82,14 @@ namespace AnimeAnnouncer
|
||||
|
||||
static void OnRssReadFinished()
|
||||
{
|
||||
if(DateTime.Today.Day == 1)
|
||||
{
|
||||
if(!tmdbCache.KeyExists($"UpcomingAnnounced-{DateTime.Today.Year}-{DateTime.Today.Month}").Result)
|
||||
{
|
||||
CreateAiringMonthPost().Wait();
|
||||
tmdbCache.SetPair($"UpcomingAnnounced-{DateTime.Today.Year}-{DateTime.Today.Month}", "1").Wait();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -300,14 +309,13 @@ namespace AnimeAnnouncer
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = tmdbCache.SetPair($"ShowAnnounced-{supposedShowId}", "1");
|
||||
_ = tmdbCache.SetPair($"ShowAnnounced-{supposedShowId}", latestSeasonNumber.ToString());
|
||||
}
|
||||
if(mastodonClient != null && cachedShow != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
PostStatus(cachedShow);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -318,6 +326,46 @@ namespace AnimeAnnouncer
|
||||
Console.WriteLine($"Choosing {title} as a finished season!");
|
||||
}
|
||||
|
||||
|
||||
private static async Task CreateAiringMonthPost()
|
||||
{
|
||||
var airingSoon = await tmdbCache.GetAiringList();
|
||||
DateTime beginningOfMonth = DateTime.Today;
|
||||
DateTime endOfMonth = DateTime.Today.AddMonths(1);
|
||||
var airingThisMonth = airingSoon.Where(p => p.LastAirDate >= beginningOfMonth && p.LastAirDate <= endOfMonth).ToList();
|
||||
String statusText = $"DUBBED anime airing this month (probably){Environment.NewLine + Environment.NewLine}";
|
||||
int cnt = 1;
|
||||
for(int i = 0;i < airingThisMonth.Count;i++, cnt++)
|
||||
{
|
||||
var airing = airingThisMonth[i];
|
||||
if(!await tmdbCache.KeyExists($"ShowAnnounced-{airing.ShowID}"))
|
||||
{ //TODO: fix for seasons
|
||||
statusText += $"{cnt}. {airing.Title} on {airing.LastAirDate:MM/dd/yyyy}{Environment.NewLine}";
|
||||
}
|
||||
}
|
||||
int neededPostCount = (int)Math.Ceiling((decimal)statusText.Length / 500);
|
||||
if(neededPostCount >= 2)
|
||||
{
|
||||
statusText = statusText[..497] + "...";
|
||||
}
|
||||
_ = mastodonClient.PublishStatus(statusText,
|
||||
Visibility.Public, null);
|
||||
/*
|
||||
else
|
||||
{
|
||||
for(cnt = 1; cnt < neededPostCount; cnt++)
|
||||
{
|
||||
//go back and find a line break
|
||||
String postPart = "";
|
||||
//_ = mastodonClient.PublishStatus(${statusText},
|
||||
// Visibility.Public, null);
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static async void PostStatus(TMDBCacheItem cachedShow)
|
||||
{
|
||||
//get poster
|
||||
|
||||
Reference in New Issue
Block a user