mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Fix chapters import
This commit is contained in:
parent
7a953a6b2f
commit
f9e710e7d4
4 changed files with 31 additions and 14 deletions
|
@ -5,6 +5,7 @@ import { VideoChapterModel } from '@server/models/video/video-chapter.js'
|
|||
import { MVideoImmutable } from '@server/types/models/index.js'
|
||||
import { Transaction } from 'sequelize'
|
||||
import { InternalEventEmitter } from './internal-event-emitter.js'
|
||||
import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js'
|
||||
|
||||
const lTags = loggerTagsFactory('video', 'chapters')
|
||||
|
||||
|
@ -44,7 +45,7 @@ export async function replaceChaptersFromDescriptionIfNeeded (options: {
|
|||
}) {
|
||||
const { transaction, video, newDescription, oldDescription = '' } = options
|
||||
|
||||
const chaptersFromOldDescription = sortBy(parseChapters(oldDescription), 'timecode')
|
||||
const chaptersFromOldDescription = sortBy(parseChapters(oldDescription, CONSTRAINTS_FIELDS.VIDEO_CHAPTERS.TITLE.max), 'timecode')
|
||||
const existingChapters = await VideoChapterModel.listChaptersOfVideo(video.id, transaction)
|
||||
|
||||
logger.debug(
|
||||
|
@ -54,7 +55,7 @@ export async function replaceChaptersFromDescriptionIfNeeded (options: {
|
|||
|
||||
// Then we can update chapters from the new description
|
||||
if (areSameChapters(chaptersFromOldDescription, existingChapters)) {
|
||||
const chaptersFromNewDescription = sortBy(parseChapters(newDescription), 'timecode')
|
||||
const chaptersFromNewDescription = sortBy(parseChapters(newDescription, CONSTRAINTS_FIELDS.VIDEO_CHAPTERS.TITLE.max), 'timecode')
|
||||
if (chaptersFromOldDescription.length === 0 && chaptersFromNewDescription.length === 0) return false
|
||||
|
||||
await replaceChapters({ video, chapters: chaptersFromNewDescription, transaction })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue