From 3df2a95cac1e34f3392abbf239c9c7eb137e88cd Mon Sep 17 00:00:00 2001 From: cvium Date: Thu, 24 Sep 2020 20:31:57 +0200 Subject: [PATCH] Cleanup in TmdbUtils --- .../Plugins/Tmdb/TmdbUtils.cs | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs index 1fb85e1a36..b754a07953 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; -using System.Net.Mime; using MediaBrowser.Model.Entities; using TMDbLib.Objects.General; @@ -18,11 +17,6 @@ namespace MediaBrowser.Providers.Plugins.Tmdb /// public const string BaseTmdbUrl = "https://www.themoviedb.org/"; - /// - /// URL of the TMDB API instance to use. - /// - public const string BaseTmdbApiUrl = "https://api.themoviedb.org/"; - /// /// Name of the provider. /// @@ -38,11 +32,6 @@ namespace MediaBrowser.Providers.Plugins.Tmdb /// public const int MaxCastMembers = 15; - /// - /// Value of the Accept header for requests to the provider. - /// - public static readonly string[] AcceptHeaders = { MediaTypeNames.Application.Json, "image/*" }; - /// /// The crew types to keep. /// @@ -77,9 +66,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb return PersonType.Writer; } - return null; + return string.Empty; } + /// + /// Determines whether a video is a trailer. + /// + /// The TMDb video. + /// A boolean indicating whether the video is a trailer. public static bool IsTrailerType(Video video) { return video.Site.Equals("youtube", StringComparison.OrdinalIgnoreCase) @@ -87,6 +81,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb || !video.Type.Equals("teaser", StringComparison.OrdinalIgnoreCase)); } + /// + /// Normalizes a language string for use with TMDb's include image language parameter. + /// + /// The preferred language as either a 2 letter code with or without country code. + /// The comma separated language string. public static string GetImageLanguagesParam(string preferredLanguage) { var languages = new List(); @@ -116,6 +115,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb return string.Join(',', languages); } + /// + /// Normalizes a language string for use with TMDb's language parameter. + /// + /// The language code. + /// The normalized language code. public static string NormalizeLanguage(string language) { if (string.IsNullOrEmpty(language)) @@ -136,6 +140,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb return language; } + /// + /// Adjusts the image's language code preferring the 5 letter language code eg. en-US. + /// + /// The image's actual language code. + /// The requested language code. + /// The language code. public static string AdjustImageLanguage(string imageLanguage, string requestLanguage) { if (!string.IsNullOrEmpty(imageLanguage)