FF-1981: TV Show Lookup using cache

This commit is contained in:
John Andrews
2025-01-30 19:39:27 +13:00
parent 279d964187
commit 7a191b4698

View File

@@ -78,12 +78,25 @@ public class TVShowLookup : Node
args.Logger?.ILog("Lookup TV Show: " + lookupName);
string tvShowInfoCacheKey = $"TVShowInfo: {lookupName} ({year})";
TVShowInfo result = args.Cache.GetObject<TVShowInfo>(tvShowInfoCacheKey);
if (result != null)
TVShowInfo result = null;
var showInfoJson = args.Cache.GetJson(tvShowInfoCacheKey);
if(string.IsNullOrWhiteSpace(showInfoJson) == false)
{
args.Logger?.ILog("Got TV show info from cache: " + result.Name + "\n" + System.Text.Json.JsonSerializer.Serialize(result));
try
{
result = System.Text.Json.JsonSerializer.Deserialize<TVShowInfo>(showInfoJson);
if (result != null)
{
args.Logger?.ILog("Got TV show info from cache: " + result.Name + "\n" + System.Text.Json.JsonSerializer.Serialize(result));
}
}
catch (Exception ex)
{
args.Logger?.WLog("Failed to deserialize TV SHow Info Json: " + ex.Message + "\n" + showInfoJson);
}
}
else
if (result == null)
{
result = LookupShow(lookupName, year);