Added configuration reading, redis caching basic, hopefully fixed future season issue
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using AnimeAnnouncer.RSS;
|
||||
using AnimeAnnouncer.Cache;
|
||||
using AnimeAnnouncer.RSS;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using TMDbLib.Client;
|
||||
|
||||
namespace AnimeAnnouncer
|
||||
@@ -7,13 +9,33 @@ namespace AnimeAnnouncer
|
||||
{
|
||||
private static NyaaIndexer nyaaIndexer= new NyaaIndexer();
|
||||
|
||||
private const String TMDBApiKey = "";
|
||||
|
||||
private static TMDbClient tmdbClient = new TMDbClient(TMDBApiKey);
|
||||
private static TMDbClient tmdbClient;
|
||||
private static TMDBCache tmdbCache;
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Starting...");
|
||||
|
||||
var configurationBuilder = new ConfigurationBuilder();
|
||||
|
||||
configurationBuilder.SetBasePath(System.IO.Directory.GetCurrentDirectory()); // errors here
|
||||
configurationBuilder.AddJsonFile(path: "appSettings.json", optional: false, reloadOnChange: true); // errors here
|
||||
|
||||
var config = configurationBuilder.Build();
|
||||
|
||||
String TMDBApiKey = config["TMDBApiKey"];
|
||||
if(String.IsNullOrEmpty(TMDBApiKey))
|
||||
{
|
||||
Console.WriteLine("ERROR: API key not found in config.");
|
||||
return;
|
||||
}
|
||||
tmdbClient = new TMDbClient(TMDBApiKey);
|
||||
|
||||
String redisCacheConnectionString = config["redisConnectionString"];
|
||||
if(!String.IsNullOrEmpty(redisCacheConnectionString))
|
||||
{
|
||||
tmdbCache = new TMDBCache(redisCacheConnectionString);
|
||||
}
|
||||
|
||||
nyaaIndexer.NewPost += OnNewPost;
|
||||
nyaaIndexer.RssReadFinished += OnRssReadFinished;
|
||||
nyaaIndexer.Start(true);
|
||||
@@ -61,7 +83,13 @@ namespace AnimeAnnouncer
|
||||
|
||||
var showResult = await tmdbClient.GetTvShowAsync(supposedShowId);
|
||||
|
||||
var latestSeason = showResult.Seasons.OrderByDescending(s => s.SeasonNumber).First();
|
||||
var latestSeason = showResult.Seasons.Where(s => s.AirDate.HasValue && s.AirDate.Value < DateTime.Now).OrderByDescending(s => s.SeasonNumber).FirstOrDefault();
|
||||
|
||||
if(latestSeason == null)
|
||||
{
|
||||
Console.WriteLine("Unable to find a viable season from TMDB.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(latestSeason.SeasonNumber != int.Parse(season))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user