From 2299241d9d6689c3f067742acdd8e791db6a5c97 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Fri, 14 Oct 2022 19:16:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSRT=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=AD=97=E5=B9=95=E8=A6=86=E7=9B=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs | 2 +- src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs | 2 +- .../DownloadManager/SimpleDownloadManager.cs | 14 ++++---------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs b/src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs index e5cdbe1..027f2d7 100644 --- a/src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs +++ b/src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs @@ -52,7 +52,7 @@ namespace N_m3u8DL_RE.Common.Util Logger.Debug(webRequest.Headers.ToString()); //手动处理跳转,以免自定义Headers丢失 var webResponse = await AppHttpClient.SendAsync(webRequest, HttpCompletionOption.ResponseHeadersRead); - if (webResponse.StatusCode == HttpStatusCode.Found || webResponse.StatusCode == HttpStatusCode.Moved) + if (webResponse.StatusCode == HttpStatusCode.Found || webResponse.StatusCode == HttpStatusCode.Moved || webResponse.StatusCode == HttpStatusCode.SeeOther) { HttpResponseHeaders respHeaders = webResponse.Headers; Logger.Debug(respHeaders.ToString()); diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index da93eb8..f91df89 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -433,7 +433,7 @@ namespace N_m3u8DL_RE.CommandLine Environment.Exit(0); } - var rootCommand = new RootCommand("N_m3u8DL-RE (Beta version) 20221011") + var rootCommand = new RootCommand("N_m3u8DL-RE (Beta version) 20221014") { Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, BinaryMerge, DelAfterDone, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs index 29f18e8..f496f3f 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs @@ -291,6 +291,10 @@ namespace N_m3u8DL_RE.DownloadManager else if (streamSpec.MediaType == MediaType.AUDIO && streamSpec.Extension == "m4s") outputExt = ".m4a"; else if (streamSpec.MediaType != MediaType.SUBTITLES && streamSpec.Extension == "m4s") outputExt = ".mp4"; + if (DownloaderConfig.MyOptions.SubtitleFormat == Enum.SubtitleFormat.SRT && outputExt == ".vtt") + { + outputExt = ".srt"; + } var output = Path.Combine(saveDir, saveName + outputExt); //检测目标文件是否存在 @@ -369,7 +373,6 @@ namespace N_m3u8DL_RE.DownloadManager { path = Path.ChangeExtension(path, ".srt"); subContentFixed = OtherUtil.WebVtt2Other(finalVtt, DownloaderConfig.MyOptions.SubtitleFormat); - output = Path.ChangeExtension(output, ".srt"); } await File.WriteAllTextAsync(path, subContentFixed, Encoding.UTF8); FileDic[keys.First()] = new DownloadResult() @@ -404,7 +407,6 @@ namespace N_m3u8DL_RE.DownloadManager { path = Path.ChangeExtension(path, ".srt"); subContentFixed = OtherUtil.WebVtt2Other(finalVtt, DownloaderConfig.MyOptions.SubtitleFormat); - output = Path.ChangeExtension(output, ".srt"); } await File.WriteAllTextAsync(path, subContentFixed, Encoding.UTF8); FileDic[firstKey] = new DownloadResult() @@ -412,8 +414,6 @@ namespace N_m3u8DL_RE.DownloadManager ActualContentLength = subContentFixed.Length, ActualFilePath = path }; - //修改输出后缀 - output = Path.ChangeExtension(output, Path.GetExtension(path)); } } @@ -437,7 +437,6 @@ namespace N_m3u8DL_RE.DownloadManager { path = Path.ChangeExtension(path, ".srt"); subContentFixed = OtherUtil.WebVtt2Other(finalVtt, DownloaderConfig.MyOptions.SubtitleFormat); - output = Path.ChangeExtension(output, ".srt"); } await File.WriteAllTextAsync(path, subContentFixed, Encoding.UTF8); FileDic[firstKey] = new DownloadResult() @@ -445,8 +444,6 @@ namespace N_m3u8DL_RE.DownloadManager ActualContentLength = subContentFixed.Length, ActualFilePath = path }; - //修改输出后缀 - output = Path.ChangeExtension(output, Path.GetExtension(path)); } //自动修复TTML mp4字幕 @@ -474,7 +471,6 @@ namespace N_m3u8DL_RE.DownloadManager { path = Path.ChangeExtension(path, ".srt"); subContentFixed = OtherUtil.WebVtt2Other(finalVtt, DownloaderConfig.MyOptions.SubtitleFormat); - output = Path.ChangeExtension(output, ".srt"); } await File.WriteAllTextAsync(path, subContentFixed, Encoding.UTF8); FileDic[firstKey] = new DownloadResult() @@ -482,8 +478,6 @@ namespace N_m3u8DL_RE.DownloadManager ActualContentLength = subContentFixed.Length, ActualFilePath = path }; - //修改输出后缀 - output = Path.ChangeExtension(output, Path.GetExtension(path)); } bool mergeSuccess = false;