npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parse-srt

v1.0.0-alpha

Published

Parse and convert SRT subtitles into JSON format.

Downloads

73,509

Readme

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

| 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. |

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)

License and copyright

Released under the MIT license

Copyright (c) 2016 Luís Rodrigues