From 6cc466f8a3f4fcccc38a225d88f86aa5592f329b Mon Sep 17 00:00:00 2001 From: nilaoda Date: Fri, 9 Dec 2022 23:45:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=96=E9=83=A8=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=96=87=E4=BB=B6language=20code=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE/Util/LanguageCodeUtil.cs | 36 +++++++++++------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/N_m3u8DL-RE/Util/LanguageCodeUtil.cs b/src/N_m3u8DL-RE/Util/LanguageCodeUtil.cs index c8c4822..62a0ba0 100644 --- a/src/N_m3u8DL-RE/Util/LanguageCodeUtil.cs +++ b/src/N_m3u8DL-RE/Util/LanguageCodeUtil.cs @@ -514,30 +514,28 @@ sr;srp /// 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; - 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)); + //处理特殊的扩展语言标记 + if (lang == null) { - //先直接查找 - var lang = ALL_LANGS.FirstOrDefault(a => a.ExtendCode.Equals(outputFile.LangCode, StringComparison.OrdinalIgnoreCase) || a.Code.Equals(outputFile.LangCode, StringComparison.OrdinalIgnoreCase)); - //处理特殊的扩展语言标记 - if (lang == null) - { - //2位转3位 - var l = ConvertTwoToThree(outputFile.LangCode.Split('-').First()); - lang = ALL_LANGS.FirstOrDefault(a => a.ExtendCode.Equals(l, StringComparison.OrdinalIgnoreCase) || a.Code.Equals(l, StringComparison.OrdinalIgnoreCase)); - } + //2位转3位 + var l = ConvertTwoToThree(outputFile.LangCode.Split('-').First()); + lang = ALL_LANGS.FirstOrDefault(a => a.ExtendCode.Equals(l, StringComparison.OrdinalIgnoreCase) || a.Code.Equals(l, StringComparison.OrdinalIgnoreCase)); + } - if (lang != null) - { - outputFile.LangCode = lang.Code; + if (lang != null) + { + outputFile.LangCode = lang.Code; + if (string.IsNullOrEmpty(outputFile.Description)) outputFile.Description = outputFile.MediaType == Common.Enum.MediaType.SUBTITLES ? lang.Description : lang.DescriptionAudio; - } - else - { - outputFile.LangCode = "und"; //无法识别直接置为und - } + } + else if (outputFile.LangCode == null) + { + outputFile.LangCode = "und"; //无法识别直接置为und } //无描述,则把LangCode当作描述