You've already forked bilibili-subtitle
optimize
This commit is contained in:
@@ -203,18 +203,22 @@ export const parseTranscript = (filename: string, text: string | ArrayBuffer): T
|
|||||||
if (filename.toLowerCase().endsWith('.srt')) {
|
if (filename.toLowerCase().endsWith('.srt')) {
|
||||||
const lines = text.split('\n\n')
|
const lines = text.split('\n\n')
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const lines = line.split('\n')
|
try {
|
||||||
if (lines.length >= 3) {
|
const linesInner = line.trim().split('\n')
|
||||||
const time = lines[1].split(' --> ')
|
if (linesInner.length >= 3) {
|
||||||
const from = parseTime(time[0])
|
const time = linesInner[1].split(' --> ')
|
||||||
const to = parseTime(time[1])
|
const from = parseTime(time[0])
|
||||||
const content = lines.slice(2).join('\n')
|
const to = parseTime(time[1])
|
||||||
items.push({
|
const content = linesInner.slice(2).join('\n')
|
||||||
from,
|
items.push({
|
||||||
to,
|
from,
|
||||||
content,
|
to,
|
||||||
idx: items.length,
|
content,
|
||||||
})
|
idx: items.length,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('parse error', line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user