mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 09:49:20 +02:00
Fix chapters import
This commit is contained in:
parent
7a953a6b2f
commit
f9e710e7d4
4 changed files with 31 additions and 14 deletions
|
@ -2,7 +2,7 @@ import { timeToInt, timecodeRegexString } from '../common/date.js'
|
|||
|
||||
const timecodeRegex = new RegExp(`^(${timecodeRegexString})\\s`)
|
||||
|
||||
export function parseChapters (text: string) {
|
||||
export function parseChapters (text: string, maxTitleLength: number) {
|
||||
if (!text) return []
|
||||
|
||||
const lines = text.split(/\r?\n|\r|\n/g)
|
||||
|
@ -25,8 +25,11 @@ export function parseChapters (text: string) {
|
|||
const timecode = timeToInt(timecodeText)
|
||||
const title = line.replace(matched[0], '')
|
||||
|
||||
chapters.push({ timecode, title })
|
||||
chapters.push({ timecode, title: title.slice(0, maxTitleLength) })
|
||||
}
|
||||
|
||||
return chapters
|
||||
// Only consider chapters if there are more than one
|
||||
if (chapters.length > 1) return chapters
|
||||
|
||||
return []
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue