|
|
@ -267,9 +267,21 @@ namespace MediaBrowser.Providers.Movies
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(preferredLanguage))
|
|
|
|
if (!string.IsNullOrEmpty(preferredLanguage))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
preferredLanguage = NormalizeLanguage(preferredLanguage);
|
|
|
|
|
|
|
|
|
|
|
|
languages.Add(preferredLanguage);
|
|
|
|
languages.Add(preferredLanguage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (preferredLanguage.Length == 5) // like en-US
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Currenty, TMDB supports 2-letter language codes only
|
|
|
|
|
|
|
|
// They are planning to change this in the future, thus we're
|
|
|
|
|
|
|
|
// supplying both codes if we're having a 5-letter code.
|
|
|
|
|
|
|
|
languages.Add(preferredLanguage.Substring(0, 2));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
languages.Add("null");
|
|
|
|
languages.Add("null");
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase))
|
|
|
|
if (!string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
languages.Add("en");
|
|
|
|
languages.Add("en");
|
|
|
@ -280,18 +292,35 @@ namespace MediaBrowser.Providers.Movies
|
|
|
|
|
|
|
|
|
|
|
|
public static string NormalizeLanguage(string language)
|
|
|
|
public static string NormalizeLanguage(string language)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// They require this to be uppercase
|
|
|
|
if (!string.IsNullOrEmpty(language))
|
|
|
|
// https://emby.media/community/index.php?/topic/32454-fr-follow-tmdbs-new-language-api-update/?p=311148
|
|
|
|
|
|
|
|
var parts = language.Split('-');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (parts.Length == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
language = parts[0] + "-" + parts[1].ToUpper();
|
|
|
|
// They require this to be uppercase
|
|
|
|
|
|
|
|
// https://emby.media/community/index.php?/topic/32454-fr-follow-tmdbs-new-language-api-update/?p=311148
|
|
|
|
|
|
|
|
var parts = language.Split('-');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (parts.Length == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
language = parts[0] + "-" + parts[1].ToUpper();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return language;
|
|
|
|
return language;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string AdjustImageLanguage(string imageLanguage, string requestLanguage)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(imageLanguage)
|
|
|
|
|
|
|
|
&& !string.IsNullOrEmpty(requestLanguage)
|
|
|
|
|
|
|
|
&& requestLanguage.Length > 2
|
|
|
|
|
|
|
|
&& imageLanguage.Length == 2
|
|
|
|
|
|
|
|
&& requestLanguage.StartsWith(imageLanguage, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return requestLanguage;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return imageLanguage;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Fetches the main result.
|
|
|
|
/// Fetches the main result.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|