private static IEnumerable <Chapter> ToChapter(ChapterAtom atom, int index) { if (atom.ChapterTimeStart != null) { var startChapter = new Chapter { Number = index, Time = ToolKits.RTimeFormat.Match(atom.ChapterTimeStart).Value.ToTimeSpan(), Name = atom.ChapterDisplay.ChapterString ?? "" }; yield return(startChapter); } if (atom.SubChapterAtom != null) { foreach (var chapterAtom in atom.SubChapterAtom) { foreach (var chapter in ToChapter(chapterAtom, index)) { yield return(chapter); } } } if (atom.ChapterTimeEnd != null) { var endChapter = new Chapter { Number = index, Time = ToolKits.RTimeFormat.Match(atom.ChapterTimeEnd).Value.ToTimeSpan(), Name = atom.ChapterDisplay.ChapterString ?? "" }; yield return(endChapter); } }
private int TimecodeComparator(ChapterAtom x, ChapterAtom y) { var firstStart = TimeCodeUtil.TimeCodeToTimespan(x.ChapterTimecodeStart); var secondStart = TimeCodeUtil.TimeCodeToTimespan(y.ChapterTimecodeStart); return firstStart.CompareTo(secondStart); }