Compare commits
2 Commits
5cfcecc5c3
...
8dcc153806
| Author | SHA1 | Date | |
|---|---|---|---|
| 8dcc153806 | |||
| 41c75ee3f2 |
@@ -29,7 +29,7 @@ public class TMDBCache
|
|||||||
var db = redis.GetDatabase();
|
var db = redis.GetDatabase();
|
||||||
String jsonItem = await db.StringGetAsync(key);
|
String jsonItem = await db.StringGetAsync(key);
|
||||||
|
|
||||||
if(!String.IsNullOrEmpty(jsonItem))
|
if (!String.IsNullOrEmpty(jsonItem))
|
||||||
return JsonSerializer.Deserialize<TMDBCacheItem>(jsonItem);
|
return JsonSerializer.Deserialize<TMDBCacheItem>(jsonItem);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
@@ -37,7 +37,7 @@ public class TMDBCache
|
|||||||
|
|
||||||
public async Task RemoveCacheItem(String key)
|
public async Task RemoveCacheItem(String key)
|
||||||
{
|
{
|
||||||
var db =redis.GetDatabase();
|
var db = redis.GetDatabase();
|
||||||
_ = await db.KeyDeleteAsync(key);
|
_ = await db.KeyDeleteAsync(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public class TMDBCache
|
|||||||
|
|
||||||
String jsonItem = await db.StringGetAsync("AiringSoon");
|
String jsonItem = await db.StringGetAsync("AiringSoon");
|
||||||
|
|
||||||
if(!String.IsNullOrEmpty(jsonItem))
|
if (!String.IsNullOrEmpty(jsonItem))
|
||||||
return JsonSerializer.Deserialize<List<AiringSoonItem>>(jsonItem);
|
return JsonSerializer.Deserialize<List<AiringSoonItem>>(jsonItem);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
@@ -70,4 +70,9 @@ public class TMDBCache
|
|||||||
var db = redis.GetDatabase();
|
var db = redis.GetDatabase();
|
||||||
await db.StringSetAsync(key, value);
|
await db.StringSetAsync(key, value);
|
||||||
}
|
}
|
||||||
|
public async Task<String?> GetStringValue(String key)
|
||||||
|
{
|
||||||
|
var db = redis.GetDatabase();
|
||||||
|
return await db.StringGetAsync(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Security.Cryptography.X509Certificates;
|
|||||||
using AnimeAnnouncer.Cache;
|
using AnimeAnnouncer.Cache;
|
||||||
using AnimeAnnouncer.RSS;
|
using AnimeAnnouncer.RSS;
|
||||||
using Mastonet;
|
using Mastonet;
|
||||||
|
using Mastonet.Entities;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using TMDbLib.Client;
|
using TMDbLib.Client;
|
||||||
@@ -60,15 +61,32 @@ namespace AnimeAnnouncer
|
|||||||
if(airingSoonList == null)
|
if(airingSoonList == null)
|
||||||
airingSoonList = new List<AiringSoonItem>();
|
airingSoonList = new List<AiringSoonItem>();
|
||||||
|
|
||||||
|
if (args.Any(p => p == "--show-airing-list"))
|
||||||
|
{
|
||||||
|
PrintAiringList();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nyaaIndexer.NewPost += OnNewPost;
|
nyaaIndexer.NewPost += OnNewPost;
|
||||||
nyaaIndexer.RssReadFinished += OnRssReadFinished;
|
nyaaIndexer.RssReadFinished += OnRssReadFinished;
|
||||||
//nyaaIndexer.IterationSleepTime = 60;
|
nyaaIndexer.IterationSleepTime = 60;
|
||||||
nyaaIndexer.Start(true);
|
nyaaIndexer.Start(false);
|
||||||
|
|
||||||
Console.WriteLine("Press enter to quit...");
|
Console.WriteLine("Press enter to quit...");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PrintAiringList()
|
||||||
|
{
|
||||||
|
var airingThisHalf = airingSoonList.Where(a => a.LastAirDate > DateTime.Now && a.LastAirDate.Value.Subtract(DateTime.Now) < TimeSpan.FromDays(180)).ToList();
|
||||||
|
int cnt = 1;
|
||||||
|
for(int i = 0;i < airingThisHalf.Count;i++)
|
||||||
|
{
|
||||||
|
var airing = airingThisHalf[i];
|
||||||
|
Console.WriteLine($"{cnt++}. {airing.Title} on {airing.LastAirDate:MM/dd/yyyy}{Environment.NewLine}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static async void OnNewPost(RSS.NyaaItem item)
|
static async void OnNewPost(RSS.NyaaItem item)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -270,7 +288,8 @@ namespace AnimeAnnouncer
|
|||||||
seasonOverride = finaleConfirmed = true;
|
seasonOverride = finaleConfirmed = true;
|
||||||
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", cachedShow);
|
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", cachedShow);
|
||||||
|
|
||||||
if(targetSeason != null && (targetSeason.Episodes.OrderBy(e => e.Order).First().AirDate + TimeSpan.FromDays(180)) > DateTime.Now && (showResult.NextEpisodeToAir.AirDate + TimeSpan.FromDays(30)) > DateTime.Now)
|
if(targetSeason != null && (targetSeason.Episodes.OrderBy(e => e.Order).First().AirDate + TimeSpan.FromDays(180)) > DateTime.Now &&
|
||||||
|
((showResult.NextEpisodeToAir ?? showResult.LastEpisodeToAir).AirDate + TimeSpan.FromDays(30)) > DateTime.Now)
|
||||||
UpdateAiringShowList(cachedShow);
|
UpdateAiringShowList(cachedShow);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -303,7 +322,10 @@ namespace AnimeAnnouncer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Announce if unique
|
// Announce if unique
|
||||||
if(await tmdbCache.KeyExists($"ShowAnnounced-{supposedShowId}"))
|
var lastAnnouncedSeason = await tmdbCache.GetStringValue($"ShowAnnounced-{supposedShowId}");
|
||||||
|
Int32 lastSeason = 0;
|
||||||
|
if (lastAnnouncedSeason != null && Int32.TryParse(lastAnnouncedSeason, out lastSeason) &&
|
||||||
|
latestSeasonNumber <= lastSeason)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{title} has been previously announced, so avoiding announcing it again.");
|
Console.WriteLine($"{title} has been previously announced, so avoiding announcing it again.");
|
||||||
return;
|
return;
|
||||||
@@ -408,8 +430,12 @@ namespace AnimeAnnouncer
|
|||||||
}
|
}
|
||||||
statusText += $"..{anidbLink}";
|
statusText += $"..{anidbLink}";
|
||||||
|
|
||||||
_ = mastodonClient.PublishStatus(statusText,
|
var status = await mastodonClient.PublishStatus(statusText,
|
||||||
Visibility.Public, mediaIds: attachment != null ? new String[] { attachment.Id } : null);
|
Visibility.Public, mediaIds: attachment != null ? new String[] { attachment.Id } : null);
|
||||||
|
if(String.IsNullOrEmpty(status.Id))
|
||||||
|
{
|
||||||
|
Console.WriteLine("An error has occurred posting the status update");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private static async void UpdateAiringShowList(TMDBCacheItem cachedShow)
|
private static async void UpdateAiringShowList(TMDBCacheItem cachedShow)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace MassTorrentAdd
|
|||||||
transmissionDirectoryName = System.Text.RegularExpressions.Regex.Replace(transmissionDirectoryName, @"E\d{2,3}.*?(\d{3,4}p)", " $1");
|
transmissionDirectoryName = System.Text.RegularExpressions.Regex.Replace(transmissionDirectoryName, @"E\d{2,3}.*?(\d{3,4}p)", " $1");
|
||||||
transmissionDirectoryName = System.Text.RegularExpressions.Regex.Replace(transmissionDirectoryName, @"\s\(.*?\)$", "");
|
transmissionDirectoryName = System.Text.RegularExpressions.Regex.Replace(transmissionDirectoryName, @"\s\(.*?\)$", "");
|
||||||
transmissionDirectoryName = destinationFolder + (destinationFolder.EndsWith("/") ? String.Empty : "/") + transmissionDirectoryName.Replace(" ", ".");
|
transmissionDirectoryName = destinationFolder + (destinationFolder.EndsWith("/") ? String.Empty : "/") + transmissionDirectoryName.Replace(" ", ".");
|
||||||
Console.WriteLine("to " + transmissionDirectoryName);
|
Console.WriteLine($"{items.Count()} item(s) to {transmissionDirectoryName}");
|
||||||
|
|
||||||
Console.WriteLine("Continue?");
|
Console.WriteLine("Continue?");
|
||||||
if(Console.ReadKey().KeyChar != 'y')
|
if(Console.ReadKey().KeyChar != 'y')
|
||||||
|
|||||||
Reference in New Issue
Block a user