No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KaKi87 c0b6b7f7c6 Explain Sentence.setText parameter 3 months ago
lib Initial commit 3 months ago
.gitignore Initial commit 3 months ago
LICENSE Initial commit 3 months ago
README.md Explain Sentence.setText parameter 3 months ago
index.js Initial commit 3 months ago
package.json npmjs.com failed 3 months ago
srt.jpg Initial commit 3 months ago
yarn.lock Initial commit 3 months ago

README.md

subtools

Advanced SRT subtitles parser.

Getting started

Prerequisites

  • NodeJS
  • NPM
  • Yarn

Install

From npm

yarn add subtools

or

npm i subtools

Use

The SRT format

srt

Source : 3PlayMedia

Import module

const subtools = require('subtools');

Import subtitles

From variable
const mySubtitles = new subtools.Sub(body);
  • body string - Your subtitles in SRT format
From file
const mySrtFile = new subtools.SubFile(file, encoding);
  • file string - Path to *.srt file
  • encoding string (optional) - File encoding
    Default : utf-8

Sub class

  • subtitles array - List of Subtitle instances
  • sentences array - List of Sentence instances
  • getSubtitle function - Get subtitle
    • key integer - Subtitle key
  • print function - Export subtitles to variable
  • write function - Export subtitles to file
    • file string - Path to file

SubFile class (inherits from Sub)

Sub class properties and methods +

  • file string - Path to *.srt file
  • write function - Export subtitles to file
    • file string - Path to file
      Default : initial file path

Subtitle class

  • key integer - SRT key
  • begin time - Date instance matching SRT begin timecode
  • end time - Date instance matching SRT end timecode
  • text string - SRT text, newlines removed
  • sentences array - List of Sentence partially or entirely present in subtitle
  • getPrev function - Get previous subtitle
  • getNext function - Get next subtitle
  • setText function - Change subtitle text and auto adapt timecodes
  • addText function - Append text to subtitle body
    • position integer - Substring index
  • removeText function - Remove text from subtitle body
    • start integer - Substring start index
    • end integer - Substring end index
  • print function - Export individual subtitle item to variable

Sentence class

  • subtitles array - List of Subtitle partially or entirely containing the sentence
  • text string - Sentence body
  • position integer - Substring index of sentence in subtitle text
  • setText function - Change sentence text and auto-update related Subtitle instances
    • text string

Planned features

I designed this module to make subtitle translations easier with sentence context.
However, I’ll add more features that common subtitles tools modules have.

Changelog

  • 1.0.1 (2019-05-11) • Initial release