diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index 8af6470..b67c7d2 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine { internal partial class CommandInvoker { - public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20221117"; + public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20221120"; [GeneratedRegex("((best|worst)\\d*|all)")] private static partial Regex ForStrRegex(); diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs index d092909..1f0d10c 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs @@ -345,7 +345,7 @@ namespace N_m3u8DL_RE.DownloadManager } } //写出字幕 - var files = FileDic.Values.Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); + var files = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).ToArray(); foreach (var item in files) File.Delete(item); FileDic.Clear(); var index = 0; @@ -375,11 +375,11 @@ namespace N_m3u8DL_RE.DownloadManager if (sawVtt) { Logger.WarnMarkUp(ResString.fixingVTTmp4); - var mp4s = FileDic.Values.Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".m4s")).OrderBy(s => s).ToArray(); + var mp4s = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".m4s")).ToArray(); var finalVtt = MP4VttUtil.ExtractSub(mp4s, timescale); //写出字幕 var firstKey = FileDic.Keys.First(); - var files = FileDic.Values.Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); + var files = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).ToArray(); foreach (var item in files) File.Delete(item); FileDic.Clear(); var index = 0; @@ -405,11 +405,11 @@ namespace N_m3u8DL_RE.DownloadManager && streamSpec.Extension != null && streamSpec.Extension.Contains("ttml")) { Logger.WarnMarkUp(ResString.fixingTTML); - var mp4s = FileDic.Values.Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".ttml")).OrderBy(s => s).ToArray(); + var mp4s = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".ttml")).ToArray(); var finalVtt = MP4TtmlUtil.ExtractFromTTMLs(mp4s, 0); //写出字幕 var firstKey = FileDic.Keys.First(); - var files = FileDic.Values.Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); + var files = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).ToArray(); //处理图形字幕 if (finalVtt.Cues.All(v => v.Payload.StartsWith("Base64::"))) @@ -455,11 +455,11 @@ namespace N_m3u8DL_RE.DownloadManager //var initFile = FileDic.Values.Where(v => Path.GetFileName(v!.ActualFilePath).StartsWith("_init")).FirstOrDefault(); //var iniFileBytes = File.ReadAllBytes(initFile!.ActualFilePath); //var sawTtml = MP4TtmlUtil.CheckInit(iniFileBytes); - var mp4s = FileDic.Values.Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".m4s")).OrderBy(s => s).ToArray(); + var mp4s = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".m4s")).ToArray(); var finalVtt = MP4TtmlUtil.ExtractFromMp4s(mp4s, 0); //写出字幕 var firstKey = FileDic.Keys.First(); - var files = FileDic.Values.Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); + var files = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).ToArray(); //处理图形字幕 if (finalVtt.Cues.All(v => v.Payload.StartsWith("Base64::"))) @@ -503,14 +503,14 @@ namespace N_m3u8DL_RE.DownloadManager if (DownloaderConfig.MyOptions.BinaryMerge || streamSpec.MediaType == MediaType.SUBTITLES) { Logger.InfoMarkUp(ResString.binaryMerge); - var files = FileDic.Values.Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); + var files = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).ToArray(); MergeUtil.CombineMultipleFilesIntoSingleFile(files, output); mergeSuccess = true; } else { //ffmpeg合并 - var files = FileDic.Values.Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); + var files = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).ToArray(); Logger.InfoMarkUp(ResString.ffmpegMerge); var ext = streamSpec.MediaType == MediaType.AUDIO ? "m4a" : "mp4"; var ffOut = Path.Combine(Path.GetDirectoryName(output)!, Path.GetFileNameWithoutExtension(output) + $".{ext}"); diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs index 111857c..ccf634c 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs @@ -376,7 +376,7 @@ namespace N_m3u8DL_RE.DownloadManager var (sawVtt, timescale) = MP4VttUtil.CheckInit(iniFileBytes); if (sawVtt) { - var mp4s = FileDic.Values.Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".m4s")).OrderBy(s => s).ToArray(); + var mp4s = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".m4s")).ToArray(); if (firstSub) { currentVtt = MP4VttUtil.ExtractSub(mp4s, timescale); @@ -394,7 +394,7 @@ namespace N_m3u8DL_RE.DownloadManager if (DownloaderConfig.MyOptions.AutoSubtitleFix && streamSpec.MediaType == Common.Enum.MediaType.SUBTITLES && streamSpec.Extension != null && streamSpec.Extension.Contains("ttml")) { - var mp4s = FileDic.Values.Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".ttml")).OrderBy(s => s).ToArray(); + var mp4s = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".ttml")).ToArray(); if (firstSub) { if (baseTimestamp != 0) @@ -421,7 +421,7 @@ namespace N_m3u8DL_RE.DownloadManager //var initFile = FileDic.Values.Where(v => Path.GetFileName(v!.ActualFilePath).StartsWith("_init")).FirstOrDefault(); //var iniFileBytes = File.ReadAllBytes(initFile!.ActualFilePath); //var sawTtml = MP4TtmlUtil.CheckInit(iniFileBytes); - var mp4s = FileDic.Values.Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".m4s")).OrderBy(s => s).ToArray(); + var mp4s = FileDic.OrderBy(s => s.Key.Index).Select(s => s.Value).Select(v => v!.ActualFilePath).Where(p => p.EndsWith(".m4s")).ToArray(); if (firstSub) { if (baseTimestamp != 0) @@ -484,7 +484,7 @@ namespace N_m3u8DL_RE.DownloadManager if (streamSpec.MediaType != MediaType.SUBTITLES) { var initResult = streamSpec.Playlist!.MediaInit != null ? FileDic[streamSpec.Playlist!.MediaInit!]! : null; - var files = FileDic.Where(f => f.Key != streamSpec.Playlist!.MediaInit).Select(f => f.Value).Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); + var files = FileDic.Where(f => f.Key != streamSpec.Playlist!.MediaInit).OrderBy(s => s.Key.Index).Select(f => f.Value).Select(v => v!.ActualFilePath).ToArray(); if (initResult != null && mp4InitFile != "") { //shaka实时解密不需要init文件用于合并,mp4decrpyt需要 @@ -513,7 +513,7 @@ namespace N_m3u8DL_RE.DownloadManager else { var initResult = streamSpec.Playlist!.MediaInit != null ? FileDic[streamSpec.Playlist!.MediaInit!]! : null; - var files = FileDic.Select(f => f.Value).Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); + var files = FileDic.OrderBy(s => s.Key.Index).Select(f => f.Value).Select(v => v!.ActualFilePath).ToArray(); foreach (var inputFilePath in files) { if (!DownloaderConfig.MyOptions.LiveKeepSegments && !Path.GetFileName(inputFilePath).StartsWith("_init"))