aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs
diff options
context:
space:
mode:
authorErik W <22211983+Lampan-git@users.noreply.github.com>2025-10-13 21:47:16 +0200
committerGitHub <noreply@github.com>2025-10-13 13:47:16 -0600
commit2c7d2d4719c670afe83530c06ba267074a0196e3 (patch)
treea25e1cc3f1b1f4d1b612fd5c781662939436f21a /MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs
parent5c519270b84cc07928bd45a14f38f9b1add24d01 (diff)
Handle es-419 in TMDb (#14946)
Diffstat (limited to 'MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs')
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs16
1 files changed, 13 insertions, 3 deletions
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs
index 2db8cae7e..f5e59a278 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs
@@ -105,14 +105,15 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// Normalizes a language string for use with TMDb's include image language parameter.
/// </summary>
/// <param name="preferredLanguage">The preferred language as either a 2 letter code with or without country code.</param>
+ /// <param name="countryCode">The country code, ISO 3166-1.</param>
/// <returns>The comma separated language string.</returns>
- public static string GetImageLanguagesParam(string preferredLanguage)
+ public static string GetImageLanguagesParam(string preferredLanguage, string? countryCode = null)
{
var languages = new List<string>();
if (!string.IsNullOrEmpty(preferredLanguage))
{
- preferredLanguage = NormalizeLanguage(preferredLanguage);
+ preferredLanguage = NormalizeLanguage(preferredLanguage, countryCode);
languages.Add(preferredLanguage);
@@ -140,15 +141,24 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// Normalizes a language string for use with TMDb's language parameter.
/// </summary>
/// <param name="language">The language code.</param>
+ /// <param name="countryCode">The country code.</param>
/// <returns>The normalized language code.</returns>
[return: NotNullIfNotNull(nameof(language))]
- public static string? NormalizeLanguage(string? language)
+ public static string? NormalizeLanguage(string? language, string? countryCode = null)
{
if (string.IsNullOrEmpty(language))
{
return language;
}
+ // Handle es-419 (Latin American Spanish) by converting to regional variant
+ if (string.Equals(language, "es-419", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(countryCode))
+ {
+ language = string.Equals(countryCode, "AR", StringComparison.OrdinalIgnoreCase)
+ ? "es-AR"
+ : "es-MX";
+ }
+
// TMDb requires this to be uppercase
// Everything after the hyphen must be written in uppercase due to a way TMDb wrote their API.
// See here: https://www.themoviedb.org/talk/5119221d760ee36c642af4ad?page=3#56e372a0c3a3685a9e0019ab