Skip to content

Commit 927952c

Browse files
committed
Fix bug in calculating max length of chapters in summary
1 parent 9e17a27 commit 927952c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

markut.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,14 @@ func (context EvalContext) PrintSummary() error {
312312
fmt.Printf(">>> YouTube Chapters (%d):\n", len(context.chapters))
313313
maxLength := Millis(0);
314314
for i, chapter := range context.chapters {
315-
if i > 0 {
316-
length := chapter.Timestamp - context.chapters[i - 1].Timestamp;
317-
maxLength = max(maxLength, length)
315+
var length Millis;
316+
if i + 1 < len(context.chapters) {
317+
length = context.chapters[i + 1].Timestamp;
318+
} else {
319+
length = fullLength;
318320
}
321+
length -= chapter.Timestamp;
322+
maxLength = max(maxLength, length)
319323
}
320324
locWidth = MaxChaptersLocWidthPlusOne(context.chapters)
321325
for i, chapter := range context.chapters {

0 commit comments

Comments
 (0)