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;