Skip to content

Commit

Permalink
Merge pull request #10 from wfwf1997/master
Browse files Browse the repository at this point in the history
Fix various chapter issues
  • Loading branch information
LittlePox authored Feb 19, 2020
2 parents 601f6bf + 85c7743 commit cca25c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 5 additions & 3 deletions OKEGui/OKEGui/Task/ChapterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
20 changes: 11 additions & 9 deletions OKEGui/OKEGui/Worker/ExecuteTaskService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand All @@ -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 = "压制中";
Expand Down

0 comments on commit cca25c2

Please sign in to comment.