Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parse-srt

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-srt

Parse and convert SRT subtitles into JSON format.

  • 1.0.0-alpha
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

parseSRT

js-standard-style latest-release GitHub issues license

A standalone and dependency-free function to parse and convert SRT subtitle data into JSON format. This has been adapted from the popcorn.js SRT parse plugin source code. The code to parse the SRT data is basically the same, with some differences in how the data is output.

Installation

Via Bower

bower install parse-srt

Via NPM

npm install parse-srt

Usage

parseSRT is an UMD module. You can load it into your application either by importing the module, or loading the script in your page.

If you are importing the parseSRT module via Webpack, Browserify or similar, make sure that the module name parse-srt is being resolved correctly to the Bower or NPM packages folder.

Via ES6 syntax

import parseSRT from 'parse-srt'

Via CommonJS syntax

var parseSRT = require('parse-srt')

Via the script tag

<script src="/scripts/parseSRT.js"></script> // Change the path as necessary

API

parseSRT(String data)

Parse and convert a SRT subtitles file data into JSON format.

Parameters

NameTypeRequiredDefaultDescription
dataStringfalse''The contents of a SRT subtitles file to be converted. If empty, an empty array will be returned.

Returns

[Array] - An array containing an object for each subtitle.

Example

var jsonSubs = parseSRT(srtData)

The subtitle object has the following structure:

PropertyTypeDescription
idNumberThe subtitle ID number, which corresponds to the order in the sequence of subtitles present in the SRT file.
startNumberThe start timestamp in seconds
endNumberThe end timestamp in seconds
textStringThe contents of the subtitle. HTML tags are kept for styling.

Brower support

parseSRT, although not tested in all of them, was created using features supported by these browsers.

  • Android Browser 4+
  • Blackberry Browser 7+
  • Chrome 13+
  • Firefox 4+
  • Internet Explorer 9+
  • Opera 12+
  • Opera Mini 5+
  • Safari 7+

Support

If you want to request new features or find any bugs, please open a ticket on the issues page and I'll review it as soon as possible.

Authors and Contributors

Created by Luís Rodrigues (@MrSlide)

Released under the MIT license

Copyright (c) 2016 Luís Rodrigues

Keywords

FAQs

Package last updated on 09 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc