Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
parse-srt
Advanced tools
Readme
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.
bower install parse-srt
npm install parse-srt
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.
import parseSRT from 'parse-srt'
var parseSRT = require('parse-srt')
<script src="/scripts/parseSRT.js"></script> // Change the path as necessary
Parse and convert a SRT subtitles file data into JSON format.
Parameters
Name | Type | Required | Default | Description |
---|---|---|---|---|
data | String | false | '' | 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:
Property | Type | Description |
---|---|---|
id | Number | The subtitle ID number, which corresponds to the order in the sequence of subtitles present in the SRT file. |
start | Number | The start timestamp in seconds |
end | Number | The end timestamp in seconds |
text | String | The contents of the subtitle. HTML tags are kept for styling. |
parseSRT, although not tested in all of them, was created using features supported by these browsers.
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.
Created by Luís Rodrigues (@MrSlide)
Released under the MIT license
Copyright (c) 2016 Luís Rodrigues
FAQs
Parse and convert SRT subtitles into JSON format.
The npm package parse-srt receives a total of 7,699 weekly downloads. As such, parse-srt popularity was classified as popular.
We found that parse-srt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.