修复master跳转后HLS-KEY解析器BaseURL错误的问题
This commit is contained in:
parent
7f32319e2e
commit
3126216d9f
|
@ -448,10 +448,10 @@ namespace N_m3u8DL_RE.Parser.Extractor
|
||||||
{
|
{
|
||||||
foreach (var p in ParserConfig.KeyProcessors)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@ namespace N_m3u8DL_RE.Parser.Processor.HLS
|
||||||
{
|
{
|
||||||
public class DefaultHLSKeyProcessor : KeyProcessor
|
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 iv = ParserUtil.GetAttribute(keyLine, "IV");
|
||||||
var method = ParserUtil.GetAttribute(keyLine, "METHOD");
|
var method = ParserUtil.GetAttribute(keyLine, "METHOD");
|
||||||
|
@ -40,7 +40,7 @@ namespace N_m3u8DL_RE.Parser.Processor.HLS
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(uri))
|
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;
|
var bytes = HTTPUtil.GetBytesAsync(segUrl, parserConfig.Headers).Result;
|
||||||
encryptInfo.Key = bytes;
|
encryptInfo.Key = bytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace N_m3u8DL_RE.Parser.Processor
|
||||||
{
|
{
|
||||||
public abstract class KeyProcessor
|
public abstract class KeyProcessor
|
||||||
{
|
{
|
||||||
public abstract bool CanProcess(ExtractorType extractorType, 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 m3u8Content, ParserConfig parserConfig);
|
public abstract EncryptInfo Process(string keyLine, string m3u8Url, string m3u8Content, ParserConfig parserConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine
|
||||||
private readonly static Option<string?> UILanguage = new(new string[] { "--ui-language" }, description: ResString.cmd_uiLanguage);
|
private readonly static Option<string?> UILanguage = new(new string[] { "--ui-language" }, description: ResString.cmd_uiLanguage);
|
||||||
private readonly static Option<string?> UrlProcessorArgs = new(new string[] { "--urlprocessor-args" }, description: ResString.cmd_urlProcessorArgs);
|
private readonly static Option<string?> UrlProcessorArgs = new(new string[] { "--urlprocessor-args" }, description: ResString.cmd_urlProcessorArgs);
|
||||||
private readonly static Option<string[]?> Keys = new(new string[] { "--key" }, description: ResString.cmd_keys) { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = false };
|
private readonly static Option<string[]?> Keys = new(new string[] { "--key" }, description: ResString.cmd_keys) { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = false };
|
||||||
private readonly static Option<string[]?> Headers = new(new string[] { "--header", "-H" }, description: ResString.cmd_header) { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = false };
|
private readonly static Option<string[]?> Headers = new(new string[] { "-H", "--header" }, description: ResString.cmd_header) { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = false };
|
||||||
private readonly static Option<LogLevel> LogLevel = new(name: "--log-level", description: ResString.cmd_logLevel, getDefaultValue: () => Common.Log.LogLevel.INFO);
|
private readonly static Option<LogLevel> LogLevel = new(name: "--log-level", description: ResString.cmd_logLevel, getDefaultValue: () => Common.Log.LogLevel.INFO);
|
||||||
private readonly static Option<SubtitleFormat> SubtitleFormat = new(name: "--sub-format", description: ResString.cmd_subFormat, getDefaultValue: () => Enum.SubtitleFormat.VTT);
|
private readonly static Option<SubtitleFormat> SubtitleFormat = new(name: "--sub-format", description: ResString.cmd_subFormat, getDefaultValue: () => Enum.SubtitleFormat.VTT);
|
||||||
private readonly static Option<bool> AutoSelect = new(new string[] { "--auto-select" }, description: ResString.cmd_autoSelect, getDefaultValue: () => false);
|
private readonly static Option<bool> 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<int> InvokeArgs(string[] args, Func<MyOption, Task> action)
|
public static async Task<int> InvokeArgs(string[] args, Func<MyOption, Task> 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,
|
Input, TmpDir, SaveDir, SaveName, ThreadCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount,
|
||||||
BinaryMerge, DelAfterDone, WriteMetaJson, AppendUrlParams, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix,
|
BinaryMerge, DelAfterDone, WriteMetaJson, AppendUrlParams, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix,
|
||||||
|
|
|
@ -15,15 +15,15 @@ namespace N_m3u8DL_RE.Processor
|
||||||
{
|
{
|
||||||
internal class DemoProcessor2 : KeyProcessor
|
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");
|
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}[/]");
|
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!, " ") + "[/]");
|
Logger.InfoMarkUp("[red]" + HexUtil.BytesToHex(info.Key!, " ") + "[/]");
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue