From d5d9978cdb7316c1b8d6f57cbf37db0118c91479 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Wed, 19 Apr 2023 19:27:27 -0700 Subject: [PATCH] [BUGFIX] Fix splitting chapters extracted from comments (#593) --- src/ytdl_sub/utils/chapters.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ytdl_sub/utils/chapters.py b/src/ytdl_sub/utils/chapters.py index 7bdbf736..0875e3bc 100644 --- a/src/ytdl_sub/utils/chapters.py +++ b/src/ytdl_sub/utils/chapters.py @@ -234,14 +234,14 @@ class Chapters: timestamps: List[Timestamp] = [] titles: List[str] = [] - # Try to get actual yt-dlp chapters first, then custom chapters, then default to empty list - chapters = entry.kwargs_get( - CHAPTERS, default=entry.kwargs_get(YTDL_SUB_CUSTOM_CHAPTERS, default=[]) - ) - - for chapter in chapters: - timestamps.append(Timestamp.from_seconds(int(float(chapter["start_time"])))) - titles.append(chapter["title"]) + if entry.kwargs_contains(CHAPTERS): + for chapter in entry.kwargs_get(CHAPTERS, []): + timestamps.append(Timestamp.from_seconds(int(float(chapter["start_time"])))) + titles.append(chapter["title"]) + elif entry.kwargs_contains(YTDL_SUB_CUSTOM_CHAPTERS): + for start_time, title in entry.kwargs_get(YTDL_SUB_CUSTOM_CHAPTERS, {}).items(): + timestamps.append(Timestamp.from_str(start_time)) + titles.append(title) return Chapters(timestamps=timestamps, titles=titles)