Merge pull request #507 from DineshSolanki/#505-Add-collection-support-to-searchMulti

Co-authored-by: Tim Eisele <Shadowghost@users.noreply.github.com>
This commit is contained in:
Cody Robibero 2024-09-03 13:52:02 -06:00 committed by GitHub
commit aa9f0b3068
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 8 deletions

View File

@ -28,6 +28,9 @@ namespace TMDbLib.Objects.General
Season = 6,
[EnumValue("tv_season")]
TvSeason = 7
TvSeason = 7,
[EnumValue("collection")]
Collection = 8
}
}

View File

@ -1,26 +1,58 @@
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<string, JToken> _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; }

View File

@ -37,6 +37,7 @@ namespace TMDbLib.Utilities.Converters
MediaType.TvEpisode => new SearchTvEpisode(),
MediaType.Season => new SearchTvSeason(),
MediaType.TvSeason => new SearchTvSeason(),
MediaType.Collection => new SearchCollection(),
_ => throw new ArgumentOutOfRangeException(),
};
}