恢复默认使用ffmpeg解密 (#522)
This commit is contained in:
parent
8095c6e172
commit
77fdaaf9bd
|
@ -77,7 +77,7 @@ public class ResString
|
||||||
public static string cmd_uiLanguage => GetText("cmd_uiLanguage");
|
public static string cmd_uiLanguage => GetText("cmd_uiLanguage");
|
||||||
public static string cmd_urlProcessorArgs => GetText("cmd_urlProcessorArgs");
|
public static string cmd_urlProcessorArgs => GetText("cmd_urlProcessorArgs");
|
||||||
public static string cmd_useShakaPackager => GetText("cmd_useShakaPackager");
|
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_concurrentDownload => GetText("cmd_concurrentDownload");
|
||||||
public static string cmd_useSystemProxy => GetText("cmd_useSystemProxy");
|
public static string cmd_useSystemProxy => GetText("cmd_useSystemProxy");
|
||||||
public static string cmd_customProxy => GetText("cmd_customProxy");
|
public static string cmd_customProxy => GetText("cmd_customProxy");
|
||||||
|
|
|
@ -468,15 +468,15 @@ internal class StaticText
|
||||||
),
|
),
|
||||||
["cmd_useShakaPackager"] = new TextContainer
|
["cmd_useShakaPackager"] = new TextContainer
|
||||||
(
|
(
|
||||||
zhCN: "解密时使用shaka-packager替代ffmpeg",
|
zhCN: "解密时使用shaka-packager替代mp4decrypt",
|
||||||
zhTW: "解密時使用shaka-packager替代ffmpeg",
|
zhTW: "解密時使用shaka-packager替代mp4decrypt",
|
||||||
enUS: "Use shaka-packager instead of ffmpeg to decrypt"
|
enUS: "Use shaka-packager instead of mp4decrypt to decrypt"
|
||||||
),
|
),
|
||||||
["cmd_useMp4decrypt"] = new TextContainer
|
["cmd_decryptionEngine"] = new TextContainer
|
||||||
(
|
(
|
||||||
zhCN: "解密时使用mp4decrypt替代ffmpeg",
|
zhCN: "设置解密时使用的第三方程序",
|
||||||
zhTW: "解密時使用mp4decrypt替代ffmpeg",
|
zhTW: "設置解密時使用的第三方程序",
|
||||||
enUS: "Use mp4decrypt instead of ffmpeg to decrypt"
|
enUS: "Set the third-party program used for decryption"
|
||||||
),
|
),
|
||||||
["cmd_concurrentDownload"] = new TextContainer
|
["cmd_concurrentDownload"] = new TextContainer
|
||||||
(
|
(
|
||||||
|
|
|
@ -53,8 +53,8 @@ internal partial class CommandInvoker
|
||||||
private static readonly Option<bool> WriteMetaJson = new(["--write-meta-json"], description: ResString.cmd_writeMetaJson, getDefaultValue: () => true);
|
private static readonly Option<bool> WriteMetaJson = new(["--write-meta-json"], description: ResString.cmd_writeMetaJson, getDefaultValue: () => true);
|
||||||
private static readonly Option<bool> AppendUrlParams = new(["--append-url-params"], description: ResString.cmd_appendUrlParams, getDefaultValue: () => false);
|
private static readonly Option<bool> AppendUrlParams = new(["--append-url-params"], description: ResString.cmd_appendUrlParams, getDefaultValue: () => false);
|
||||||
private static readonly Option<bool> MP4RealTimeDecryption = new (["--mp4-real-time-decryption"], description: ResString.cmd_MP4RealTimeDecryption, getDefaultValue: () => false);
|
private static readonly Option<bool> MP4RealTimeDecryption = new (["--mp4-real-time-decryption"], description: ResString.cmd_MP4RealTimeDecryption, getDefaultValue: () => false);
|
||||||
private static readonly Option<bool> UseShakaPackager = new (["--use-shaka-packager"], description: ResString.cmd_useShakaPackager, getDefaultValue: () => false);
|
private static readonly Option<bool> UseShakaPackager = new (["--use-shaka-packager"], description: ResString.cmd_useShakaPackager, getDefaultValue: () => false) { IsHidden = true };
|
||||||
private static readonly Option<bool> UseMp4Decrypt = new (["--use-mp4decrypt"], description: ResString.cmd_useMp4decrypt, getDefaultValue: () => false);
|
private static readonly Option<DecryptEngine> DecryptionEngine = new (["--decryption-engine"], description: ResString.cmd_decryptionEngine, getDefaultValue: () => DecryptEngine.MP4DECRYPT);
|
||||||
private static readonly Option<bool> ForceAnsiConsole = new(["--force-ansi-console"], description: ResString.cmd_forceAnsiConsole);
|
private static readonly Option<bool> ForceAnsiConsole = new(["--force-ansi-console"], description: ResString.cmd_forceAnsiConsole);
|
||||||
private static readonly Option<bool> NoAnsiColor = new(["--no-ansi-color"], description: ResString.cmd_noAnsiColor);
|
private static readonly Option<bool> NoAnsiColor = new(["--no-ansi-color"], description: ResString.cmd_noAnsiColor);
|
||||||
private static readonly Option<string?> DecryptionBinaryPath = new(["--decryption-binary-path"], description: ResString.cmd_decryptionBinaryPath) { ArgumentHelpName = "PATH" };
|
private static readonly Option<string?> DecryptionBinaryPath = new(["--decryption-binary-path"], description: ResString.cmd_decryptionBinaryPath) { ArgumentHelpName = "PATH" };
|
||||||
|
@ -524,7 +524,7 @@ internal partial class CommandInvoker
|
||||||
UrlProcessorArgs = bindingContext.ParseResult.GetValueForOption(UrlProcessorArgs),
|
UrlProcessorArgs = bindingContext.ParseResult.GetValueForOption(UrlProcessorArgs),
|
||||||
MP4RealTimeDecryption = bindingContext.ParseResult.GetValueForOption(MP4RealTimeDecryption),
|
MP4RealTimeDecryption = bindingContext.ParseResult.GetValueForOption(MP4RealTimeDecryption),
|
||||||
UseShakaPackager = bindingContext.ParseResult.GetValueForOption(UseShakaPackager),
|
UseShakaPackager = bindingContext.ParseResult.GetValueForOption(UseShakaPackager),
|
||||||
UseMp4Decrypt = bindingContext.ParseResult.GetValueForOption(UseMp4Decrypt),
|
DecryptionEngine = bindingContext.ParseResult.GetValueForOption(DecryptionEngine),
|
||||||
DecryptionBinaryPath = bindingContext.ParseResult.GetValueForOption(DecryptionBinaryPath),
|
DecryptionBinaryPath = bindingContext.ParseResult.GetValueForOption(DecryptionBinaryPath),
|
||||||
FFmpegBinaryPath = bindingContext.ParseResult.GetValueForOption(FFmpegBinaryPath),
|
FFmpegBinaryPath = bindingContext.ParseResult.GetValueForOption(FFmpegBinaryPath),
|
||||||
KeyTextFile = bindingContext.ParseResult.GetValueForOption(KeyTextFile),
|
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,
|
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,
|
BinaryMerge, UseFFmpegConcatDemuxer, DelAfterDone, NoDateInfo, NoLog, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix,
|
||||||
FFmpegBinaryPath,
|
FFmpegBinaryPath,
|
||||||
LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, UseMp4Decrypt, MP4RealTimeDecryption,
|
LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionEngine, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption,
|
||||||
MaxSpeed,
|
MaxSpeed,
|
||||||
MuxAfterDone,
|
MuxAfterDone,
|
||||||
CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, CustomRange, TaskStartAt,
|
CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, CustomRange, TaskStartAt,
|
||||||
|
|
|
@ -139,11 +139,12 @@ internal class MyOption
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// See: <see cref="CommandInvoker.UseShakaPackager"/>.
|
/// See: <see cref="CommandInvoker.UseShakaPackager"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("Use DecryptionEngine instead")]
|
||||||
public bool UseShakaPackager { get; set; }
|
public bool UseShakaPackager { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// See: <see cref="CommandInvoker.UseMp4Decrypt"/>.
|
/// See: <see cref="CommandInvoker.DecryptionEngine"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseMp4Decrypt { get; set; }
|
public DecryptEngine DecryptionEngine { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// See: <see cref="CommandInvoker.MuxAfterDone"/>.
|
/// See: <see cref="CommandInvoker.MuxAfterDone"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -270,13 +271,4 @@ internal class MyOption
|
||||||
/// See: <see cref="CommandInvoker.LiveFixVttByAudio"/>.
|
/// See: <see cref="CommandInvoker.LiveFixVttByAudio"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LiveFixVttByAudio { get; set; }
|
public bool LiveFixVttByAudio { get; set; }
|
||||||
|
|
||||||
public DecryptEngine GetDecryptEngine()
|
|
||||||
{
|
|
||||||
if (UseShakaPackager)
|
|
||||||
return DecryptEngine.SHAKA_PACKAGER;
|
|
||||||
if (UseMp4Decrypt)
|
|
||||||
return DecryptEngine.MP4DECRYPT;
|
|
||||||
return DecryptEngine.FFMPEG;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -111,7 +111,7 @@ internal class SimpleDownloadManager
|
||||||
var headers = DownloaderConfig.Headers;
|
var headers = DownloaderConfig.Headers;
|
||||||
|
|
||||||
var decryptionBinaryPath = DownloaderConfig.MyOptions.DecryptionBinaryPath!;
|
var decryptionBinaryPath = DownloaderConfig.MyOptions.DecryptionBinaryPath!;
|
||||||
var decryptEngine = DownloaderConfig.MyOptions.GetDecryptEngine();
|
var decryptEngine = DownloaderConfig.MyOptions.DecryptionEngine;
|
||||||
var mp4InitFile = "";
|
var mp4InitFile = "";
|
||||||
var currentKID = "";
|
var currentKID = "";
|
||||||
var readInfo = false; // 是否读取过
|
var readInfo = false; // 是否读取过
|
||||||
|
@ -171,7 +171,7 @@ internal class SimpleDownloadManager
|
||||||
mp4Info = MP4DecryptUtil.GetMP4Info(result.ActualFilePath);
|
mp4Info = MP4DecryptUtil.GetMP4Info(result.ActualFilePath);
|
||||||
currentKID = mp4Info.KID;
|
currentKID = mp4Info.KID;
|
||||||
// try shaka packager, which can handle WebM
|
// 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);
|
currentKID = MP4DecryptUtil.ReadInitShaka(result.ActualFilePath, decryptionBinaryPath);
|
||||||
}
|
}
|
||||||
// 从文件读取KEY
|
// 从文件读取KEY
|
||||||
|
@ -243,7 +243,7 @@ internal class SimpleDownloadManager
|
||||||
currentKID = MP4DecryptUtil.GetMP4Info(result.ActualFilePath).KID;
|
currentKID = MP4DecryptUtil.GetMP4Info(result.ActualFilePath).KID;
|
||||||
}
|
}
|
||||||
// try shaka packager, which can handle WebM
|
// 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);
|
currentKID = MP4DecryptUtil.ReadInitShaka(result.ActualFilePath, decryptionBinaryPath);
|
||||||
}
|
}
|
||||||
// 从文件读取KEY
|
// 从文件读取KEY
|
||||||
|
@ -590,7 +590,7 @@ internal class SimpleDownloadManager
|
||||||
{
|
{
|
||||||
currentKID = MP4DecryptUtil.GetMP4Info(output).KID;
|
currentKID = MP4DecryptUtil.GetMP4Info(output).KID;
|
||||||
// try shaka packager, which can handle WebM
|
// 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);
|
currentKID = MP4DecryptUtil.ReadInitShaka(output, decryptionBinaryPath);
|
||||||
}
|
}
|
||||||
// 从文件读取KEY
|
// 从文件读取KEY
|
||||||
|
@ -654,7 +654,7 @@ internal class SimpleDownloadManager
|
||||||
}
|
}
|
||||||
progress.Columns(progressColumns);
|
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}[/]");
|
Logger.WarnMarkUp($"[darkorange3_1]{ResString.realTimeDecMessage}[/]");
|
||||||
|
|
||||||
await progress.StartAsync(async ctx =>
|
await progress.StartAsync(async ctx =>
|
||||||
|
|
|
@ -164,7 +164,7 @@ internal class SimpleLiveRecordManager2
|
||||||
var saveDir = DownloaderConfig.MyOptions.SaveDir ?? Environment.CurrentDirectory;
|
var saveDir = DownloaderConfig.MyOptions.SaveDir ?? Environment.CurrentDirectory;
|
||||||
var saveName = DownloaderConfig.MyOptions.SaveName != null ? $"{DownloaderConfig.MyOptions.SaveName}.{streamSpec.Language}".TrimEnd('.') : dirName;
|
var saveName = DownloaderConfig.MyOptions.SaveName != null ? $"{DownloaderConfig.MyOptions.SaveName}.{streamSpec.Language}".TrimEnd('.') : dirName;
|
||||||
var headers = DownloaderConfig.Headers;
|
var headers = DownloaderConfig.Headers;
|
||||||
var decryptEngine = DownloaderConfig.MyOptions.GetDecryptEngine();
|
var decryptEngine = DownloaderConfig.MyOptions.DecryptionEngine;
|
||||||
|
|
||||||
Logger.Debug($"dirName: {dirName}; tmpDir: {tmpDir}; saveDir: {saveDir}; saveName: {saveName}");
|
Logger.Debug($"dirName: {dirName}; tmpDir: {tmpDir}; saveDir: {saveDir}; saveName: {saveName}");
|
||||||
|
|
||||||
|
@ -840,7 +840,7 @@ internal class SimpleLiveRecordManager2
|
||||||
DownloaderConfig.MyOptions.ConcurrentDownload = true;
|
DownloaderConfig.MyOptions.ConcurrentDownload = true;
|
||||||
DownloaderConfig.MyOptions.MP4RealTimeDecryption = true;
|
DownloaderConfig.MyOptions.MP4RealTimeDecryption = true;
|
||||||
DownloaderConfig.MyOptions.LiveRecordLimit = DownloaderConfig.MyOptions.LiveRecordLimit ?? TimeSpan.MaxValue;
|
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}[/]");
|
Logger.WarnMarkUp($"[darkorange3_1]{ResString.realTimeDecMessage}[/]");
|
||||||
var limit = DownloaderConfig.MyOptions.LiveRecordLimit;
|
var limit = DownloaderConfig.MyOptions.LiveRecordLimit;
|
||||||
if (limit != TimeSpan.MaxValue)
|
if (limit != TimeSpan.MaxValue)
|
||||||
|
|
|
@ -14,6 +14,7 @@ using N_m3u8DL_RE.DownloadManager;
|
||||||
using N_m3u8DL_RE.CommandLine;
|
using N_m3u8DL_RE.CommandLine;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
using N_m3u8DL_RE.Enum;
|
||||||
|
|
||||||
namespace N_m3u8DL_RE;
|
namespace N_m3u8DL_RE;
|
||||||
|
|
||||||
|
@ -110,9 +111,14 @@ internal class Program
|
||||||
throw new ArgumentException("MuxAfterDone disabled, MuxImports not allowed!");
|
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必须开启
|
// LivePipeMux开启时 LiveRealTimeMerge必须开启
|
||||||
|
@ -148,7 +154,7 @@ internal class Program
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(option.DecryptionBinaryPath))
|
if (string.IsNullOrEmpty(option.DecryptionBinaryPath))
|
||||||
{
|
{
|
||||||
if (option.UseShakaPackager)
|
if (option.DecryptionEngine is DecryptEngine.SHAKA_PACKAGER)
|
||||||
{
|
{
|
||||||
var file = GlobalUtil.FindExecutable("shaka-packager");
|
var file = GlobalUtil.FindExecutable("shaka-packager");
|
||||||
var file2 = GlobalUtil.FindExecutable("packager-linux-x64");
|
var file2 = GlobalUtil.FindExecutable("packager-linux-x64");
|
||||||
|
@ -158,7 +164,7 @@ internal class Program
|
||||||
option.DecryptionBinaryPath = file ?? file2 ?? file3 ?? file4;
|
option.DecryptionBinaryPath = file ?? file2 ?? file3 ?? file4;
|
||||||
Logger.Extra($"shaka-packager => {option.DecryptionBinaryPath}");
|
Logger.Extra($"shaka-packager => {option.DecryptionBinaryPath}");
|
||||||
}
|
}
|
||||||
else if (option.UseMp4Decrypt)
|
else if (option.DecryptionEngine is DecryptEngine.MP4DECRYPT)
|
||||||
{
|
{
|
||||||
var file = GlobalUtil.FindExecutable("mp4decrypt");
|
var file = GlobalUtil.FindExecutable("mp4decrypt");
|
||||||
if (file == null) throw new FileNotFoundException("mp4decrypt not found!");
|
if (file == null) throw new FileNotFoundException("mp4decrypt not found!");
|
||||||
|
|
Loading…
Reference in New Issue