Skip to content

Commit

Permalink
1.2.7
Browse files Browse the repository at this point in the history
Removes all cases of `\r` in subtitle files to prevent them from breaking the parser
  • Loading branch information
DrKain committed Oct 21, 2021
1 parent 9936ff0 commit 2a465a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ var Subclean = /** @class */ (function () {
this.log('[Error] Failed to load a filter: ' + filter);
}
};
Subclean.prototype.tryFixLineBreaks = function () { };
/**
* Add your own items to the blacklist. Currently not used.
* Needs to be passed a file name to read
Expand All @@ -181,7 +182,10 @@ var Subclean = /** @class */ (function () {
this.loadBlacklist('main');
this.loadBlacklist('users');
// Parse the subtitle file
var nodes = subtitle_1.parseSync(fs.readFileSync(this.args.input, 'utf-8'));
var fileData = fs.readFileSync(this.args.input, 'utf-8');
// Remove all cases of \r (parser can not handle these)
fileData = fileData.replace(/\r/g, ' ');
var nodes = subtitle_1.parseSync(fileData);
var hits = 0;
// Remove ads
nodes.forEach(function (node, index) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "subclean",
"version": "1.2.6",
"version": "1.2.7",
"description": "A CLI package to clean subtitle files of advertising",
"main": "lib/index.js",
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ class Subclean {
this.loadBlacklist('users');

// Parse the subtitle file
const nodes = parseSync(fs.readFileSync(this.args.input, 'utf-8'));
let fileData = fs.readFileSync(this.args.input, 'utf-8');

// Remove all cases of \r (parser can not handle these)
fileData = fileData.replace(/\r/g, ' ');

const nodes = parseSync(fileData);
let hits = 0;

// Remove ads
Expand Down

0 comments on commit 2a465a5

Please sign in to comment.