subtools
v1.0.1
Published
Advanced SRT subtitles parser featuring sentence analysis
Downloads
1
Maintainers
Readme
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
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 fileencoding
string (optional) - File encoding Default :utf-8
Sub
class
subtitles
array - List ofSubtitle
instancessentences
array - List ofSentence
instancesgetSubtitle
function - Get subtitlekey
integer - Subtitle key
print
function - Export subtitles to variablewrite
function - Export subtitles to filefile
string - Path to file
SubFile
class (inherits from Sub
)
Sub
class properties and methods +
file
string - Path to *.srt filewrite
function - Export subtitles to filefile
string - Path to file Default : initial file path
Subtitle
class
key
integer - SRT keybegin
time -Date
instance matching SRT begin timecodeend
time -Date
instance matching SRT end timecodetext
string - SRT text, newlines removedsentences
array - List ofSentence
partially or entirely present in subtitlegetPrev
function - Get previous subtitlegetNext
function - Get next subtitlesetText
function - Change subtitle text and auto adapt timecodesaddText
function - Append text to subtitle bodyposition
integer - Substring index
removeText
function - Remove text from subtitle bodystart
integer - Substring start indexend
integer - Substring end index
print
function - Export individual subtitle item to variable
Sentence
class
subtitles
array - List ofSubtitle
partially or entirely containing the sentencetext
string - Sentence bodyposition
integer - Substring index of sentence in subtitle textsetText
function - Change sentence text and auto-update relatedSubtitle
instances
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