Make better use of heirarch chapters to combine section title audio (which is usually short, eg "Part 1") with the following full-length chapter.
This commit is contained in:
parent
9c53d9bf87
commit
13149eff08
@ -194,19 +194,31 @@ namespace FileLiberator
|
|||||||
|
|
||||||
private List<AudibleApi.Common.Chapter> getChapters(IEnumerable<AudibleApi.Common.Chapter> chapters)
|
private List<AudibleApi.Common.Chapter> getChapters(IEnumerable<AudibleApi.Common.Chapter> chapters)
|
||||||
{
|
{
|
||||||
List<AudibleApi.Common.Chapter> chaps = chapters.ToList();
|
List<AudibleApi.Common.Chapter> chaps = new();
|
||||||
|
|
||||||
foreach (var c in chapters)
|
foreach (var c in chapters)
|
||||||
{
|
{
|
||||||
if (c.Chapters is not null)
|
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)
|
foreach (var child in children)
|
||||||
child.Title = string.IsNullOrEmpty(c.Title) ? child.Title : $"{c.Title}: {child.Title}";
|
child.Title = string.IsNullOrEmpty(c.Title) ? child.Title : $"{c.Title}: {child.Title}";
|
||||||
|
|
||||||
chaps.AddRange(children);
|
chaps.AddRange(children);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
chaps.Add(c);
|
||||||
}
|
}
|
||||||
return chaps;
|
return chaps;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user