修正Headers处理逻辑
This commit is contained in:
parent
f064d75e5d
commit
2310d0472a
|
@ -56,18 +56,8 @@ namespace N_m3u8DL_RE.CommandLine
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static Dictionary<string, string> ParseHeaders(ArgumentResult result)
|
private static Dictionary<string, string> ParseHeaders(ArgumentResult result)
|
||||||
{
|
{
|
||||||
//默认的Headers
|
|
||||||
var headers = new Dictionary<string, string>()
|
|
||||||
{
|
|
||||||
["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
|
|
||||||
};
|
|
||||||
var array = result.Tokens.Select(t => t.Value).ToArray();
|
var array = result.Tokens.Select(t => t.Value).ToArray();
|
||||||
var otherHeaders = ConvertUtil.SplitHeaderArrayToDic(array);
|
return ConvertUtil.SplitHeaderArrayToDic(array);
|
||||||
foreach (var h in otherHeaders)
|
|
||||||
{
|
|
||||||
headers[h.Key] = h.Value;
|
|
||||||
}
|
|
||||||
return headers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace N_m3u8DL_RE.CommandLine
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// See: <see cref="CommandInvoker.Headers"/>.
|
/// See: <see cref="CommandInvoker.Headers"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string,string> Headers { get; set; } = new Dictionary<string,string>();
|
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// See: <see cref="CommandInvoker.Keys"/>.
|
/// See: <see cref="CommandInvoker.Keys"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -13,7 +13,6 @@ using N_m3u8DL_RE.Config;
|
||||||
using N_m3u8DL_RE.Util;
|
using N_m3u8DL_RE.Util;
|
||||||
using N_m3u8DL_RE.DownloadManager;
|
using N_m3u8DL_RE.DownloadManager;
|
||||||
using N_m3u8DL_RE.CommandLine;
|
using N_m3u8DL_RE.CommandLine;
|
||||||
using N_m3u8DL_RE.Entity;
|
|
||||||
|
|
||||||
namespace N_m3u8DL_RE
|
namespace N_m3u8DL_RE
|
||||||
{
|
{
|
||||||
|
@ -103,12 +102,23 @@ namespace N_m3u8DL_RE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//默认的headers
|
||||||
|
var headers = new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
|
||||||
|
};
|
||||||
|
//添加或替换用户输入的headers
|
||||||
|
foreach (var item in option.Headers)
|
||||||
|
{
|
||||||
|
headers[item.Key] = item.Value;
|
||||||
|
}
|
||||||
|
|
||||||
var parserConfig = new ParserConfig()
|
var parserConfig = new ParserConfig()
|
||||||
{
|
{
|
||||||
AppendUrlParams = option.AppendUrlParams,
|
AppendUrlParams = option.AppendUrlParams,
|
||||||
UrlProcessorArgs = option.UrlProcessorArgs,
|
UrlProcessorArgs = option.UrlProcessorArgs,
|
||||||
BaseUrl = option.BaseUrl!,
|
BaseUrl = option.BaseUrl!,
|
||||||
Headers = option.Headers
|
Headers = headers
|
||||||
};
|
};
|
||||||
|
|
||||||
//demo1
|
//demo1
|
||||||
|
|
Loading…
Reference in New Issue