diff --git a/Source/FileLiberator/DownloadDecryptBook.cs b/Source/FileLiberator/DownloadDecryptBook.cs index f3686ca5..257a17cf 100644 --- a/Source/FileLiberator/DownloadDecryptBook.cs +++ b/Source/FileLiberator/DownloadDecryptBook.cs @@ -194,19 +194,31 @@ namespace FileLiberator private List getChapters(IEnumerable chapters) { - List chaps = chapters.ToList(); + List chaps = new(); foreach (var c in chapters) { if (c.Chapters is not null) { - var children = getChapters(c.Chapters); + var firstSub = new AudibleApi.Common.Chapter + { + Title = $"{c.Title}: {c.Chapters[0].Title}", + StartOffsetMs = c.StartOffsetMs, + StartOffsetSec = c.StartOffsetSec, + LengthMs = c.LengthMs + c.Chapters[0].LengthMs + }; + + chaps.Add(firstSub); + + var children = getChapters(c.Chapters[1..]); foreach (var child in children) child.Title = string.IsNullOrEmpty(c.Title) ? child.Title : $"{c.Title}: {child.Title}"; chaps.AddRange(children); } + else + chaps.Add(c); } return chaps; }