Allow default/forced tag without setting language

This commit is contained in:
Joe Rogers
2021-11-27 20:13:21 +01:00
parent 3eec137100
commit 4a20ae6cb4
2 changed files with 48 additions and 4 deletions

View File

@@ -120,6 +120,12 @@ namespace MediaBrowser.Providers.MediaInfo
while (languageSpan.Length > 0)
{
var lastDot = languageSpan.LastIndexOf('.');
if (lastDot < videoFileNameWithoutExtension.Length)
{
languageSpan = ReadOnlySpan<char>.Empty;
break;
}
var currentSlice = languageSpan[lastDot..];
if (currentSlice.Equals(".default", StringComparison.OrdinalIgnoreCase)
|| currentSlice.Equals(".forced", StringComparison.OrdinalIgnoreCase)
@@ -133,12 +139,19 @@ namespace MediaBrowser.Providers.MediaInfo
break;
}
// Try to translate to three character code
// Be flexible and check against both the full and three character versions
var language = languageSpan.ToString();
var culture = _localization.FindLanguageInfo(language);
if (string.IsNullOrWhiteSpace(language))
{
language = null;
}
else
{
// Try to translate to three character code
// Be flexible and check against both the full and three character versions
var culture = _localization.FindLanguageInfo(language);
language = culture == null ? language : culture.ThreeLetterISOLanguageName;
language = culture == null ? language : culture.ThreeLetterISOLanguageName;
}
mediaStream = new MediaStream
{