修正Headers处理逻辑

This commit is contained in:
nilaoda 2022-08-26 23:34:03 +08:00
parent f064d75e5d
commit 2310d0472a
3 changed files with 14 additions and 14 deletions

View File

@ -56,18 +56,8 @@ namespace N_m3u8DL_RE.CommandLine
/// <returns></returns>
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 otherHeaders = ConvertUtil.SplitHeaderArrayToDic(array);
foreach (var h in otherHeaders)
{
headers[h.Key] = h.Value;
}
return headers;
return ConvertUtil.SplitHeaderArrayToDic(array);
}
/// <summary>

View File

@ -13,7 +13,7 @@ namespace N_m3u8DL_RE.CommandLine
/// <summary>
/// See: <see cref="CommandInvoker.Headers"/>.
/// </summary>
public Dictionary<string,string> Headers { get; set; } = new Dictionary<string,string>();
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
/// <summary>
/// See: <see cref="CommandInvoker.Keys"/>.
/// </summary>

View File

@ -13,7 +13,6 @@ using N_m3u8DL_RE.Config;
using N_m3u8DL_RE.Util;
using N_m3u8DL_RE.DownloadManager;
using N_m3u8DL_RE.CommandLine;
using N_m3u8DL_RE.Entity;
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()
{
AppendUrlParams = option.AppendUrlParams,
UrlProcessorArgs = option.UrlProcessorArgs,
BaseUrl = option.BaseUrl!,
Headers = option.Headers
Headers = headers
};
//demo1