No description
| lib | ||
| .gitignore | ||
| index.js | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| srt.jpg | ||
| yarn.lock | ||
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);
bodystring - Your subtitles in SRT format
From file
const mySrtFile = new subtools.SubFile(file, encoding);
filestring - Path to *.srt fileencodingstring (optional) - File encoding
Default :utf-8
Sub class
subtitlesarray - List ofSubtitleinstancessentencesarray - List ofSentenceinstancesgetSubtitlefunction - Get subtitlekeyinteger - Subtitle key
printfunction - Export subtitles to variablewritefunction - Export subtitles to filefilestring - Path to file
SubFile class (inherits from Sub)
Sub class properties and methods +
filestring - Path to *.srt filewritefunction - Export subtitles to filefilestring - Path to file
Default : initial file path
Subtitle class
keyinteger - SRT keybegintime -Dateinstance matching SRT begin timecodeendtime -Dateinstance matching SRT end timecodetextstring - SRT text, newlines removedsentencesarray - List ofSentencepartially or entirely present in subtitlegetPrevfunction - Get previous subtitlegetNextfunction - Get next subtitlesetTextfunction - Change subtitle text and auto adapt timecodesaddTextfunction - Append text to subtitle bodypositioninteger - Substring index
removeTextfunction - Remove text from subtitle bodystartinteger - Substring start indexendinteger - Substring end index
printfunction - Export individual subtitle item to variable
Sentence class
subtitlesarray - List ofSubtitlepartially or entirely containing the sentencetextstring - Sentence bodypositioninteger - Substring index of sentence in subtitle textsetTextfunction - Change sentence text and auto-update relatedSubtitleinstancestextstring
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
