From 4859c288ed6e596a218413449f8447e14ca8eba8 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Mon, 22 Aug 2022 00:29:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AEBaseURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Common/Resource/ResString.cs | 1 + src/N_m3u8DL-RE.Common/Resource/StaticText.cs | 6 ++++++ src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs | 6 ++---- src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs | 8 +++++--- src/N_m3u8DL-RE/CommandLine/MyOption.cs | 4 ++++ src/N_m3u8DL-RE/Program.cs | 1 + 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.cs index 9322bfd..7d46ff9 100644 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.cs +++ b/src/N_m3u8DL-RE.Common/Resource/ResString.cs @@ -24,6 +24,7 @@ namespace N_m3u8DL_RE.Common.Resource public static string cmd_delAfterDone { get => GetText("cmd_delAfterDone"); } public static string cmd_ffmpegBinaryPath { get => GetText("cmd_ffmpegBinaryPath"); } 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_Input { get => GetText("cmd_Input"); } public static string cmd_keys { get => GetText("cmd_keys"); } diff --git a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs index 1ed61c0..2ee39c2 100644 --- a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs +++ b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs @@ -52,6 +52,12 @@ namespace N_m3u8DL_RE.Common.Resource zhTW: "驗證最後一個分片有效性", enUS: "Verifying the validity of the last segment" ), + ["cmd_baseUrl"] = new TextContainer + ( + zhCN: "设置BaseURL", + zhTW: "設置BaseURL", + enUS: "Set BaseURL" + ), ["cmd_appendUrlParams"] = new TextContainer ( zhCN: "将输入Url的Params添加至分片, 对某些网站很有用, 例如 kakao.com", diff --git a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs index 6837eec..3ce9210 100644 --- a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs +++ b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs @@ -31,6 +31,8 @@ namespace N_m3u8DL_RE.Parser.Extractor this.MpdUrl = parserConfig.Url ?? string.Empty; if (!string.IsNullOrEmpty(parserConfig.BaseUrl)) this.BaseUrl = parserConfig.BaseUrl; + else + this.BaseUrl = this.MpdUrl; } 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", "//"); this.BaseUrl = ParserUtil.CombineURL(this.MpdUrl, baseUrl); } - else - { - this.BaseUrl = this.MpdUrl; - } //全部Period var periods = mpdElement.Elements().Where(e => e.Name.LocalName == "Period"); diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index 96bd571..78a12da 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -41,6 +41,7 @@ namespace N_m3u8DL_RE.CommandLine private readonly static Option DecryptionBinaryPath = new(new string[] { "--decryption-binary-path" }, description: ResString.cmd_decryptionBinaryPath); private readonly static Option FFmpegBinaryPath = new(new string[] { "--ffmpeg-binary-path" }, description: ResString.cmd_ffmpegBinaryPath); private readonly static Option MkvmergeBinaryPath = new(new string[] { "--mkvmerge-binary-path" }, description: ResString.cmd_mkvmergeBinaryPath); + private readonly static Option BaseUrl = new(new string[] { "--base-url" }, description: ResString.cmd_baseUrl); class MyOptionBinder : BinderBase { @@ -77,7 +78,8 @@ namespace N_m3u8DL_RE.CommandLine KeyTextFile = bindingContext.ParseResult.GetValueForOption(KeyTextFile), DownloadRetryCount = bindingContext.ParseResult.GetValueForOption(DownloadRetryCount), 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 InvokeArgs(string[] args, Func 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, FFmpegBinaryPath, MkvmergeBinaryPath, LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, UseMkvmerge, MP4RealTimeDecryption diff --git a/src/N_m3u8DL-RE/CommandLine/MyOption.cs b/src/N_m3u8DL-RE/CommandLine/MyOption.cs index 870258c..086882d 100644 --- a/src/N_m3u8DL-RE/CommandLine/MyOption.cs +++ b/src/N_m3u8DL-RE/CommandLine/MyOption.cs @@ -18,6 +18,10 @@ namespace N_m3u8DL_RE.CommandLine /// public string[]? Keys { get; set; } /// + /// See: . + /// + public string? BaseUrl { get; set; } + /// /// See: . /// public string? KeyTextFile { get; set; } diff --git a/src/N_m3u8DL-RE/Program.cs b/src/N_m3u8DL-RE/Program.cs index 8bda2b4..6fde3c6 100644 --- a/src/N_m3u8DL-RE/Program.cs +++ b/src/N_m3u8DL-RE/Program.cs @@ -98,6 +98,7 @@ namespace N_m3u8DL_RE { AppendUrlParams = option.AppendUrlParams, UrlProcessorArgs = option.UrlProcessorArgs, + BaseUrl = option.BaseUrl! }; //设置Headers