srt-to-obj
Convert an .srt subtitle file to an array of object literals.
Last updated 3 years ago by radiovisual .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install srt-to-obj 
SYNC missed versions from official npm registry.

srt-to-obj Build Status

Convert an .srt subtitle file to an array of object literals.

Install

$ npm install --save srt-to-obj

Usage

Given an .srt file that looks like this:

1
00:00:55,880 --> 00:00:57,670
Line one

2
00:01:12,270 --> 00:01:13,390
Line two
Line three
Line four
Line five

3
00:01:25,360 --> 00:01:26,700
Line six

The following JavaScript:

const srtToObj = require('srt-to-obj');

srtToObj('path/to/srt/file').then(srtData => {
  console.log(srtData);
});

Would result in the following output:

[
  {
    index: '1',
    timestamp: '00:00:55,880 --> 00:00:57,670',
    start: '00:00:55,880',
    end: '00:00:57,670',
    text: 'Line one'
   }, {
    index: '2',
    timestamp: '00:01:12,270 --> 00:01:13,390',
    start: '00:01:12,270',
    end: '00:01:13,390',
    text: 'Line two\nLine three\nLine four\nLine five'
  }, {
    index: '3',
    timestamp: '00:01:25,360 --> 00:01:26,700',
    start: '00:01:25,360',
    end: '00:01:26,700',
    text: 'Line six'
  }
]

API

srtToObj(path)

path

Type: string

The path to the subtitle file you want to convert to an array of objects

License

MIT © Michael Wuergler

Current Tags

  • 0.0.3                                ...           latest (3 years ago)

3 Versions

  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |