diff --git a/OKEGui/OKEGui/Task/ChapterService.cs b/OKEGui/OKEGui/Task/ChapterService.cs index 23ec8c92..3ae85912 100644 --- a/OKEGui/OKEGui/Task/ChapterService.cs +++ b/OKEGui/OKEGui/Task/ChapterService.cs @@ -67,21 +67,23 @@ public static ChapterInfo LoadChapter(TaskDetail task) { FileInfo txtChapter = new FileInfo(Path.ChangeExtension(inputFile.FullName, ".txt")); if (!txtChapter.Exists) return null; - chapterInfo = new OGMParser().Parse(txtChapter.FullName)[0]; + chapterInfo = new OGMParser().Parse(txtChapter.FullName).FirstOrDefault(); break; } case ChapterStatus.Maybe: { DirectoryInfo playlistDirectory = new DirectoryInfo(Path.Combine(inputFile.Directory.Parent.FullName, "PLAYLIST")); - chapterInfo = GetChapterFromMPLS(playlistDirectory.GetFiles("*.m2ts"), inputFile); + chapterInfo = GetChapterFromMPLS(playlistDirectory.GetFiles("*.mpls"), inputFile); break; } default: return null; } - chapterInfo.Chapters.Sort((a, b) => (int) (a.Time - b.Time).Ticks); + if (chapterInfo == null) return null; + + chapterInfo.Chapters.Sort((a, b) => a.Time.CompareTo(b.Time)); chapterInfo.Chapters = chapterInfo.Chapters .Where(x => task.LengthInMiliSec - x.Time.TotalMilliseconds > 1001).ToList(); if (chapterInfo.Chapters.Count > 1 || diff --git a/OKEGui/OKEGui/Worker/ExecuteTaskService.cs b/OKEGui/OKEGui/Worker/ExecuteTaskService.cs index a4df9107..df446baf 100644 --- a/OKEGui/OKEGui/Worker/ExecuteTaskService.cs +++ b/OKEGui/OKEGui/Worker/ExecuteTaskService.cs @@ -281,14 +281,15 @@ private void WorkerDoWork(object sender, DoWorkEventArgs e) // 添加章节文件 ChapterInfo chapterInfo = ChapterService.LoadChapter(task); - if (task.ChapterStatus == ChapterStatus.Maybe) - { - task.ChapterStatus = chapterInfo == null ? ChapterStatus.No : ChapterStatus.Added; - } - if (chapterInfo != null) { - FileInfo outputChapterFile = new FileInfo(Path.ChangeExtension(task.InputFile, ".txt")); + if (task.ChapterStatus == ChapterStatus.Maybe) + { + task.ChapterStatus = ChapterStatus.Added; + } + + FileInfo outputChapterFile = + new FileInfo(Path.ChangeExtension(task.InputFile, ".txt")); if (outputChapterFile.Exists) { File.Move(outputChapterFile.FullName, outputChapterFile.FullName + ".bak"); @@ -298,10 +299,7 @@ private void WorkerDoWork(object sender, DoWorkEventArgs e) outputChapterFile.Refresh(); OKEFile chapterFile = new OKEFile(outputChapterFile); task.MediaOutFile.AddTrack(new ChapterTrack(chapterFile)); - } - if (chapterInfo != null) - { // 用章节文件生成qpfile string qpFileName = Path.ChangeExtension(task.InputFile, ".qpf"); string qpFile = vJob.Vfr @@ -310,6 +308,10 @@ private void WorkerDoWork(object sender, DoWorkEventArgs e) File.WriteAllText(qpFileName, qpFile); processor.AppendParameter($"--qpfile \"{qpFileName}\""); } + else + { + task.ChapterStatus = ChapterStatus.No; + } // 开始压制 task.CurrentStatus = "压制中";