plussub / srt-vtt-parser

A dependency free SRT / VTT subtitle parser, written in Typescript.
MIT License
22 stars 5 forks source link

Last entry is cut off from result #6

Closed ringge closed 8 months ago

ringge commented 9 months ago

Hello, I tried to run parse for both srt file and vtt file, using the texts provided in the example also, but the last entry was cut-off from the result, so instead of showing 3 entries, it only showed 2 entries. See Stackblitz example: https://stackblitz.com/edit/stackblitz-starters-1mdsrm?file=app%2Fpage.tsx

✓ Compiled in 281ms (650 modules) [ { id: '1', from: 102821, to: 104289, text: '(SIREN WAILING IN DISTANCE)\nmultiline test' }, { id: '2', from: 105365, to: 108084, text: "DRIVER: There's 100,000 streets in this city." } ] Please help to check, thanks

ste-xx commented 8 months ago

you just need a new line:

export const vttFile = `WEBVTT

1
00:01:42.821 --> 00:01:44.289
(SIREN WAILING IN DISTANCE)
multiline test

2
00:01:45.365 --> 00:01:48.084
<i>DRIVER: There's 100,000 streets in this city.</i>

3
00:01:49.077 --> 00:01:51.421
You don't need to know the route.`;

to

export const vttFile = `WEBVTT

1
00:01:42.821 --> 00:01:44.289
(SIREN WAILING IN DISTANCE)
multiline test

2
00:01:45.365 --> 00:01:48.084
<i>DRIVER: There's 100,000 streets in this city.</i>

3
00:01:49.077 --> 00:01:51.421
You don't need to know the route.
`;
ringge commented 8 months ago

well, VTT file does not always have that new line

ste-xx commented 8 months ago

They should: https://www.w3.org/TR/webvtt1/#webvtt-cue-block At least that's what the RFC standard says, but I'm on your side and think the parser should handle it.

Currently a workaround would be to just add a new line to a subtitle file.

ringge commented 8 months ago

They should: https://www.w3.org/TR/webvtt1/#webvtt-cue-block At least that's what the RFC standard says, but I'm on your side and think the parser should handle it.

Currently a workaround would be to just add a new line to a subtitle file.

Thanks a lot, really appreciate it!

ste-xx commented 8 months ago

Fixed in 1.1.1