update language normalization

This commit is contained in:
Luke Pulverenti 2016-09-22 18:04:48 -04:00
parent 2c78e43aad
commit 35acc01e03

View File

@ -691,17 +691,17 @@ namespace MediaBrowser.Providers.Manager
} }
var orderedResults = new List<MetadataResult<TItemType>>(); var orderedResults = new List<MetadataResult<TItemType>>();
var preferredLanguage = NormalizeLanguage(id.MetadataLanguage);
if (string.IsNullOrEmpty(id.MetadataLanguage))
{
orderedResults.AddRange(results);
}
else
{
// prioritize results with matching ResultLanguage // prioritize results with matching ResultLanguage
foreach (var result in results) foreach (var result in results)
{ {
if (!string.IsNullOrEmpty(result.ResultLanguage) && result.ResultLanguage == id.MetadataLanguage && result.QueriedById) if (!result.QueriedById)
{
break;
}
if (string.Equals(NormalizeLanguage(result.ResultLanguage), preferredLanguage, StringComparison.OrdinalIgnoreCase) && result.QueriedById)
{ {
orderedResults.Add(result); orderedResults.Add(result);
} }
@ -715,7 +715,6 @@ namespace MediaBrowser.Providers.Manager
orderedResults.Add(result); orderedResults.Add(result);
} }
} }
}
foreach (var result in results) foreach (var result in results)
{ {
@ -725,6 +724,15 @@ namespace MediaBrowser.Providers.Manager
return refreshResult; return refreshResult;
} }
private string NormalizeLanguage(string language)
{
if (string.IsNullOrWhiteSpace(language))
{
return "en-us";
}
return language;
}
private void MergeNewData(TItemType source, TIdType lookupInfo) private void MergeNewData(TItemType source, TIdType lookupInfo)
{ {
// Copy new provider id's that may have been obtained // Copy new provider id's that may have been obtained