Fix duplicate chapters error

pull/6135/head
Chocobozzz 2024-01-18 09:17:13 +01:00
parent 12ea8f0dd1
commit eb02a5dd5d
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 6 additions and 0 deletions

View File

@ -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)
}
}