diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.cs index e72fa71..4f4603e 100644 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.cs +++ b/src/N_m3u8DL-RE.Common/Resource/ResString.cs @@ -77,7 +77,7 @@ public class ResString public static string cmd_uiLanguage => GetText("cmd_uiLanguage"); public static string cmd_urlProcessorArgs => GetText("cmd_urlProcessorArgs"); public static string cmd_useShakaPackager => GetText("cmd_useShakaPackager"); - public static string cmd_useMp4decrypt => GetText("cmd_useMp4decrypt"); + public static string cmd_decryptionEngine => GetText("cmd_decryptionEngine"); public static string cmd_concurrentDownload => GetText("cmd_concurrentDownload"); public static string cmd_useSystemProxy => GetText("cmd_useSystemProxy"); public static string cmd_customProxy => GetText("cmd_customProxy"); diff --git a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs index bc7efcc..0922030 100644 --- a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs +++ b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs @@ -468,15 +468,15 @@ internal class StaticText ), ["cmd_useShakaPackager"] = new TextContainer ( - zhCN: "解密时使用shaka-packager替代ffmpeg", - zhTW: "解密時使用shaka-packager替代ffmpeg", - enUS: "Use shaka-packager instead of ffmpeg to decrypt" + zhCN: "解密时使用shaka-packager替代mp4decrypt", + zhTW: "解密時使用shaka-packager替代mp4decrypt", + enUS: "Use shaka-packager instead of mp4decrypt to decrypt" ), - ["cmd_useMp4decrypt"] = new TextContainer + ["cmd_decryptionEngine"] = new TextContainer ( - zhCN: "解密时使用mp4decrypt替代ffmpeg", - zhTW: "解密時使用mp4decrypt替代ffmpeg", - enUS: "Use mp4decrypt instead of ffmpeg to decrypt" + zhCN: "设置解密时使用的第三方程序", + zhTW: "設置解密時使用的第三方程序", + enUS: "Set the third-party program used for decryption" ), ["cmd_concurrentDownload"] = new TextContainer ( diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index d1ceae5..5c6f182 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -53,8 +53,8 @@ internal partial class CommandInvoker private static readonly Option WriteMetaJson = new(["--write-meta-json"], description: ResString.cmd_writeMetaJson, getDefaultValue: () => true); private static readonly Option AppendUrlParams = new(["--append-url-params"], description: ResString.cmd_appendUrlParams, getDefaultValue: () => false); private static readonly Option MP4RealTimeDecryption = new (["--mp4-real-time-decryption"], description: ResString.cmd_MP4RealTimeDecryption, getDefaultValue: () => false); - private static readonly Option UseShakaPackager = new (["--use-shaka-packager"], description: ResString.cmd_useShakaPackager, getDefaultValue: () => false); - private static readonly Option UseMp4Decrypt = new (["--use-mp4decrypt"], description: ResString.cmd_useMp4decrypt, getDefaultValue: () => false); + private static readonly Option UseShakaPackager = new (["--use-shaka-packager"], description: ResString.cmd_useShakaPackager, getDefaultValue: () => false) { IsHidden = true }; + private static readonly Option DecryptionEngine = new (["--decryption-engine"], description: ResString.cmd_decryptionEngine, getDefaultValue: () => DecryptEngine.MP4DECRYPT); private static readonly Option ForceAnsiConsole = new(["--force-ansi-console"], description: ResString.cmd_forceAnsiConsole); private static readonly Option NoAnsiColor = new(["--no-ansi-color"], description: ResString.cmd_noAnsiColor); private static readonly Option DecryptionBinaryPath = new(["--decryption-binary-path"], description: ResString.cmd_decryptionBinaryPath) { ArgumentHelpName = "PATH" }; @@ -524,7 +524,7 @@ internal partial class CommandInvoker UrlProcessorArgs = bindingContext.ParseResult.GetValueForOption(UrlProcessorArgs), MP4RealTimeDecryption = bindingContext.ParseResult.GetValueForOption(MP4RealTimeDecryption), UseShakaPackager = bindingContext.ParseResult.GetValueForOption(UseShakaPackager), - UseMp4Decrypt = bindingContext.ParseResult.GetValueForOption(UseMp4Decrypt), + DecryptionEngine = bindingContext.ParseResult.GetValueForOption(DecryptionEngine), DecryptionBinaryPath = bindingContext.ParseResult.GetValueForOption(DecryptionBinaryPath), FFmpegBinaryPath = bindingContext.ParseResult.GetValueForOption(FFmpegBinaryPath), KeyTextFile = bindingContext.ParseResult.GetValueForOption(KeyTextFile), @@ -617,7 +617,7 @@ internal partial class CommandInvoker Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, HttpRequestTimeout, ForceAnsiConsole, NoAnsiColor,AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, BinaryMerge, UseFFmpegConcatDemuxer, DelAfterDone, NoDateInfo, NoLog, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, FFmpegBinaryPath, - LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, UseMp4Decrypt, MP4RealTimeDecryption, + LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionEngine, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption, MaxSpeed, MuxAfterDone, CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, CustomRange, TaskStartAt, diff --git a/src/N_m3u8DL-RE/CommandLine/MyOption.cs b/src/N_m3u8DL-RE/CommandLine/MyOption.cs index 67cad32..a3b78b8 100644 --- a/src/N_m3u8DL-RE/CommandLine/MyOption.cs +++ b/src/N_m3u8DL-RE/CommandLine/MyOption.cs @@ -139,11 +139,12 @@ internal class MyOption /// /// See: . /// + [Obsolete("Use DecryptionEngine instead")] public bool UseShakaPackager { get; set; } /// - /// See: . + /// See: . /// - public bool UseMp4Decrypt { get; set; } + public DecryptEngine DecryptionEngine { get; set; } /// /// See: . /// @@ -270,13 +271,4 @@ internal class MyOption /// See: . /// public bool LiveFixVttByAudio { get; set; } - - public DecryptEngine GetDecryptEngine() - { - if (UseShakaPackager) - return DecryptEngine.SHAKA_PACKAGER; - if (UseMp4Decrypt) - return DecryptEngine.MP4DECRYPT; - return DecryptEngine.FFMPEG; - } } \ No newline at end of file diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs index 7226679..ea39578 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs @@ -111,7 +111,7 @@ internal class SimpleDownloadManager var headers = DownloaderConfig.Headers; var decryptionBinaryPath = DownloaderConfig.MyOptions.DecryptionBinaryPath!; - var decryptEngine = DownloaderConfig.MyOptions.GetDecryptEngine(); + var decryptEngine = DownloaderConfig.MyOptions.DecryptionEngine; var mp4InitFile = ""; var currentKID = ""; var readInfo = false; // 是否读取过 @@ -171,7 +171,7 @@ internal class SimpleDownloadManager mp4Info = MP4DecryptUtil.GetMP4Info(result.ActualFilePath); currentKID = mp4Info.KID; // try shaka packager, which can handle WebM - if (string.IsNullOrEmpty(currentKID) && DownloaderConfig.MyOptions.UseShakaPackager) { + if (string.IsNullOrEmpty(currentKID) && DownloaderConfig.MyOptions.DecryptionEngine == DecryptEngine.SHAKA_PACKAGER) { currentKID = MP4DecryptUtil.ReadInitShaka(result.ActualFilePath, decryptionBinaryPath); } // 从文件读取KEY @@ -243,7 +243,7 @@ internal class SimpleDownloadManager currentKID = MP4DecryptUtil.GetMP4Info(result.ActualFilePath).KID; } // try shaka packager, which can handle WebM - if (string.IsNullOrEmpty(currentKID) && DownloaderConfig.MyOptions.UseShakaPackager) { + if (string.IsNullOrEmpty(currentKID) && DownloaderConfig.MyOptions.DecryptionEngine == DecryptEngine.SHAKA_PACKAGER) { currentKID = MP4DecryptUtil.ReadInitShaka(result.ActualFilePath, decryptionBinaryPath); } // 从文件读取KEY @@ -590,7 +590,7 @@ internal class SimpleDownloadManager { currentKID = MP4DecryptUtil.GetMP4Info(output).KID; // try shaka packager, which can handle WebM - if (string.IsNullOrEmpty(currentKID) && DownloaderConfig.MyOptions.UseShakaPackager) { + if (string.IsNullOrEmpty(currentKID) && DownloaderConfig.MyOptions.DecryptionEngine == DecryptEngine.SHAKA_PACKAGER) { currentKID = MP4DecryptUtil.ReadInitShaka(output, decryptionBinaryPath); } // 从文件读取KEY @@ -654,7 +654,7 @@ internal class SimpleDownloadManager } progress.Columns(progressColumns); - if (DownloaderConfig.MyOptions is { MP4RealTimeDecryption: true, UseShakaPackager: false, Keys.Length: > 0 }) + if (DownloaderConfig.MyOptions is { MP4RealTimeDecryption: true, DecryptionEngine: not DecryptEngine.SHAKA_PACKAGER, Keys.Length: > 0 }) Logger.WarnMarkUp($"[darkorange3_1]{ResString.realTimeDecMessage}[/]"); await progress.StartAsync(async ctx => diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs index a31eff8..66dab78 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs @@ -164,7 +164,7 @@ internal class SimpleLiveRecordManager2 var saveDir = DownloaderConfig.MyOptions.SaveDir ?? Environment.CurrentDirectory; var saveName = DownloaderConfig.MyOptions.SaveName != null ? $"{DownloaderConfig.MyOptions.SaveName}.{streamSpec.Language}".TrimEnd('.') : dirName; var headers = DownloaderConfig.Headers; - var decryptEngine = DownloaderConfig.MyOptions.GetDecryptEngine(); + var decryptEngine = DownloaderConfig.MyOptions.DecryptionEngine; Logger.Debug($"dirName: {dirName}; tmpDir: {tmpDir}; saveDir: {saveDir}; saveName: {saveName}"); @@ -840,7 +840,7 @@ internal class SimpleLiveRecordManager2 DownloaderConfig.MyOptions.ConcurrentDownload = true; DownloaderConfig.MyOptions.MP4RealTimeDecryption = true; DownloaderConfig.MyOptions.LiveRecordLimit = DownloaderConfig.MyOptions.LiveRecordLimit ?? TimeSpan.MaxValue; - if (DownloaderConfig.MyOptions is { MP4RealTimeDecryption: true, UseShakaPackager: false, Keys.Length: > 0 }) + if (DownloaderConfig.MyOptions is { MP4RealTimeDecryption: true, DecryptionEngine: not DecryptEngine.SHAKA_PACKAGER, Keys.Length: > 0 }) Logger.WarnMarkUp($"[darkorange3_1]{ResString.realTimeDecMessage}[/]"); var limit = DownloaderConfig.MyOptions.LiveRecordLimit; if (limit != TimeSpan.MaxValue) diff --git a/src/N_m3u8DL-RE/Program.cs b/src/N_m3u8DL-RE/Program.cs index b10a852..e2a0c5e 100644 --- a/src/N_m3u8DL-RE/Program.cs +++ b/src/N_m3u8DL-RE/Program.cs @@ -14,6 +14,7 @@ using N_m3u8DL_RE.DownloadManager; using N_m3u8DL_RE.CommandLine; using System.Net; using System.Net.Http.Headers; +using N_m3u8DL_RE.Enum; namespace N_m3u8DL_RE; @@ -109,10 +110,15 @@ internal class Program { throw new ArgumentException("MuxAfterDone disabled, MuxImports not allowed!"); } - - if (option is { UseShakaPackager: true, UseMp4Decrypt: true }) + + if (option.UseShakaPackager) { - throw new ArgumentException("UseShakaPackager and UseMp4Decrypt cannot be enabled simultaneously!"); + option.DecryptionEngine = DecryptEngine.SHAKA_PACKAGER; + } + + if (option is { UseShakaPackager: true, DecryptionEngine: not DecryptEngine.SHAKA_PACKAGER }) + { + throw new ArgumentException("UseShakaPackager and Mp4DecryptEngine not match!"); } // LivePipeMux开启时 LiveRealTimeMerge必须开启 @@ -148,7 +154,7 @@ internal class Program { if (string.IsNullOrEmpty(option.DecryptionBinaryPath)) { - if (option.UseShakaPackager) + if (option.DecryptionEngine is DecryptEngine.SHAKA_PACKAGER) { var file = GlobalUtil.FindExecutable("shaka-packager"); var file2 = GlobalUtil.FindExecutable("packager-linux-x64"); @@ -158,7 +164,7 @@ internal class Program option.DecryptionBinaryPath = file ?? file2 ?? file3 ?? file4; Logger.Extra($"shaka-packager => {option.DecryptionBinaryPath}"); } - else if (option.UseMp4Decrypt) + else if (option.DecryptionEngine is DecryptEngine.MP4DECRYPT) { var file = GlobalUtil.FindExecutable("mp4decrypt"); if (file == null) throw new FileNotFoundException("mp4decrypt not found!");