diff --git a/MetaNodes/TheMovieDb/TVShowLookup.cs b/MetaNodes/TheMovieDb/TVShowLookup.cs index 5c93252e..6071000f 100644 --- a/MetaNodes/TheMovieDb/TVShowLookup.cs +++ b/MetaNodes/TheMovieDb/TVShowLookup.cs @@ -1,4 +1,5 @@ -using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.RegularExpressions; using DM.MovieApi; using DM.MovieApi.ApiResponse; using DM.MovieApi.MovieDb.Movies; @@ -78,25 +79,13 @@ public class TVShowLookup : Node args.Logger?.ILog("Lookup TV Show: " + lookupName); string tvShowInfoCacheKey = $"TVShowInfo: {lookupName} ({year})"; - TVShowInfo result = null; - var showInfoJson = args.Cache.GetJson(tvShowInfoCacheKey); - if(string.IsNullOrWhiteSpace(showInfoJson) == false) + TVShowInfo result =args.Cache.GetObject(tvShowInfoCacheKey); + if (result != null) { - 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); - } + args.Logger?.ILog("Got TV show info from cache: " + result.Name + "\n" + + System.Text.Json.JsonSerializer.Serialize(result)); } - - if (result == null) + else { result = LookupShow(lookupName, year); diff --git a/MetaNodes/ThirdParty/TheMovieDbWrapper/MovieDb/TV/TVShowInfo.cs b/MetaNodes/ThirdParty/TheMovieDbWrapper/MovieDb/TV/TVShowInfo.cs index d7b02231..bf65161c 100644 --- a/MetaNodes/ThirdParty/TheMovieDbWrapper/MovieDb/TV/TVShowInfo.cs +++ b/MetaNodes/ThirdParty/TheMovieDbWrapper/MovieDb/TV/TVShowInfo.cs @@ -1,56 +1,123 @@ -// ReSharper disable UnusedAutoPropertyAccessor.Local - -using System.Runtime.Serialization; +using System.Runtime.Serialization; +using System.Text.Json.Serialization; using DM.MovieApi.MovieDb.Genres; namespace DM.MovieApi.MovieDb.TV; +/// +/// Represents TV show information, including metadata such as name, popularity, and genre details. +/// [DataContract] public class TVShowInfo { - [DataMember( Name = "id" )] + /// + /// Gets or sets the unique identifier for the TV show. + /// + [DataMember(Name = "id")] + [JsonPropertyName("id")] public int Id { get; set; } - [DataMember( Name = "name" )] + /// + /// Gets or sets the name of the TV show. + /// + [DataMember(Name = "name")] + [JsonPropertyName("name")] public string Name { get; set; } - [DataMember( Name = "original_name" )] + /// + /// Gets or sets the original name of the TV show. + /// + [DataMember(Name = "original_name")] + [JsonPropertyName("original_name")] public string OriginalName { get; set; } - [DataMember( Name = "poster_path" )] + /// + /// Gets or sets the URL path to the poster image. + /// + [DataMember(Name = "poster_path")] + [JsonPropertyName("poster_path")] public string PosterPath { get; set; } - [DataMember( Name = "backdrop_path" )] + /// + /// Gets or sets the URL path to the backdrop image. + /// + [DataMember(Name = "backdrop_path")] + [JsonPropertyName("backdrop_path")] public string BackdropPath { get; set; } - [DataMember( Name = "popularity" )] + /// + /// Gets or sets the popularity score of the TV show. + /// + [DataMember(Name = "popularity")] + [JsonPropertyName("popularity")] public double Popularity { get; set; } - [DataMember( Name = "vote_average" )] + /// + /// Gets or sets the average vote rating of the TV show. + /// + [DataMember(Name = "vote_average")] + [JsonPropertyName("vote_average")] public double VoteAverage { get; set; } - [DataMember( Name = "vote_count" )] + /// + /// Gets or sets the total number of votes received. + /// + [DataMember(Name = "vote_count")] + [JsonPropertyName("vote_count")] public int VoteCount { get; set; } - [DataMember( Name = "overview" )] + /// + /// Gets or sets the overview or summary of the TV show. + /// + [DataMember(Name = "overview")] + [JsonPropertyName("overview")] public string Overview { get; set; } - [DataMember( Name = "first_air_date" )] + /// + /// Gets or sets the first air date of the TV show. + /// + [DataMember(Name = "first_air_date")] + [JsonPropertyName("first_air_date")] public DateTime FirstAirDate { get; set; } - [DataMember( Name = "origin_country" )] + /// + /// Gets or sets the origin countries of the TV show. + /// + [DataMember(Name = "origin_country")] + [JsonPropertyName("origin_country")] public List OriginCountry { get; set; } - [DataMember(Name = "genre_ids")] public List GenreIds { get; set; } = []; + /// + /// Gets or sets the list of genre IDs associated with the TV show. + /// + [DataMember(Name = "genre_ids")] + [JsonPropertyName("genre_ids")] + public List GenreIds { get; set; } = []; + + /// + /// Gets or sets the list of genres associated with the TV show. + /// This property is not serialized to JSON. + /// public List Genres { get; internal set; } = []; + /// + /// Gets or sets the original language of the TV show. + /// [DataMember(Name = "original_language")] + [JsonPropertyName("original_language")] public string OriginalLanguage { get; set; } + /// + /// Initializes a new instance of the class. + /// public TVShowInfo() { } + /// + /// Returns a string representation of the TV show. + /// + /// A formatted string containing the name, ID, and first air date. public override string ToString() => $"{Name} ({Id} - {FirstAirDate:yyyy-MM-dd})"; }