修复外部输入文件language code丢失问题

This commit is contained in:
nilaoda 2022-12-09 23:45:17 +08:00
parent ef94ab0adf
commit 6cc466f8a3
1 changed files with 17 additions and 19 deletions

View File

@ -514,11 +514,9 @@ sr;srp
/// <param name="outputFile"></param> /// <param name="outputFile"></param>
public static void ConvertLangCodeAndDisplayName(OutputFile outputFile) public static void ConvertLangCodeAndDisplayName(OutputFile outputFile)
{ {
if (string.IsNullOrEmpty(outputFile.LangCode) || outputFile.MediaType == null) return; if (string.IsNullOrEmpty(outputFile.LangCode)) return;
var originalLangCode = outputFile.LangCode; var originalLangCode = outputFile.LangCode;
if (string.IsNullOrEmpty(outputFile.Description))
{
//先直接查找 //先直接查找
var lang = ALL_LANGS.FirstOrDefault(a => a.ExtendCode.Equals(outputFile.LangCode, StringComparison.OrdinalIgnoreCase) || a.Code.Equals(outputFile.LangCode, StringComparison.OrdinalIgnoreCase)); var lang = ALL_LANGS.FirstOrDefault(a => a.ExtendCode.Equals(outputFile.LangCode, StringComparison.OrdinalIgnoreCase) || a.Code.Equals(outputFile.LangCode, StringComparison.OrdinalIgnoreCase));
//处理特殊的扩展语言标记 //处理特殊的扩展语言标记
@ -532,13 +530,13 @@ sr;srp
if (lang != null) if (lang != null)
{ {
outputFile.LangCode = lang.Code; outputFile.LangCode = lang.Code;
if (string.IsNullOrEmpty(outputFile.Description))
outputFile.Description = outputFile.MediaType == Common.Enum.MediaType.SUBTITLES ? lang.Description : lang.DescriptionAudio; outputFile.Description = outputFile.MediaType == Common.Enum.MediaType.SUBTITLES ? lang.Description : lang.DescriptionAudio;
} }
else else if (outputFile.LangCode == null)
{ {
outputFile.LangCode = "und"; //无法识别直接置为und outputFile.LangCode = "und"; //无法识别直接置为und
} }
}
//无描述则把LangCode当作描述 //无描述则把LangCode当作描述
if (string.IsNullOrEmpty(outputFile.Description)) outputFile.Description = originalLangCode; if (string.IsNullOrEmpty(outputFile.Description)) outputFile.Description = originalLangCode;