0.1.3 • Published 4 years ago

subtitle-parsing-tool v0.1.3

Weekly downloads
13
License
GPL-3.0
Repository
github
Last release
4 years ago

Subtitle Parsing Tool

Parses subtitle files and generates a collection of timed objects

Now includes typings!

Supported subtitle files

  • SRT
  • WebVTT

Installation

npm i subtitle-parsing-tool

Importing

Import the main parser tool function as a default export

Import types as named imports

ES6

import parser from 'subtitle-parsing-tool'

With types

import parser, { Cue, Formats } from 'subtitle-parsing-tool';

CommonJS

const parser = require('subtitle-parsing-tool');

Usage

const parsedResponsePromise = DefaultExportFunction(format, string)

Parameters

format

A string value, which denotes the format of the subtitles to be parsed. Accepts 2 values:

  • SRT
  • WEBVTT

string

A string value. The raw data for the subtitles to parse.

Return value

A Promise that resolves to an array of Cue type objects

Exported Types

The following types are available:

Formats

An exported object of strings which correspond to the supported formats

enum Formats

Formats.Srt
Formats.WebVtt

interface Cue

An object of the following shape:

{
    sequence: number;
    startTime: number;
    endTime: number;
    text: string[];
}