diff --git a/src/N_m3u8DL-RE.Common/N_m3u8DL-RE.Common.csproj b/src/N_m3u8DL-RE.Common/N_m3u8DL-RE.Common.csproj index bbd9d1d..d95cde4 100644 --- a/src/N_m3u8DL-RE.Common/N_m3u8DL-RE.Common.csproj +++ b/src/N_m3u8DL-RE.Common/N_m3u8DL-RE.Common.csproj @@ -12,29 +12,5 @@ - - - - True - True - ResString.resx - - - - - - PublicResXFileCodeGenerator - true - ResString.Designer.cs - - - PublicResXFileCodeGenerator - true - - - PublicResXFileCodeGenerator - true - - diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.Designer.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.Designer.cs deleted file mode 100644 index 839f803..0000000 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.Designer.cs +++ /dev/null @@ -1,596 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace N_m3u8DL_RE.Common.Resource { - using System; - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class ResString { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal ResString() { - } - - /// - /// 返回此类使用的缓存的 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("N_m3u8DL_RE.Common.Resource.ResString", typeof(ResString).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 重写当前线程的 CurrentUICulture 属性,对 - /// 使用此强类型资源类的所有资源查找执行重写。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// 查找类似 fMP4 is detected, binary merging is automatically enabled 的本地化字符串。 - /// - public static string autoBinaryMerge { - get { - return ResourceManager.GetString("autoBinaryMerge", resourceCulture); - } - } - - /// - /// 查找类似 Dolby Vision content is detected, binary merging is automatically enabled 的本地化字符串。 - /// - public static string autoBinaryMerge2 { - get { - return ResourceManager.GetString("autoBinaryMerge2", resourceCulture); - } - } - - /// - /// 查找类似 An unrecognized encryption method is detected, binary merging is automatically enabled 的本地化字符串。 - /// - public static string autoBinaryMerge3 { - get { - return ResourceManager.GetString("autoBinaryMerge3", resourceCulture); - } - } - - /// - /// 查找类似 Bad m3u8 的本地化字符串。 - /// - public static string badM3u8 { - get { - return ResourceManager.GetString("badM3u8", resourceCulture); - } - } - - /// - /// 查找类似 Binary merging... 的本地化字符串。 - /// - public static string binaryMerge { - get { - return ResourceManager.GetString("binaryMerge", resourceCulture); - } - } - - /// - /// 查找类似 Verifying the validity of the last segment 的本地化字符串。 - /// - public static string checkingLast { - get { - return ResourceManager.GetString("checkingLast", resourceCulture); - } - } - - /// - /// 查找类似 Add Params of input Url to segments, useful for some websites, such as kakao.com 的本地化字符串。 - /// - public static string cmd_appendUrlParams { - get { - return ResourceManager.GetString("cmd_appendUrlParams", resourceCulture); - } - } - - /// - /// 查找类似 Automatically selects the best tracks of all types 的本地化字符串。 - /// - public static string cmd_autoSelect { - get { - return ResourceManager.GetString("cmd_autoSelect", resourceCulture); - } - } - - /// - /// 查找类似 Binary merge 的本地化字符串。 - /// - public static string cmd_binaryMerge { - get { - return ResourceManager.GetString("cmd_binaryMerge", resourceCulture); - } - } - - /// - /// 查找类似 Check if the actual number of segments downloaded matches the expected number 的本地化字符串。 - /// - public static string cmd_checkSegmentsCount { - get { - return ResourceManager.GetString("cmd_checkSegmentsCount", resourceCulture); - } - } - - /// - /// 查找类似 Full path to the tool used for MP4 decryption, like C:\Tools\mp4decrypt.exe 的本地化字符串。 - /// - public static string cmd_decryptionBinaryPath { - get { - return ResourceManager.GetString("cmd_decryptionBinaryPath", resourceCulture); - } - } - - /// - /// 查找类似 Delete temporary files when done 的本地化字符串。 - /// - public static string cmd_delAfterDone { - get { - return ResourceManager.GetString("cmd_delAfterDone", resourceCulture); - } - } - - /// - /// 查找类似 Full path to the ffmpeg binary, like C:\Tools\ffmpeg.exe 的本地化字符串。 - /// - public static string cmd_ffmpegBinaryPath { - get { - return ResourceManager.GetString("cmd_ffmpegBinaryPath", resourceCulture); - } - } - - /// - /// 查找类似 Pass custom header(s) to server, Example: - ///-H "Cookie: mycookie" -H "User-Agent: iOS" 的本地化字符串。 - /// - public static string cmd_header { - get { - return ResourceManager.GetString("cmd_header", resourceCulture); - } - } - - /// - /// 查找类似 Input Url or File 的本地化字符串。 - /// - public static string cmd_Input { - get { - return ResourceManager.GetString("cmd_Input", resourceCulture); - } - } - - /// - /// 查找类似 Pass decryption key(s) to mp4decrypt/shaka-packager. format: - ///--key KID1:KEY1 --key KID2:KEY2 的本地化字符串。 - /// - public static string cmd_keys { - get { - return ResourceManager.GetString("cmd_keys", resourceCulture); - } - } - - /// - /// 查找类似 Set the kid-key file, the program will search the KEY with KID from the file.(Very large file are not recommended) 的本地化字符串。 - /// - public static string cmd_keyText { - get { - return ResourceManager.GetString("cmd_keyText", resourceCulture); - } - } - - /// - /// 查找类似 Failed to get KEY, ignore. 的本地化字符串。 - /// - public static string cmd_loadKeyFailed { - get { - return ResourceManager.GetString("cmd_loadKeyFailed", resourceCulture); - } - } - - /// - /// 查找类似 Set log level 的本地化字符串。 - /// - public static string cmd_logLevel { - get { - return ResourceManager.GetString("cmd_logLevel", resourceCulture); - } - } - - /// - /// 查找类似 Decrypt MP4 segments in real time 的本地化字符串。 - /// - public static string cmd_MP4RealTimeDecryption { - get { - return ResourceManager.GetString("cmd_MP4RealTimeDecryption", resourceCulture); - } - } - - /// - /// 查找类似 Set output directory 的本地化字符串。 - /// - public static string cmd_saveDir { - get { - return ResourceManager.GetString("cmd_saveDir", resourceCulture); - } - } - - /// - /// 查找类似 Set output filename 的本地化字符串。 - /// - public static string cmd_saveName { - get { - return ResourceManager.GetString("cmd_saveName", resourceCulture); - } - } - - /// - /// 查找类似 的本地化字符串。 - /// - public static string cmd_savePattern { - get { - return ResourceManager.GetString("cmd_savePattern", resourceCulture); - } - } - - /// - /// 查找类似 Skip download 的本地化字符串。 - /// - public static string cmd_skipDownload { - get { - return ResourceManager.GetString("cmd_skipDownload", resourceCulture); - } - } - - /// - /// 查找类似 Skip segments merge 的本地化字符串。 - /// - public static string cmd_skipMerge { - get { - return ResourceManager.GetString("cmd_skipMerge", resourceCulture); - } - } - - /// - /// 查找类似 Subtitle output format 的本地化字符串。 - /// - public static string cmd_subFormat { - get { - return ResourceManager.GetString("cmd_subFormat", resourceCulture); - } - } - - /// - /// 查找类似 Select only subtitle tracks 的本地化字符串。 - /// - public static string cmd_subOnly { - get { - return ResourceManager.GetString("cmd_subOnly", resourceCulture); - } - } - - /// - /// 查找类似 Automatically fix subtitles 的本地化字符串。 - /// - public static string cmd_subtitleFix { - get { - return ResourceManager.GetString("cmd_subtitleFix", resourceCulture); - } - } - - /// - /// 查找类似 Set download thread count 的本地化字符串。 - /// - public static string cmd_threadCount { - get { - return ResourceManager.GetString("cmd_threadCount", resourceCulture); - } - } - - /// - /// 查找类似 Set temporary file directory 的本地化字符串。 - /// - public static string cmd_tmpDir { - get { - return ResourceManager.GetString("cmd_tmpDir", resourceCulture); - } - } - - /// - /// 查找类似 Set UI language 的本地化字符串。 - /// - public static string cmd_uiLanguage { - get { - return ResourceManager.GetString("cmd_uiLanguage", resourceCulture); - } - } - - /// - /// 查找类似 Give these arguments to the URL Processors. 的本地化字符串。 - /// - public static string cmd_urlProcessorArgs { - get { - return ResourceManager.GetString("cmd_urlProcessorArgs", resourceCulture); - } - } - - /// - /// 查找类似 Use shaka-packager instead of mp4decrypt 的本地化字符串。 - /// - public static string cmd_useShakaPackager { - get { - return ResourceManager.GetString("cmd_useShakaPackager", resourceCulture); - } - } - - /// - /// 查找类似 Write meta json after parsed 的本地化字符串。 - /// - public static string cmd_writeMetaJson { - get { - return ResourceManager.GetString("cmd_writeMetaJson", resourceCulture); - } - } - - /// - /// 查找类似 Fetch: 的本地化字符串。 - /// - public static string fetch { - get { - return ResourceManager.GetString("fetch", resourceCulture); - } - } - - /// - /// 查找类似 ffmpeg merging... 的本地化字符串。 - /// - public static string ffmpegMerge { - get { - return ResourceManager.GetString("ffmpegMerge", resourceCulture); - } - } - - /// - /// 查找类似 ffmpeg not found, please download at: https://ffmpeg.org/download.html 的本地化字符串。 - /// - public static string ffmpegNotFound { - get { - return ResourceManager.GetString("ffmpegNotFound", resourceCulture); - } - } - - /// - /// 查找类似 Extracting TTML(raw) subtitle... 的本地化字符串。 - /// - public static string fixingTTML { - get { - return ResourceManager.GetString("fixingTTML", resourceCulture); - } - } - - /// - /// 查找类似 Extracting TTML(mp4) subtitle... 的本地化字符串。 - /// - public static string fixingTTMLmp4 { - get { - return ResourceManager.GetString("fixingTTMLmp4", resourceCulture); - } - } - - /// - /// 查找类似 Extracting VTT(raw) subtitle... 的本地化字符串。 - /// - public static string fixingVTT { - get { - return ResourceManager.GetString("fixingVTT", resourceCulture); - } - } - - /// - /// 查找类似 Extracting VTT(mp4) subtitle... 的本地化字符串。 - /// - public static string fixingVTTmp4 { - get { - return ResourceManager.GetString("fixingVTTmp4", resourceCulture); - } - } - - /// - /// 查找类似 No Processor matched 的本地化字符串。 - /// - public static string keyProcessorNotFound { - get { - return ResourceManager.GetString("keyProcessorNotFound", resourceCulture); - } - } - - /// - /// 查找类似 Live stream found 的本地化字符串。 - /// - public static string liveFound { - get { - return ResourceManager.GetString("liveFound", resourceCulture); - } - } - - /// - /// 查找类似 Loading URL: 的本地化字符串。 - /// - public static string loadingUrl { - get { - return ResourceManager.GetString("loadingUrl", resourceCulture); - } - } - - /// - /// 查找类似 Master List detected, try parse all streams 的本地化字符串。 - /// - public static string masterM3u8Found { - get { - return ResourceManager.GetString("masterM3u8Found", resourceCulture); - } - } - - /// - /// 查找类似 Content Matched: [white on mediumorchid1]Dynamic Adaptive Streaming over HTTP[/] 的本地化字符串。 - /// - public static string matchDASH { - get { - return ResourceManager.GetString("matchDASH", resourceCulture); - } - } - - /// - /// 查找类似 Content Matched: [white on deepskyblue1]HTTP Live Streaming[/] 的本地化字符串。 - /// - public static string matchHLS { - get { - return ResourceManager.GetString("matchHLS", resourceCulture); - } - } - - /// - /// 查找类似 Input not supported: 的本地化字符串。 - /// - public static string notSupported { - get { - return ResourceManager.GetString("notSupported", resourceCulture); - } - } - - /// - /// 查找类似 Parsing streams... 的本地化字符串。 - /// - public static string parsingStream { - get { - return ResourceManager.GetString("parsingStream", resourceCulture); - } - } - - /// - /// 查找类似 [grey](Move up and down to reveal more streams)[/] 的本地化字符串。 - /// - public static string promptChoiceText { - get { - return ResourceManager.GetString("promptChoiceText", resourceCulture); - } - } - - /// - /// 查找类似 (Press [blue]<space>[/] to toggle a stream, [green]<enter>[/] to accept) 的本地化字符串。 - /// - public static string promptInfo { - get { - return ResourceManager.GetString("promptInfo", resourceCulture); - } - } - - /// - /// 查找类似 Please select [green]what you want to download[/]: 的本地化字符串。 - /// - public static string promptTitle { - get { - return ResourceManager.GetString("promptTitle", resourceCulture); - } - } - - /// - /// 查找类似 Reading media info... 的本地化字符串。 - /// - public static string readingInfo { - get { - return ResourceManager.GetString("readingInfo", resourceCulture); - } - } - - /// - /// 查找类似 Trying to search for KEY from text file... 的本地化字符串。 - /// - public static string searchKey { - get { - return ResourceManager.GetString("searchKey", resourceCulture); - } - } - - /// - /// 查找类似 Segment count check not pass, total: {}, downloaded: {}. 的本地化字符串。 - /// - public static string segmentCountCheckNotPass { - get { - return ResourceManager.GetString("segmentCountCheckNotPass", resourceCulture); - } - } - - /// - /// 查找类似 Selected streams: 的本地化字符串。 - /// - public static string selectedStream { - get { - return ResourceManager.GetString("selectedStream", resourceCulture); - } - } - - /// - /// 查找类似 Start downloading... 的本地化字符串。 - /// - public static string startDownloading { - get { - return ResourceManager.GetString("startDownloading", resourceCulture); - } - } - - /// - /// 查找类似 Extracted, there are {} streams, with {} basic streams, {} audio streams, {} subtitle streams 的本地化字符串。 - /// - public static string streamsInfo { - get { - return ResourceManager.GetString("streamsInfo", resourceCulture); - } - } - - /// - /// 查找类似 Writing meta.json 的本地化字符串。 - /// - public static string writeJson { - get { - return ResourceManager.GetString("writeJson", resourceCulture); - } - } - } -} diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.cs new file mode 100644 index 0000000..a50ae5d --- /dev/null +++ b/src/N_m3u8DL-RE.Common/Resource/ResString.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace N_m3u8DL_RE.Common.Resource +{ + public class ResString + { + public static string autoBinaryMerge { get => GetText("autoBinaryMerge"); } + public static string autoBinaryMerge2 { get => GetText("autoBinaryMerge2"); } + public static string autoBinaryMerge3 { get => GetText("autoBinaryMerge3"); } + public static string badM3u8 { get => GetText("badM3u8"); } + public static string binaryMerge { get => GetText("binaryMerge"); } + public static string checkingLast { get => GetText("checkingLast"); } + public static string cmd_appendUrlParams { get => GetText("cmd_appendUrlParams"); } + public static string cmd_autoSelect { get => GetText("cmd_autoSelect"); } + public static string cmd_binaryMerge { get => GetText("cmd_binaryMerge"); } + public static string cmd_checkSegmentsCount { get => GetText("cmd_checkSegmentsCount"); } + public static string cmd_decryptionBinaryPath { get => GetText("cmd_decryptionBinaryPath"); } + public static string cmd_delAfterDone { get => GetText("cmd_delAfterDone"); } + public static string cmd_ffmpegBinaryPath { get => GetText("cmd_ffmpegBinaryPath"); } + public static string cmd_header { get => GetText("cmd_header"); } + public static string cmd_Input { get => GetText("cmd_Input"); } + public static string cmd_keys { get => GetText("cmd_keys"); } + public static string cmd_keyText { get => GetText("cmd_keyText"); } + public static string cmd_loadKeyFailed { get => GetText("cmd_loadKeyFailed"); } + public static string cmd_logLevel { get => GetText("cmd_logLevel"); } + public static string cmd_MP4RealTimeDecryption { get => GetText("cmd_MP4RealTimeDecryption"); } + public static string cmd_saveDir { get => GetText("cmd_saveDir"); } + public static string cmd_saveName { get => GetText("cmd_saveName"); } + public static string cmd_savePattern { get => GetText("cmd_savePattern"); } + public static string cmd_skipDownload { get => GetText("cmd_skipDownload"); } + public static string cmd_skipMerge { get => GetText("cmd_skipMerge"); } + public static string cmd_subFormat { get => GetText("cmd_subFormat"); } + public static string cmd_subOnly { get => GetText("cmd_subOnly"); } + public static string cmd_subtitleFix { get => GetText("cmd_subtitleFix"); } + public static string cmd_threadCount { get => GetText("cmd_threadCount"); } + public static string cmd_tmpDir { get => GetText("cmd_tmpDir"); } + public static string cmd_uiLanguage { get => GetText("cmd_uiLanguage"); } + public static string cmd_urlProcessorArgs { get => GetText("cmd_urlProcessorArgs"); } + public static string cmd_useShakaPackager { get => GetText("cmd_useShakaPackager"); } + public static string cmd_writeMetaJson { get => GetText("cmd_writeMetaJson"); } + public static string fetch { get => GetText("fetch"); } + public static string ffmpegMerge { get => GetText("ffmpegMerge"); } + public static string ffmpegNotFound { get => GetText("ffmpegNotFound"); } + public static string fixingTTML { get => GetText("fixingTTML"); } + public static string fixingTTMLmp4 { get => GetText("fixingTTMLmp4"); } + public static string fixingVTT { get => GetText("fixingVTT"); } + public static string fixingVTTmp4 { get => GetText("fixingVTTmp4"); } + public static string keyProcessorNotFound { get => GetText("keyProcessorNotFound"); } + public static string liveFound { get => GetText("liveFound"); } + public static string loadingUrl { get => GetText("loadingUrl"); } + public static string masterM3u8Found { get => GetText("masterM3u8Found"); } + public static string matchDASH { get => GetText("matchDASH"); } + public static string matchHLS { get => GetText("matchHLS"); } + public static string notSupported { get => GetText("notSupported"); } + public static string parsingStream { get => GetText("parsingStream"); } + public static string promptChoiceText { get => GetText("promptChoiceText"); } + public static string promptInfo { get => GetText("promptInfo"); } + public static string promptTitle { get => GetText("promptTitle"); } + public static string readingInfo { get => GetText("readingInfo"); } + public static string searchKey { get => GetText("searchKey"); } + public static string segmentCountCheckNotPass { get => GetText("segmentCountCheckNotPass"); } + public static string selectedStream { get => GetText("selectedStream"); } + public static string startDownloading { get => GetText("startDownloading"); } + public static string streamsInfo { get => GetText("streamsInfo"); } + public static string writeJson { get => GetText("writeJson"); } + + private static string GetText(string key) + { + if (!StaticText.LANG_DIC.ContainsKey(key)) + return "<...LANG TEXT MISSING...>"; + + var current = Thread.CurrentThread.CurrentUICulture.Name; + if (current == "zh-CN" || current == "zh-SG" || current == "zh-Hans") + return StaticText.LANG_DIC[key].ZH_CN; + else if (current.StartsWith("zh-")) + return StaticText.LANG_DIC[key].ZH_TW; + else + return StaticText.LANG_DIC[key].EN_US; + } + } +} diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.resx b/src/N_m3u8DL-RE.Common/Resource/ResString.resx deleted file mode 100644 index 17f494e..0000000 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.resx +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Bad m3u8 - - - Input not supported: - - - Loading URL: - - - Content Matched: [white on deepskyblue1]HTTP Live Streaming[/] - - - Master List detected, try parse all streams - - - Fetch: - - - Please select [green]what you want to download[/]: - - - [grey](Move up and down to reveal more streams)[/] - - - (Press [blue]<space>[/] to toggle a stream, [green]<enter>[/] to accept) - - - Extracted, there are {} streams, with {} basic streams, {} audio streams, {} subtitle streams - - - Live stream found - - - Selected streams: - - - Writing meta.json - - - Content Matched: [white on mediumorchid1]Dynamic Adaptive Streaming over HTTP[/] - - - Verifying the validity of the last segment - - - Parsing streams... - - - No Processor matched - - - Start downloading... - - - Segment count check not pass, total: {}, downloaded: {}. - - - Extracting VTT(raw) subtitle... - - - Extracting VTT(mp4) subtitle... - - - Binary merging... - - - Extracting TTML(mp4) subtitle... - - - Extracting TTML(raw) subtitle... - - - Input Url or File - - - Pass custom header(s) to server, Example: --H "Cookie: mycookie" -H "User-Agent: iOS" - - - Set log level - - - Automatically selects the best tracks of all types - - - Select only subtitle tracks - - - Set download thread count - - - Skip segments merge - - - Binary merge - - - Delete temporary files when done - - - Automatically fix subtitles - - - Check if the actual number of segments downloaded matches the expected number - - - Subtitle output format - - - Set temporary file directory - - - Set output directory - - - Set output filename - - - Set UI language - - - Skip download - - - Write meta json after parsed - - - Add Params of input Url to segments, useful for some websites, such as kakao.com - - - - - - Pass decryption key(s) to mp4decrypt/shaka-packager. format: ---key KID1:KEY1 --key KID2:KEY2 - - - Give these arguments to the URL Processors. - - - Decrypt MP4 segments in real time - - - Use shaka-packager instead of mp4decrypt - - - Full path to the tool used for MP4 decryption, like C:\Tools\mp4decrypt.exe - - - Failed to get KEY, ignore. - - - fMP4 is detected, binary merging is automatically enabled - - - Full path to the ffmpeg binary, like C:\Tools\ffmpeg.exe - - - ffmpeg merging... - - - Set the kid-key file, the program will search the KEY with KID from the file.(Very large file are not recommended) - - - Trying to search for KEY from text file... - - - ffmpeg not found, please download at: https://ffmpeg.org/download.html - - - Reading media info... - - - Dolby Vision content is detected, binary merging is automatically enabled - - - An unrecognized encryption method is detected, binary merging is automatically enabled - - \ No newline at end of file diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.zh-Hans.resx b/src/N_m3u8DL-RE.Common/Resource/ResString.zh-Hans.resx deleted file mode 100644 index 8bbc2ca..0000000 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.zh-Hans.resx +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 错误的m3u8 - - - 当前输入不受支持: - - - 加载URL: - - - 内容匹配: [white on deepskyblue1]HTTP Live Streaming[/] - - - 检测到Master列表,开始解析全部流信息 - - - 获取: - - - 请选择 [green]你要下载的内容[/]: - - - [grey](按键盘上下键以浏览更多内容)[/] - - - (按 [blue]空格键[/] 选择流, [green]回车键[/] 完成选择) - - - 已解析, 共计 {} 条媒体流, 基本流 {} 条, 可选音频流 {} 条, 可选字幕流 {} 条 - - - 检测到直播流 - - - 已选择的流: - - - 写出meta.json - - - 内容匹配: [white on mediumorchid1]Dynamic Adaptive Streaming over HTTP[/] - - - 验证最后一个分片有效性 - - - 正在解析媒体信息... - - - 找不到支持的Processor - - - 开始下载... - - - 分片数量校验不通过, 共{}个,已下载{}. - - - 正在提取VTT(raw)字幕... - - - 正在提取VTT(mp4)字幕... - - - 二进制合并中... - - - 正在提取TTML(mp4)字幕... - - - 正在提取TTML(raw)字幕... - - - 链接或文件 - - - 为HTTP请求设置特定的请求头, 例如: --H "Cookie: mycookie" -H "User-Agent: iOS" - - - 设置日志级别 - - - 自动选择所有类型的最佳轨道 - - - 只选取字幕轨道 - - - 设置下载线程数 - - - 跳过合并分片 - - - 二进制合并 - - - 完成后删除临时文件 - - - 自动修正字幕 - - - 检测实际下载的分片数量和预期数量是否匹配 - - - 字幕输出类型 - - - 设置临时文件存储目录 - - - 设置输出目录 - - - 设置保存文件名 - - - 设置UI语言 - - - 跳过下载 - - - 解析后的信息是否输出json文件 - - - 将输入Url的Params添加至分片, 对某些网站很有用, 例如 kakao.com - - - 设置保存文件命名模板, 支持使用变量 - - - 设置解密密钥, 程序调用mp4decrpyt/shaka-packager进行解密. 格式: ---key KID1:KEY1 --key KID2:KEY2 - - - 此字符串将直接传递给URL Processor - - - 实时解密MP4分片 - - - 使用shaka-packager替代mp4decrypt - - - MP4解密所用工具的全路径, 例如 C:\Tools\mp4decrypt.exe - - - 获取KEY失败,忽略读取. - - - 检测到fMP4,自动开启二进制合并 - - - ffmpeg可执行程序全路径, 例如 C:\Tools\ffmpeg.exe - - - 调用ffmpeg合并中... - - - 设置密钥文件,程序将从文件中按KID搜寻KEY以解密.(不建议使用特大文件) - - - 正在尝试从文本文件搜索KEY... - - - 找不到ffmpeg,请自行下载:https://ffmpeg.org/download.html - - - 读取媒体信息... - - - 检测到杜比视界内容,自动开启二进制合并 - - - 检测到无法识别的加密方式,自动开启二进制合并 - - \ No newline at end of file diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.zh-Hant.resx b/src/N_m3u8DL-RE.Common/Resource/ResString.zh-Hant.resx deleted file mode 100644 index 147d752..0000000 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.zh-Hant.resx +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 錯誤的m3u8 - - - 當前輸入不受支援: - - - 載入URL: - - - 內容匹配: [white on deepskyblue1]HTTP Live Streaming[/] - - - 檢測到Master列表,開始解析全部流訊息 - - - 獲取: - - - 請選擇 [green]你要下載的內容[/]: - - - [grey](按鍵盤上下鍵以瀏覽更多內容)[/] - - - (按 [blue]空格鍵[/] 選擇流, [green]確認鍵[/] 完成選擇) - - - 已解析, 共計 {} 條媒體流, 基本流 {} 條, 可選音頻流 {} 條, 可選字幕流 {} 條 - - - 檢測到直播流 - - - 已選擇的流: - - - 寫出meta.json - - - 內容匹配: [white on mediumorchid1]Dynamic Adaptive Streaming over HTTP[/] - - - 驗證最後一個分片有效性 - - - 正在解析媒體信息... - - - 找不到支持的Processor - - - 開始下載... - - - 分片數量校驗不通過, 共{}個,已下載{}. - - - 正在提取VTT(raw)字幕... - - - 正在提取VTT(mp4)字幕... - - - 二進位制合併中... - - - 正在提取TTML(mp4)字幕... - - - 正在提取TTML(raw)字幕... - - - 連結或文件 - - - 為HTTP請求設置特定的請求頭, 例如: --H "Cookie: mycookie" -H "User-Agent: iOS" - - - 設置日誌級別 - - - 自動選擇所有類型的最佳軌道 - - - 只選取字幕軌道 - - - 設置下載執行緒數 - - - 跳過合併分片 - - - 二進位制合併 - - - 完成後刪除臨時文件 - - - 自動修正字幕 - - - 檢測實際下載的分片數量和預期數量是否匹配 - - - 字幕輸出類型 - - - 設置臨時文件儲存目錄 - - - 設置輸出目錄 - - - 設置保存檔案名 - - - 設置UI語言 - - - 跳過下載 - - - 解析後的訊息是否輸出json文件 - - - 將輸入Url的Params添加至分片, 對某些網站很有用, 例如 kakao.com - - - 設置解密密鑰, 程序調用mp4decrpyt/shaka-packager進行解密. 格式: ---key KID1:KEY1 --key KID2:KEY2 - - - 此字符串將直接傳遞給URL Processor - - - 即時解密MP4分片 - - - 使用shaka-packager替代mp4decrypt - - - MP4解密所用工具的全路徑, 例如 C:\Tools\mp4decrypt.exe - - - 獲取KEY失敗,忽略讀取. - - - 檢測到fMP4,自動開啟二進位制合併 - - - ffmpeg可執行程序全路徑, 例如 C:\Tools\ffmpeg.exe - - - 調用ffmpeg合併中... - - - 設置密鑰文件,程序將從文件中按KID搜尋KEY以解密.(不建議使用特大文件) - - - 正在嘗試從文本文件搜尋KEY... - - - 找不到ffmpeg,請自行下載:https://ffmpeg.org/download.html - - - 讀取媒體訊息... - - - 檢測到杜比視界內容,自動開啟二進位制合併 - - - 檢測到無法識別的加密方式,自動開啟二進位制合併 - - \ No newline at end of file diff --git a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs new file mode 100644 index 0000000..0b195e4 --- /dev/null +++ b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs @@ -0,0 +1,370 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace N_m3u8DL_RE.Common.Resource +{ + internal class StaticText + { + public static Dictionary LANG_DIC = new() + { + ["autoBinaryMerge"] = new TextContainer + ( + zhCN: "检测到fMP4,自动开启二进制合并", + zhTW: "檢測到fMP4,自動開啟二進位制合併", + enUS: "fMP4 is detected, binary merging is automatically enabled" + ), + ["autoBinaryMerge2"] = new TextContainer + ( + zhCN: "检测到杜比视界内容,自动开启二进制合并", + zhTW: "檢測到杜比視界內容,自動開啟二進位制合併", + enUS: "Dolby Vision content is detected, binary merging is automatically enabled" + ), + ["autoBinaryMerge3"] = new TextContainer + ( + zhCN: "检测到无法识别的加密方式,自动开启二进制合并", + zhTW: "檢測到無法識別的加密方式,自動開啟二進位制合併", + enUS: "An unrecognized encryption method is detected, binary merging is automatically enabled" + ), + ["badM3u8"] = new TextContainer + ( + zhCN: "错误的m3u8", + zhTW: "錯誤的m3u8", + enUS: "Bad m3u8" + ), + ["binaryMerge"] = new TextContainer + ( + zhCN: "二进制合并中...", + zhTW: "二進位制合併中...", + enUS: "Binary merging..." + ), + ["checkingLast"] = new TextContainer + ( + zhCN: "验证最后一个分片有效性", + zhTW: "驗證最後一個分片有效性", + enUS: "Verifying the validity of the last segment" + ), + ["cmd_appendUrlParams"] = new TextContainer + ( + zhCN: "将输入Url的Params添加至分片, 对某些网站很有用, 例如 kakao.com", + zhTW: "將輸入Url的Params添加至分片, 對某些網站很有用, 例如 kakao.com", + enUS: "Add Params of input Url to segments, useful for some websites, such as kakao.com" + ), + ["cmd_autoSelect"] = new TextContainer + ( + zhCN: "自动选择所有类型的最佳轨道", + zhTW: "自動選擇所有類型的最佳軌道", + enUS: "Automatically selects the best tracks of all types" + ), + ["cmd_binaryMerge"] = new TextContainer + ( + zhCN: "二进制合并", + zhTW: "二進位制合併", + enUS: "Binary merge" + ), + ["cmd_checkSegmentsCount"] = new TextContainer + ( + zhCN: "检测实际下载的分片数量和预期数量是否匹配", + zhTW: "檢測實際下載的分片數量和預期數量是否匹配", + enUS: "Check if the actual number of segments downloaded matches the expected number" + ), + ["cmd_decryptionBinaryPath"] = new TextContainer + ( + zhCN: "MP4解密所用工具的全路径, 例如 C:\\Tools\\mp4decrypt.exe", + zhTW: "MP4解密所用工具的全路徑, 例如 C:\\Tools\\mp4decrypt.exe", + enUS: "Full path to the tool used for MP4 decryption, like C:\\Tools\\mp4decrypt.exe" + ), + ["cmd_delAfterDone"] = new TextContainer + ( + zhCN: "完成后删除临时文件", + zhTW: "完成後刪除臨時文件", + enUS: "Delete temporary files when done" + ), + ["cmd_ffmpegBinaryPath"] = new TextContainer + ( + zhCN: "ffmpeg可执行程序全路径, 例如 C:\\Tools\\ffmpeg.exe", + zhTW: "ffmpeg可執行程序全路徑, 例如 C:\\Tools\\ffmpeg.exe", + enUS: "Full path to the ffmpeg binary, like C:\\Tools\\ffmpeg.exe" + ), + ["cmd_header"] = new TextContainer + ( + zhCN: "为HTTP请求设置特定的请求头, 例如:\r\n-H \"Cookie: mycookie\" -H \"User-Agent: iOS\"", + zhTW: "為HTTP請求設置特定的請求頭, 例如:\r\n-H \"Cookie: mycookie\" -H \"User-Agent: iOS\"", + enUS: "Pass custom header(s) to server, Example:\r\n-H \"Cookie: mycookie\" -H \"User-Agent: iOS\"" + ), + ["cmd_Input"] = new TextContainer + ( + zhCN: "链接或文件", + zhTW: "連結或文件", + enUS: "Input Url or File" + ), + ["cmd_keys"] = new TextContainer + ( + zhCN: "设置解密密钥, 程序调用mp4decrpyt/shaka-packager进行解密. 格式:\r\n--key KID1:KEY1 --key KID2:KEY2", + zhTW: "設置解密密鑰, 程序調用mp4decrpyt/shaka-packager進行解密. 格式:\r\n--key KID1:KEY1 --key KID2:KEY2", + enUS: "Pass decryption key(s) to mp4decrypt/shaka-packager. format:\r\n--key KID1:KEY1 --key KID2:KEY2" + ), + ["cmd_keyText"] = new TextContainer + ( + zhCN: "设置密钥文件,程序将从文件中按KID搜寻KEY以解密.(不建议使用特大文件)", + zhTW: "設置密鑰文件,程序將從文件中按KID搜尋KEY以解密.(不建議使用特大文件)", + enUS: "Set the kid-key file, the program will search the KEY with KID from the file.(Very large file are not recommended)" + ), + ["cmd_loadKeyFailed"] = new TextContainer + ( + zhCN: "获取KEY失败,忽略读取.", + zhTW: "獲取KEY失敗,忽略讀取.", + enUS: "Failed to get KEY, ignore." + ), + ["cmd_logLevel"] = new TextContainer + ( + zhCN: "设置日志级别", + zhTW: "設置日誌級別", + enUS: "Set log level" + ), + ["cmd_MP4RealTimeDecryption"] = new TextContainer + ( + zhCN: "实时解密MP4分片", + zhTW: "即時解密MP4分片", + enUS: "Decrypt MP4 segments in real time" + ), + ["cmd_saveDir"] = new TextContainer + ( + zhCN: "设置输出目录", + zhTW: "設置輸出目錄", + enUS: "Set output directory" + ), + ["cmd_saveName"] = new TextContainer + ( + zhCN: "设置保存文件名", + zhTW: "設置保存檔案名", + enUS: "Set output filename" + ), + ["cmd_savePattern"] = new TextContainer + ( + zhCN: "设置保存文件命名模板, 支持使用变量", + zhTW: "", + enUS: "" + ), + ["cmd_skipDownload"] = new TextContainer + ( + zhCN: "跳过下载", + zhTW: "跳過下載", + enUS: "Skip download" + ), + ["cmd_skipMerge"] = new TextContainer + ( + zhCN: "跳过合并分片", + zhTW: "跳過合併分片", + enUS: "Skip segments merge" + ), + ["cmd_subFormat"] = new TextContainer + ( + zhCN: "字幕输出类型", + zhTW: "字幕輸出類型", + enUS: "Subtitle output format" + ), + ["cmd_subOnly"] = new TextContainer + ( + zhCN: "只选取字幕轨道", + zhTW: "只選取字幕軌道", + enUS: "Select only subtitle tracks" + ), + ["cmd_subtitleFix"] = new TextContainer + ( + zhCN: "自动修正字幕", + zhTW: "自動修正字幕", + enUS: "Automatically fix subtitles" + ), + ["cmd_threadCount"] = new TextContainer + ( + zhCN: "设置下载线程数", + zhTW: "設置下載執行緒數", + enUS: "Set download thread count" + ), + ["cmd_tmpDir"] = new TextContainer + ( + zhCN: "设置临时文件存储目录", + zhTW: "設置臨時文件儲存目錄", + enUS: "Set temporary file directory" + ), + ["cmd_uiLanguage"] = new TextContainer + ( + zhCN: "设置UI语言 (zh-CN, zh-TW, en-US)", + zhTW: "設置UI語言 (zh-CN, zh-TW, en-US)", + enUS: "Set UI language (zh-CN, zh-TW, en-US)" + ), + ["cmd_urlProcessorArgs"] = new TextContainer + ( + zhCN: "此字符串将直接传递给URL Processor", + zhTW: "此字符串將直接傳遞給URL Processor", + enUS: "Give these arguments to the URL Processors." + ), + ["cmd_useShakaPackager"] = new TextContainer + ( + zhCN: "使用shaka-packager替代mp4decrypt", + zhTW: "使用shaka-packager替代mp4decrypt", + enUS: "Use shaka-packager instead of mp4decrypt" + ), + ["cmd_writeMetaJson"] = new TextContainer + ( + zhCN: "解析后的信息是否输出json文件", + zhTW: "解析後的訊息是否輸出json文件", + enUS: "Write meta json after parsed" + ), + ["fetch"] = new TextContainer + ( + zhCN: "获取: ", + zhTW: "獲取: ", + enUS: "Fetch: " + ), + ["ffmpegMerge"] = new TextContainer + ( + zhCN: "调用ffmpeg合并中...", + zhTW: "調用ffmpeg合併中...", + enUS: "ffmpeg merging..." + ), + ["ffmpegNotFound"] = new TextContainer + ( + zhCN: "找不到ffmpeg,请自行下载:https://ffmpeg.org/download.html", + zhTW: "找不到ffmpeg,請自行下載:https://ffmpeg.org/download.html", + enUS: "ffmpeg not found, please download at: https://ffmpeg.org/download.html" + ), + ["fixingTTML"] = new TextContainer + ( + zhCN: "正在提取TTML(raw)字幕...", + zhTW: "正在提取TTML(raw)字幕...", + enUS: "Extracting TTML(raw) subtitle..." + ), + ["fixingTTMLmp4"] = new TextContainer + ( + zhCN: "正在提取TTML(mp4)字幕...", + zhTW: "正在提取TTML(mp4)字幕...", + enUS: "Extracting TTML(mp4) subtitle..." + ), + ["fixingVTT"] = new TextContainer + ( + zhCN: "正在提取VTT(raw)字幕...", + zhTW: "正在提取VTT(raw)字幕...", + enUS: "Extracting VTT(raw) subtitle..." + ), + ["fixingVTTmp4"] = new TextContainer + ( + zhCN: "正在提取VTT(mp4)字幕...", + zhTW: "正在提取VTT(mp4)字幕...", + enUS: "Extracting VTT(mp4) subtitle..." + ), + ["keyProcessorNotFound"] = new TextContainer + ( + zhCN: "找不到支持的Processor", + zhTW: "找不到支持的Processor", + enUS: "No Processor matched" + ), + ["liveFound"] = new TextContainer + ( + zhCN: "检测到直播流", + zhTW: "檢測到直播流", + enUS: "Live stream found" + ), + ["loadingUrl"] = new TextContainer + ( + zhCN: "加载URL: ", + zhTW: "載入URL: ", + enUS: "Loading URL: " + ), + ["masterM3u8Found"] = new TextContainer + ( + zhCN: "检测到Master列表,开始解析全部流信息", + zhTW: "檢測到Master列表,開始解析全部流訊息", + enUS: "Master List detected, try parse all streams" + ), + ["matchDASH"] = new TextContainer + ( + zhCN: "内容匹配: [white on mediumorchid1]Dynamic Adaptive Streaming over HTTP[/]", + zhTW: "內容匹配: [white on mediumorchid1]Dynamic Adaptive Streaming over HTTP[/]", + enUS: "Content Matched: [white on mediumorchid1]Dynamic Adaptive Streaming over HTTP[/]" + ), + ["matchHLS"] = new TextContainer + ( + zhCN: "内容匹配: [white on deepskyblue1]HTTP Live Streaming[/]", + zhTW: "內容匹配: [white on deepskyblue1]HTTP Live Streaming[/]", + enUS: "Content Matched: [white on deepskyblue1]HTTP Live Streaming[/]" + ), + ["notSupported"] = new TextContainer + ( + zhCN: "当前输入不受支持: ", + zhTW: "當前輸入不受支援: ", + enUS: "Input not supported: " + ), + ["parsingStream"] = new TextContainer + ( + zhCN: "正在解析媒体信息...", + zhTW: "正在解析媒體信息...", + enUS: "Parsing streams..." + ), + ["promptChoiceText"] = new TextContainer + ( + zhCN: "[grey](按键盘上下键以浏览更多内容)[/]", + zhTW: "[grey](按鍵盤上下鍵以瀏覽更多內容)[/]", + enUS: "[grey](Move up and down to reveal more streams)[/]" + ), + ["promptInfo"] = new TextContainer + ( + zhCN: "(按 [blue]空格键[/] 选择流, [green]回车键[/] 完成选择)", + zhTW: "(按 [blue]空格鍵[/] 選擇流, [green]確認鍵[/] 完成選擇)", + enUS: "(Press [blue][/] to toggle a stream, [green][/] to accept)" + ), + ["promptTitle"] = new TextContainer + ( + zhCN: "请选择 [green]你要下载的内容[/]:", + zhTW: "請選擇 [green]你要下載的內容[/]:", + enUS: "Please select [green]what you want to download[/]:" + ), + ["readingInfo"] = new TextContainer + ( + zhCN: "读取媒体信息...", + zhTW: "讀取媒體訊息...", + enUS: "Reading media info..." + ), + ["searchKey"] = new TextContainer + ( + zhCN: "正在尝试从文本文件搜索KEY...", + zhTW: "正在嘗試從文本文件搜尋KEY...", + enUS: "Trying to search for KEY from text file..." + ), + ["segmentCountCheckNotPass"] = new TextContainer + ( + zhCN: "分片数量校验不通过, 共{}个,已下载{}.", + zhTW: "分片數量校驗不通過, 共{}個,已下載{}.", + enUS: "Segment count check not pass, total: {}, downloaded: {}." + ), + ["selectedStream"] = new TextContainer + ( + zhCN: "已选择的流:", + zhTW: "已選擇的流:", + enUS: "Selected streams:" + ), + ["startDownloading"] = new TextContainer + ( + zhCN: "开始下载...", + zhTW: "開始下載...", + enUS: "Start downloading..." + ), + ["streamsInfo"] = new TextContainer + ( + zhCN: "已解析, 共计 {} 条媒体流, 基本流 {} 条, 可选音频流 {} 条, 可选字幕流 {} 条", + zhTW: "已解析, 共計 {} 條媒體流, 基本流 {} 條, 可選音頻流 {} 條, 可選字幕流 {} 條", + enUS: "Extracted, there are {} streams, with {} basic streams, {} audio streams, {} subtitle streams" + ), + ["writeJson"] = new TextContainer + ( + zhCN: "写出meta json", + zhTW: "寫出meta json", + enUS: "Writing meta json" + ), + + }; + } +} diff --git a/src/N_m3u8DL-RE.Common/Resource/TextContainer.cs b/src/N_m3u8DL-RE.Common/Resource/TextContainer.cs new file mode 100644 index 0000000..13ae7cc --- /dev/null +++ b/src/N_m3u8DL-RE.Common/Resource/TextContainer.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace N_m3u8DL_RE.Common.Resource +{ + internal class TextContainer + { + public string ZH_CN { get; set; } + public string ZH_TW { get; set; } + public string EN_US { get; set; } + + public TextContainer(string zhCN, string zhTW, string enUS) + { + ZH_CN = zhCN; + ZH_TW = zhTW; + EN_US = enUS; + } + } +} diff --git a/src/N_m3u8DL-RE.Common/Util/GlobalUtil.cs b/src/N_m3u8DL-RE.Common/Util/GlobalUtil.cs index ef31d36..25791e2 100644 --- a/src/N_m3u8DL-RE.Common/Util/GlobalUtil.cs +++ b/src/N_m3u8DL-RE.Common/Util/GlobalUtil.cs @@ -35,7 +35,7 @@ namespace N_m3u8DL_RE.Common.Util { return JsonSerializer.Serialize(sList, Context.ListStreamSpec); } - return JsonSerializer.Serialize(o, Options); + return "{NOT SUPPORTED}"; } //此函数用于格式化输出时长 diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index 2743efa..8842584 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -4,10 +4,10 @@ using N_m3u8DL_RE.Enum; using System.CommandLine; using System.CommandLine.Binding; using System.Globalization; +using System.Linq; namespace N_m3u8DL_RE.CommandLine { - internal class CommandInvoker { private readonly static Argument Input = new(name: "input", description: ResString.cmd_Input); @@ -73,20 +73,14 @@ namespace N_m3u8DL_RE.CommandLine KeyTextFile = bindingContext.ParseResult.GetValueForOption(KeyTextFile), }; - //在这里设置语言 - string loc = "en-US"; - string currLoc = Thread.CurrentThread.CurrentUICulture.Name; - if (currLoc == "zh-CN" || currLoc == "zh-SG") loc = "zh-Hans"; - else if (currLoc.StartsWith("zh-")) loc = "zh-Hant"; - - //以用户选择优先 - loc = option.UILanguage ?? loc; - - CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(loc); - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(loc); - Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(loc); - ResString.Culture = CultureInfo.GetCultureInfo(loc); + //以用户选择语言为准优先 + if (option.UILanguage != null && new List { "en-US", "zh-CN", "zh-TW" }.Contains(option.UILanguage)) + { + CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(option.UILanguage); + Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(option.UILanguage); + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(option.UILanguage); + } return option; } diff --git a/src/N_m3u8DL-RE/Directory.Build.props b/src/N_m3u8DL-RE/Directory.Build.props index 630e98d..0c1d38f 100644 --- a/src/N_m3u8DL-RE/Directory.Build.props +++ b/src/N_m3u8DL-RE/Directory.Build.props @@ -8,8 +8,7 @@ link true false - true - zh-Hans;zh-Hant;en-US + zh-CN;zh-TW;en-US 7.0.0-* diff --git a/src/N_m3u8DL-RE/Program.cs b/src/N_m3u8DL-RE/Program.cs index d575d9a..1fafa8f 100644 --- a/src/N_m3u8DL-RE/Program.cs +++ b/src/N_m3u8DL-RE/Program.cs @@ -1,26 +1,18 @@ using N_m3u8DL_RE.Parser.Config; using N_m3u8DL_RE.Common.Entity; using N_m3u8DL_RE.Common.Enum; -using N_m3u8DL_RE.Parser.Util; using N_m3u8DL_RE.Parser; using Spectre.Console; -using System.Text.Json; -using System.Text.Json.Serialization; using N_m3u8DL_RE.Common.Resource; using N_m3u8DL_RE.Common.Log; using System.Globalization; using System.Text; -using System.Text.RegularExpressions; -using System.Collections.Concurrent; using N_m3u8DL_RE.Common.Util; using N_m3u8DL_RE.Processor; -using N_m3u8DL_RE.Downloader; using N_m3u8DL_RE.Config; using N_m3u8DL_RE.Util; -using System.Diagnostics; using N_m3u8DL_RE.DownloadManager; using N_m3u8DL_RE.CommandLine; -using System.Reflection; namespace N_m3u8DL_RE { @@ -28,6 +20,24 @@ namespace N_m3u8DL_RE { static async Task Main(string[] args) { + string loc = "en-US"; + string currLoc = Thread.CurrentThread.CurrentUICulture.Name; + if (currLoc == "zh-CN" || currLoc == "zh-SG") loc = "zh-CN"; + else if (currLoc.StartsWith("zh-")) loc = "zh-TW"; + + //处理用户-h等请求 + var index = -1; + var list = new List(args); + if ((index = list.IndexOf("--ui-language")) != -1 && list.Count > index + 1 && new List { "en-US", "zh-CN", "zh-TW" }.Contains(list[index + 1])) + { + Console.WriteLine(111); + loc = list[index + 1]; + } + + CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(loc); + Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(loc); + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(loc); + await CommandInvoker.InvokeArgs(args, DoWorkAsync); }