From 3126216d9fb9623a3cd583bcc98b3722c475e9d1 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Tue, 26 Jul 2022 23:08:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmaster=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=90=8EHLS-KEY=E8=A7=A3=E6=9E=90=E5=99=A8BaseURL=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Parser/Extractor/HLSExtractor.cs | 4 ++-- .../Processor/HLS/DefaultHLSKeyProcessor.cs | 6 +++--- src/N_m3u8DL-RE.Parser/Processor/KeyProcessor.cs | 4 ++-- src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs | 4 ++-- src/N_m3u8DL-RE/Processor/DemoProcessor2.cs | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/N_m3u8DL-RE.Parser/Extractor/HLSExtractor.cs b/src/N_m3u8DL-RE.Parser/Extractor/HLSExtractor.cs index 629a0e2..3655d00 100644 --- a/src/N_m3u8DL-RE.Parser/Extractor/HLSExtractor.cs +++ b/src/N_m3u8DL-RE.Parser/Extractor/HLSExtractor.cs @@ -448,10 +448,10 @@ namespace N_m3u8DL_RE.Parser.Extractor { foreach (var p in ParserConfig.KeyProcessors) { - if (p.CanProcess(ExtractorType, keyLine, M3u8Content, ParserConfig)) + if (p.CanProcess(ExtractorType, keyLine, M3u8Url, M3u8Content, ParserConfig)) { //匹配到对应处理器后不再继续 - return p.Process(keyLine, M3u8Content, ParserConfig); + return p.Process(keyLine, M3u8Url, M3u8Content, ParserConfig); } } diff --git a/src/N_m3u8DL-RE.Parser/Processor/HLS/DefaultHLSKeyProcessor.cs b/src/N_m3u8DL-RE.Parser/Processor/HLS/DefaultHLSKeyProcessor.cs index a04f497..efcd560 100644 --- a/src/N_m3u8DL-RE.Parser/Processor/HLS/DefaultHLSKeyProcessor.cs +++ b/src/N_m3u8DL-RE.Parser/Processor/HLS/DefaultHLSKeyProcessor.cs @@ -13,10 +13,10 @@ namespace N_m3u8DL_RE.Parser.Processor.HLS { public class DefaultHLSKeyProcessor : KeyProcessor { - public override bool CanProcess(ExtractorType extractorType, string keyLine, string m3u8Content, ParserConfig paserConfig) => extractorType == ExtractorType.HLS; + public override bool CanProcess(ExtractorType extractorType, string m3u8Url, string keyLine, string m3u8Content, ParserConfig paserConfig) => extractorType == ExtractorType.HLS; - public override EncryptInfo Process(string keyLine, string m3u8Content, ParserConfig parserConfig) + public override EncryptInfo Process(string keyLine, string m3u8Url, string m3u8Content, ParserConfig parserConfig) { var iv = ParserUtil.GetAttribute(keyLine, "IV"); var method = ParserUtil.GetAttribute(keyLine, "METHOD"); @@ -40,7 +40,7 @@ namespace N_m3u8DL_RE.Parser.Processor.HLS } else if (!string.IsNullOrEmpty(uri)) { - var segUrl = PreProcessUrl(ParserUtil.CombineURL(parserConfig.BaseUrl, uri), parserConfig); + var segUrl = PreProcessUrl(ParserUtil.CombineURL(m3u8Url, uri), parserConfig); var bytes = HTTPUtil.GetBytesAsync(segUrl, parserConfig.Headers).Result; encryptInfo.Key = bytes; } diff --git a/src/N_m3u8DL-RE.Parser/Processor/KeyProcessor.cs b/src/N_m3u8DL-RE.Parser/Processor/KeyProcessor.cs index 13d1c4e..ec1438d 100644 --- a/src/N_m3u8DL-RE.Parser/Processor/KeyProcessor.cs +++ b/src/N_m3u8DL-RE.Parser/Processor/KeyProcessor.cs @@ -11,7 +11,7 @@ namespace N_m3u8DL_RE.Parser.Processor { public abstract class KeyProcessor { - public abstract bool CanProcess(ExtractorType extractorType, string keyLine, string m3u8Content, ParserConfig parserConfig); - public abstract EncryptInfo Process(string keyLine, string m3u8Content, ParserConfig parserConfig); + public abstract bool CanProcess(ExtractorType extractorType, string keyLine, string m3u8Url, string m3u8Content, ParserConfig parserConfig); + public abstract EncryptInfo Process(string keyLine, string m3u8Url, string m3u8Content, ParserConfig parserConfig); } } diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index 106d5f1..85b0c6d 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine private readonly static Option UILanguage = new(new string[] { "--ui-language" }, description: ResString.cmd_uiLanguage); private readonly static Option UrlProcessorArgs = new(new string[] { "--urlprocessor-args" }, description: ResString.cmd_urlProcessorArgs); private readonly static Option Keys = new(new string[] { "--key" }, description: ResString.cmd_keys) { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = false }; - private readonly static Option Headers = new(new string[] { "--header", "-H" }, description: ResString.cmd_header) { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = false }; + private readonly static Option Headers = new(new string[] { "-H", "--header" }, description: ResString.cmd_header) { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = false }; private readonly static Option LogLevel = new(name: "--log-level", description: ResString.cmd_logLevel, getDefaultValue: () => Common.Log.LogLevel.INFO); private readonly static Option SubtitleFormat = new(name: "--sub-format", description: ResString.cmd_subFormat, getDefaultValue: () => Enum.SubtitleFormat.VTT); private readonly static Option AutoSelect = new(new string[] { "--auto-select" }, description: ResString.cmd_autoSelect, getDefaultValue: () => false); @@ -91,7 +91,7 @@ namespace N_m3u8DL_RE.CommandLine public static async Task InvokeArgs(string[] args, Func action) { - var rootCommand = new RootCommand("N_m3u8DL-RE (Beta version) 20220724") + var rootCommand = new RootCommand("N_m3u8DL-RE (Beta version) 20220726") { Input, TmpDir, SaveDir, SaveName, ThreadCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, BinaryMerge, DelAfterDone, WriteMetaJson, AppendUrlParams, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, diff --git a/src/N_m3u8DL-RE/Processor/DemoProcessor2.cs b/src/N_m3u8DL-RE/Processor/DemoProcessor2.cs index de6032e..5825c51 100644 --- a/src/N_m3u8DL-RE/Processor/DemoProcessor2.cs +++ b/src/N_m3u8DL-RE/Processor/DemoProcessor2.cs @@ -15,15 +15,15 @@ namespace N_m3u8DL_RE.Processor { internal class DemoProcessor2 : KeyProcessor { - public override bool CanProcess(ExtractorType extractorType, string keyLine, string m3u8Content, ParserConfig parserConfig) + public override bool CanProcess(ExtractorType extractorType, string keyLine, string m3u8Url, string m3u8Content, ParserConfig parserConfig) { return extractorType == ExtractorType.HLS && parserConfig.Url.Contains("playertest.longtailvideo.com"); } - public override EncryptInfo Process(string keyLine, string m3u8Content, ParserConfig parserConfig) + public override EncryptInfo Process(string keyLine, string m3u8Url, string m3u8Content, ParserConfig parserConfig) { Logger.InfoMarkUp($"[white on green]My Key Processor => {keyLine}[/]"); - var info = new DefaultHLSKeyProcessor().Process(keyLine, m3u8Content, parserConfig); + var info = new DefaultHLSKeyProcessor().Process(keyLine, m3u8Url, m3u8Content, parserConfig); Logger.InfoMarkUp("[red]" + HexUtil.BytesToHex(info.Key!, " ") + "[/]"); return info; }