Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix duplicate chapters error

Chocobozzzeb02a5dd5dfd
diff --git a/server/core/lib/video-chapters.ts b/server/core/lib/video-chapters.ts
index 71e2a7cf44..740493f4ae 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<number>()
+
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)
}
}