Fix image searching to prioritize explicit language match if searching in English (#8946)

This commit is contained in:
Brad Beattie 2022-12-29 09:15:48 -05:00 committed by GitHub
parent d7992bda67
commit 4ee1b78a80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,24 +24,27 @@ namespace MediaBrowser.Model.Extensions
requestedLanguage = "en";
}
var isRequestedLanguageEn = string.Equals(requestedLanguage, "en", StringComparison.OrdinalIgnoreCase);
return remoteImageInfos.OrderByDescending(i =>
{
// Image priority ordering:
// - Images that match the requested language
// - Images with no language
// - TODO: Images that match the original language
// - Images in English
// - Images that don't match the requested language
if (string.Equals(requestedLanguage, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
return 4;
}
if (string.IsNullOrEmpty(i.Language))
{
// Assume empty image language is likely to be English.
return isRequestedLanguageEn ? 3 : 2;
return 3;
}
if (!isRequestedLanguageEn && string.Equals(i.Language, "en", StringComparison.OrdinalIgnoreCase))
if (string.Equals(i.Language, "en", StringComparison.OrdinalIgnoreCase))
{
// Prioritize English over non-requested languages.
return 2;
}