diff --git a/TMDbLib/Objects/General/MediaType.cs b/TMDbLib/Objects/General/MediaType.cs index b113d3d3..420e5c27 100644 --- a/TMDbLib/Objects/General/MediaType.cs +++ b/TMDbLib/Objects/General/MediaType.cs @@ -28,6 +28,9 @@ public enum MediaType Season = 6, [EnumValue("tv_season")] - TvSeason = 7 + TvSeason = 7, + + [EnumValue("collection")] + Collection = 8 } } \ No newline at end of file diff --git a/TMDbLib/Objects/Search/SearchCollection.cs b/TMDbLib/Objects/Search/SearchCollection.cs index 691f1db6..105134a6 100644 --- a/TMDbLib/Objects/Search/SearchCollection.cs +++ b/TMDbLib/Objects/Search/SearchCollection.cs @@ -1,26 +1,59 @@ +using System.Collections.Generic; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace TMDbLib.Objects.Search { - public class SearchCollection + public class SearchCollection : SearchBase { + // Property to hold additional data from the JSON + [JsonExtensionData] + private IDictionary _additionalData; + [JsonProperty("adult")] public bool Adult { get; set; } [JsonProperty("backdrop_path")] public string BackdropPath { get; set; } - - [JsonProperty("id")] - public int Id { get; set; } + + private string _name; + private string _originalName; [JsonProperty("name")] - public string Name { get; set; } + public string Name + { + get + { + // If _name is not set, attempt to retrieve the "title" property from additional data + if (_name == null && _additionalData != null && _additionalData.TryGetValue("title", out var nameToken)) + { + return nameToken.ToString(); + } + + return _name; + } + set => _name = value; + } [JsonProperty("original_language")] public string OriginalLanguage { get; set; } - + [JsonProperty("original_name")] - public string OriginalName { get; set; } + public string OriginalName + { + get + { + // If _originalName is not set, attempt to retrieve the "original_title" property from additional data + if (_originalName == null && _additionalData != null && + _additionalData.TryGetValue("original_title", out var originalNameToken)) + { + return originalNameToken.ToString(); + } + + return _originalName; + } + set => _originalName = value; + } [JsonProperty("overview")] public string Overview { get; set; } diff --git a/TMDbLib/Utilities/Converters/SearchBaseConverter.cs b/TMDbLib/Utilities/Converters/SearchBaseConverter.cs index f659e5db..1e2f2c5c 100644 --- a/TMDbLib/Utilities/Converters/SearchBaseConverter.cs +++ b/TMDbLib/Utilities/Converters/SearchBaseConverter.cs @@ -37,6 +37,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist MediaType.TvEpisode => new SearchTvEpisode(), MediaType.Season => new SearchTvSeason(), MediaType.TvSeason => new SearchTvSeason(), + MediaType.Collection => new SearchCollection(), _ => throw new ArgumentOutOfRangeException(), }; }