Skip to content

Node Module

Kain edited this page Jan 20, 2024 · 3 revisions

subclean

NPM NPM Documentation Maintenance License: MIT

As of 1.6.2 and above this can now be used as a node module, allowing you to pass raw text through the cleanRaw function. Usage is as follows:

npm install subclean --save
import { subclean } from "subclean";

const testdata = `1
00:00:06,000 --> 00:00:12,074
Watch Movies, TV Series and Live Sports
Signup Here -> WWW.ADMITME.APP

2
00:00:27,319 --> 00:00:28,820
Or you can remove that annoying ad using subclean!

3
00:00:28,903 --> 00:00:30,447
Now with support for node modules.`;

subclean.cleanRaw(testdata).then(console.log);

Result:

1
00:00:27,319 --> 00:00:28,820
Or you can remove that annoying ad using subclean!

2
00:00:28,903 --> 00:00:30,447
Now with support for node modules.

You can still pass arguments to customize the process.

const config = { nochains: true, ne: true };
subclean.cleanRaw(testdata, config).then(console.log);

If the data is invalid you will receive an error

const testdata = `this is invalid data`;
subclean.cleanRaw(testdata).then(console.log).catch(console.log);
// Error: Unable to parse subtitles
Clone this wiki locally