From eb02a5dd5dfd130c123747875fa9363a51eb0ef1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Jan 2024 09:17:13 +0100 Subject: [PATCH] Fix duplicate chapters error --- server/core/lib/video-chapters.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/core/lib/video-chapters.ts b/server/core/lib/video-chapters.ts index 71e2a7cf4..740493f4a 100644 --- a/server/core/lib/video-chapters.ts +++ b/server/core/lib/video-chapters.ts @@ -79,12 +79,18 @@ async function createChapters (options: { }) { const { chapters, transaction, videoId } = options + const existingTimecodes = new Set() + for (const chapter of chapters) { + if (existingTimecodes.has(chapter.timecode)) continue + await VideoChapterModel.create({ title: chapter.title, timecode: chapter.timecode, videoId }, { transaction }) + + existingTimecodes.add(chapter.timecode) } }