支持设置BaseURL

This commit is contained in:
nilaoda 2022-08-22 00:29:04 +08:00
parent 3c17a20447
commit 4859c288ed
6 changed files with 19 additions and 7 deletions

View File

@ -24,6 +24,7 @@ namespace N_m3u8DL_RE.Common.Resource
public static string cmd_delAfterDone { get => GetText("cmd_delAfterDone"); } public static string cmd_delAfterDone { get => GetText("cmd_delAfterDone"); }
public static string cmd_ffmpegBinaryPath { get => GetText("cmd_ffmpegBinaryPath"); } public static string cmd_ffmpegBinaryPath { get => GetText("cmd_ffmpegBinaryPath"); }
public static string cmd_mkvmergeBinaryPath { get => GetText("cmd_mkvmergeBinaryPath"); } public static string cmd_mkvmergeBinaryPath { get => GetText("cmd_mkvmergeBinaryPath"); }
public static string cmd_baseUrl { get => GetText("cmd_baseUrl"); }
public static string cmd_header { get => GetText("cmd_header"); } public static string cmd_header { get => GetText("cmd_header"); }
public static string cmd_Input { get => GetText("cmd_Input"); } public static string cmd_Input { get => GetText("cmd_Input"); }
public static string cmd_keys { get => GetText("cmd_keys"); } public static string cmd_keys { get => GetText("cmd_keys"); }

View File

@ -52,6 +52,12 @@ namespace N_m3u8DL_RE.Common.Resource
zhTW: "驗證最後一個分片有效性", zhTW: "驗證最後一個分片有效性",
enUS: "Verifying the validity of the last segment" enUS: "Verifying the validity of the last segment"
), ),
["cmd_baseUrl"] = new TextContainer
(
zhCN: "设置BaseURL",
zhTW: "設置BaseURL",
enUS: "Set BaseURL"
),
["cmd_appendUrlParams"] = new TextContainer ["cmd_appendUrlParams"] = new TextContainer
( (
zhCN: "将输入Url的Params添加至分片, 对某些网站很有用, 例如 kakao.com", zhCN: "将输入Url的Params添加至分片, 对某些网站很有用, 例如 kakao.com",

View File

@ -31,6 +31,8 @@ namespace N_m3u8DL_RE.Parser.Extractor
this.MpdUrl = parserConfig.Url ?? string.Empty; this.MpdUrl = parserConfig.Url ?? string.Empty;
if (!string.IsNullOrEmpty(parserConfig.BaseUrl)) if (!string.IsNullOrEmpty(parserConfig.BaseUrl))
this.BaseUrl = parserConfig.BaseUrl; this.BaseUrl = parserConfig.BaseUrl;
else
this.BaseUrl = this.MpdUrl;
} }
private string ExtendBaseUrl(XElement element, string oriBaseUrl) private string ExtendBaseUrl(XElement element, string oriBaseUrl)
@ -92,10 +94,6 @@ namespace N_m3u8DL_RE.Parser.Extractor
if (baseUrl.Contains("kkbox.com.tw/")) baseUrl = baseUrl.Replace("//https:%2F%2F", "//"); if (baseUrl.Contains("kkbox.com.tw/")) baseUrl = baseUrl.Replace("//https:%2F%2F", "//");
this.BaseUrl = ParserUtil.CombineURL(this.MpdUrl, baseUrl); this.BaseUrl = ParserUtil.CombineURL(this.MpdUrl, baseUrl);
} }
else
{
this.BaseUrl = this.MpdUrl;
}
//全部Period //全部Period
var periods = mpdElement.Elements().Where(e => e.Name.LocalName == "Period"); var periods = mpdElement.Elements().Where(e => e.Name.LocalName == "Period");

View File

@ -41,6 +41,7 @@ namespace N_m3u8DL_RE.CommandLine
private readonly static Option<string?> DecryptionBinaryPath = new(new string[] { "--decryption-binary-path" }, description: ResString.cmd_decryptionBinaryPath); private readonly static Option<string?> DecryptionBinaryPath = new(new string[] { "--decryption-binary-path" }, description: ResString.cmd_decryptionBinaryPath);
private readonly static Option<string?> FFmpegBinaryPath = new(new string[] { "--ffmpeg-binary-path" }, description: ResString.cmd_ffmpegBinaryPath); private readonly static Option<string?> FFmpegBinaryPath = new(new string[] { "--ffmpeg-binary-path" }, description: ResString.cmd_ffmpegBinaryPath);
private readonly static Option<string?> MkvmergeBinaryPath = new(new string[] { "--mkvmerge-binary-path" }, description: ResString.cmd_mkvmergeBinaryPath); private readonly static Option<string?> MkvmergeBinaryPath = new(new string[] { "--mkvmerge-binary-path" }, description: ResString.cmd_mkvmergeBinaryPath);
private readonly static Option<string?> BaseUrl = new(new string[] { "--base-url" }, description: ResString.cmd_baseUrl);
class MyOptionBinder : BinderBase<MyOption> class MyOptionBinder : BinderBase<MyOption>
{ {
@ -78,6 +79,7 @@ namespace N_m3u8DL_RE.CommandLine
DownloadRetryCount = bindingContext.ParseResult.GetValueForOption(DownloadRetryCount), DownloadRetryCount = bindingContext.ParseResult.GetValueForOption(DownloadRetryCount),
MuxAfterDone = bindingContext.ParseResult.GetValueForOption(MuxAfterDone), MuxAfterDone = bindingContext.ParseResult.GetValueForOption(MuxAfterDone),
UseMkvmerge = bindingContext.ParseResult.GetValueForOption(UseMkvmerge), UseMkvmerge = bindingContext.ParseResult.GetValueForOption(UseMkvmerge),
BaseUrl = bindingContext.ParseResult.GetValueForOption(BaseUrl),
}; };
@ -96,9 +98,9 @@ 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) 20220821") var rootCommand = new RootCommand("N_m3u8DL-RE (Beta version) 20220822")
{ {
Input, TmpDir, SaveDir, SaveName, ThreadCount, DownloadRetryCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount,
BinaryMerge, DelAfterDone, WriteMetaJson, MuxAfterDone, AppendUrlParams, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, BinaryMerge, DelAfterDone, WriteMetaJson, MuxAfterDone, AppendUrlParams, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix,
FFmpegBinaryPath, MkvmergeBinaryPath, FFmpegBinaryPath, MkvmergeBinaryPath,
LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, UseMkvmerge, MP4RealTimeDecryption LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, UseMkvmerge, MP4RealTimeDecryption

View File

@ -18,6 +18,10 @@ namespace N_m3u8DL_RE.CommandLine
/// </summary> /// </summary>
public string[]? Keys { get; set; } public string[]? Keys { get; set; }
/// <summary> /// <summary>
/// See: <see cref="CommandInvoker.BaseUrl"/>.
/// </summary>
public string? BaseUrl { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.KeyTextFile"/>. /// See: <see cref="CommandInvoker.KeyTextFile"/>.
/// </summary> /// </summary>
public string? KeyTextFile { get; set; } public string? KeyTextFile { get; set; }

View File

@ -98,6 +98,7 @@ namespace N_m3u8DL_RE
{ {
AppendUrlParams = option.AppendUrlParams, AppendUrlParams = option.AppendUrlParams,
UrlProcessorArgs = option.UrlProcessorArgs, UrlProcessorArgs = option.UrlProcessorArgs,
BaseUrl = option.BaseUrl!
}; };
//设置Headers //设置Headers