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

kml-subtitles

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

kml-subtitles

Simple module which parses subtitle files to a javascript object

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

kml-subtitles

Simple module which parses subtitle files to a javascript object

Installation:

NodeJS:

npm install kml-subtitles

Example

Let's say we have my.srt SubRip subtitles file:

1
00:00:02,000 --> 00:00:06,000
Subtitle 1.1
Subtitle 1.2

2
00:00:28,967 --> 00:01:30,958
Subtitle 2.1
Subtitle 2.2
  1. Initialize and configure the parser
var parser = require('kml-subtitles');

var parsedSubtitles = parser({
	path : "./", //--> folder path where the subtitle files exits
    ext : ['.srt', '.vtt'], //--> subtitles extensions
    dest : "./subtitles.js", //--> default destination for exporting the parsed data
    name : "subtitles", //--> default name of the object which contains the parsed data (used for exporting to file)
});

var data = parsedSubtitles.data();

data object will look like:

{
    my : [{
        start: 2,
        end: 6,
        text: 'Subtitle 1.1<br>Subtitle 1.2'
    },
    {
        start: 28.967,
        end: 90.958,
        text: 'Subtitle 2.1<br>Subtitle 2.2'
    }]
}

2. Export the parsed data to a js file


parsedSubtitles.writeTo('export.js');

the export.js content will look like :

var subtitles = {
    my : [{
        start: 2,
        end: 6,
        text: 'Subtitle 1.1<br>Subtitle 1.2'
    },
    {
        start: 28.967,
        end: 90.958,
        text: 'Subtitle 2.1<br>Subtitle 2.2'
    }]
}

Keywords

FAQs

Package last updated on 06 Sep 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