6.0.4 • Published 1 year ago

srt-validator v6.0.4

Weekly downloads
808
License
BSD-3-Clause
Repository
github
Last release
1 year ago

npm node issues license jest codecov code-style build-and-test publish-to-npm

Installation

yarn add srt-validator

Or

npm install srt-validator --save

Examples

SRT file (also known as SubRip Subtitle file) is a plain-text file that contains subtitles with the start and end timecodes of the text to ensure the subtitles match the audio. It also inclues the sequential number of subtitles. A sample SRT looks like this:

1
00:02:17,440 --> 00:02:20,375
Senator, we're making
our final approach into Coruscant.

2
00:02:20,476 --> 00:02:22,501
Very good, Lieutenant.

This library only exposes a single util function srtValidator(input) which takes a string as an input and validates it against the SRT spec. The output of this function is an array of error objects. If the array is empty then there are no errors and the SRT is valid.

Valid SRT

import srtValidator from 'srt-validator';

const srtString = `1
00:02:17,440 --> 00:02:20,375
Senator, we're making
our final approach into Coruscant.

2
00:02:20,476 --> 00:02:22,501
Very good, Lieutenant.`;

srtValidator(srtString);

This will return:

[];

Invalid SRT

import srtValidator from 'srt-validator';

const srtString = `1
02:01:17,440 --> 02:00:20,375
Forget it, Jake.
It's Chinatown.`;

srtValidator(srtString);

This will return:

[
  {
    errorCode: 'validatorErrorStartTime',
    lineNumber: 2,
    message: 'start time should be less than end time',
    validator: 'CaptionTimeSpanValidator',
  },
];

Documentation

Attribution

License

MIT licensed.

6.0.4

1 year ago

5.1.4

2 years ago

5.0.5

2 years ago

5.1.3

2 years ago

5.0.4

2 years ago

5.1.2

2 years ago

5.0.3

2 years ago

5.1.1

2 years ago

5.0.2

2 years ago

5.1.0

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

6.0.1

2 years ago

6.0.3

2 years ago

4.0.0

2 years ago

5.1.6

2 years ago

3.2.4

3 years ago

3.2.2

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.2.3

3 years ago

3.1.3

4 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago