From fc212e5e5f698482abbf19912787cd2691bae981 Mon Sep 17 00:00:00 2001 From: crobibero Date: Thu, 24 Dec 2020 08:16:50 -0700 Subject: [PATCH] Remove JsonOmdbNotAvailableConverterFactory --- .../JsonOmdbNotAvailableConverterFactory.cs | 36 ----------- .../Plugins/Omdb/OmdbProvider.cs | 60 +++++++++---------- 2 files changed, 30 insertions(+), 66 deletions(-) delete mode 100644 MediaBrowser.Common/Json/Converters/JsonOmdbNotAvailableConverterFactory.cs diff --git a/MediaBrowser.Common/Json/Converters/JsonOmdbNotAvailableConverterFactory.cs b/MediaBrowser.Common/Json/Converters/JsonOmdbNotAvailableConverterFactory.cs deleted file mode 100644 index 5994ce9226..0000000000 --- a/MediaBrowser.Common/Json/Converters/JsonOmdbNotAvailableConverterFactory.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace MediaBrowser.Common.Json.Converters -{ - /// - /// Json Omdb converter factory. - /// - /// - /// Remove when Omdb is moved to plugin. - /// - public class JsonOmdbNotAvailableConverterFactory : JsonConverterFactory - { - /// - public override bool CanConvert(Type typeToConvert) - { - return (typeToConvert.IsGenericType - && typeToConvert.GetGenericTypeDefinition() == typeof(Nullable<>) - && typeToConvert.GenericTypeArguments[0].IsValueType) - || typeToConvert == typeof(string); - } - - /// - public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) - { - if (typeToConvert == typeof(string)) - { - return (JsonConverter)Activator.CreateInstance(typeof(JsonOmdbNotAvailableStringConverter)); - } - - var structType = typeToConvert.GenericTypeArguments[0]; - return (JsonConverter)Activator.CreateInstance(typeof(JsonOmdbNotAvailableStructConverter<>).MakeGenericType(structType)); - } - } -} diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs index 1ebd1b13a3..e700e6969b 100644 --- a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs @@ -471,101 +471,101 @@ namespace MediaBrowser.Providers.Plugins.Omdb public class SeasonRootObject { - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Title { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string seriesID { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStructConverter))] public int? Season { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStructConverter))] public int? totalSeasons { get; set; } public RootObject[] Episodes { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Response { get; set; } } public class RootObject { - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Title { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Year { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Rated { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Released { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Runtime { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Genre { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Director { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Writer { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Actors { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Plot { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Language { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Country { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Awards { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Poster { get; set; } public List Ratings { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Metascore { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string imdbRating { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string imdbVotes { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string imdbID { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Type { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string DVD { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string BoxOffice { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Production { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Website { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStringConverter))] public string Response { get; set; } - [JsonConverter(typeof(JsonOmdbNotAvailableConverterFactory))] + [JsonConverter(typeof(JsonOmdbNotAvailableStructConverter))] public int? Episode { get; set; } public float? GetRottenTomatoScore()