From 9d192fadfee80ce33269311e190358304437c6df Mon Sep 17 00:00:00 2001 From: nilaoda Date: Mon, 17 Oct 2022 13:37:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=AD=E8=A8=80=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs | 2 +- src/N_m3u8DL-RE/Util/MergeUtil.cs | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index f91df89..3cee7f0 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -433,7 +433,7 @@ namespace N_m3u8DL_RE.CommandLine Environment.Exit(0); } - var rootCommand = new RootCommand("N_m3u8DL-RE (Beta version) 20221014") + var rootCommand = new RootCommand("N_m3u8DL-RE (Beta version) 20221017") { Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, BinaryMerge, DelAfterDone, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, diff --git a/src/N_m3u8DL-RE/Util/MergeUtil.cs b/src/N_m3u8DL-RE/Util/MergeUtil.cs index ea90585..3f7e2e0 100644 --- a/src/N_m3u8DL-RE/Util/MergeUtil.cs +++ b/src/N_m3u8DL-RE/Util/MergeUtil.cs @@ -267,7 +267,13 @@ namespace N_m3u8DL_RE.Util private static void ConvertLangCodeAndDisplayName(OutputFile outputFile) { if (string.IsNullOrEmpty(outputFile.LangCode)) return; + var originalLangCode = outputFile.LangCode; + + // zh-cn => zh outputFile.LangCode = outputFile.LangCode.Split('-')[0]; + // ENG => eng + if (outputFile.LangCode.ToUpper() == outputFile.LangCode) outputFile.LangCode = outputFile.LangCode.ToLower(); + CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); foreach (var c in cultures) { @@ -280,11 +286,45 @@ namespace N_m3u8DL_RE.Util } break; } + else if (outputFile.LangCode == c.ThreeLetterISOLanguageName) + { + if (string.IsNullOrEmpty(outputFile.Description)) + { + outputFile.Description = c.DisplayName; + } + break; + } } + //有的播放器不识别zho,统一转为chi if (outputFile.LangCode == "zho") outputFile.LangCode = "chi"; else if (outputFile.LangCode == "cmn") outputFile.LangCode = "chi"; else if (outputFile.LangCode == "yue") outputFile.LangCode = "chi"; + else if (outputFile.LangCode == "cn") outputFile.LangCode = "chi"; + else if (outputFile.LangCode == "cz") outputFile.LangCode = "chi"; + else if (outputFile.LangCode == "Cantonese" || outputFile.LangCode == "Mandarin") + { + outputFile.Description = outputFile.LangCode; + outputFile.LangCode = "chi"; + } + else if (outputFile.LangCode == "Vietnamese") + { + outputFile.Description = outputFile.LangCode; + outputFile.LangCode = "vie"; + } + else if (outputFile.LangCode == "English") + { + outputFile.Description = outputFile.LangCode; + outputFile.LangCode = "eng"; + } + else if (outputFile.LangCode == "Thai") + { + outputFile.Description = outputFile.LangCode; + outputFile.LangCode = "tha"; + } + + //无描述,则把LangCode当作描述 + if (string.IsNullOrEmpty(outputFile.Description)) outputFile.Description = originalLangCode; } } }