优化语言标签识别

This commit is contained in:
nilaoda 2022-10-17 13:37:44 +08:00
parent fb81212da5
commit 9d192fadfe
2 changed files with 41 additions and 1 deletions

View File

@ -433,7 +433,7 @@ namespace N_m3u8DL_RE.CommandLine
Environment.Exit(0); 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, Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount,
BinaryMerge, DelAfterDone, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, BinaryMerge, DelAfterDone, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix,

View File

@ -267,7 +267,13 @@ namespace N_m3u8DL_RE.Util
private static void ConvertLangCodeAndDisplayName(OutputFile outputFile) private static void ConvertLangCodeAndDisplayName(OutputFile outputFile)
{ {
if (string.IsNullOrEmpty(outputFile.LangCode)) return; if (string.IsNullOrEmpty(outputFile.LangCode)) return;
var originalLangCode = outputFile.LangCode;
// zh-cn => zh
outputFile.LangCode = outputFile.LangCode.Split('-')[0]; 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); CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
foreach (var c in cultures) foreach (var c in cultures)
{ {
@ -280,11 +286,45 @@ namespace N_m3u8DL_RE.Util
} }
break; break;
} }
else if (outputFile.LangCode == c.ThreeLetterISOLanguageName)
{
if (string.IsNullOrEmpty(outputFile.Description))
{
outputFile.Description = c.DisplayName;
}
break;
}
} }
//有的播放器不识别zho统一转为chi //有的播放器不识别zho统一转为chi
if (outputFile.LangCode == "zho") outputFile.LangCode = "chi"; if (outputFile.LangCode == "zho") outputFile.LangCode = "chi";
else if (outputFile.LangCode == "cmn") outputFile.LangCode = "chi"; else if (outputFile.LangCode == "cmn") outputFile.LangCode = "chi";
else if (outputFile.LangCode == "yue") 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;
} }
} }
} }