From 7a191b4698a95a2bbbaffa4a965e196de7ee7497 Mon Sep 17 00:00:00 2001 From: John Andrews Date: Thu, 30 Jan 2025 19:39:27 +1300 Subject: [PATCH] FF-1981: TV Show Lookup using cache --- MetaNodes/TheMovieDb/TVShowLookup.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/MetaNodes/TheMovieDb/TVShowLookup.cs b/MetaNodes/TheMovieDb/TVShowLookup.cs index 1c73dae7..5c93252e 100644 --- a/MetaNodes/TheMovieDb/TVShowLookup.cs +++ b/MetaNodes/TheMovieDb/TVShowLookup.cs @@ -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(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(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);