More accurate hb 2 pass logic

make-only-subtitle-default
HaveAGitGat 2 years ago
parent f73157eb82
commit d949b203e5

@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.editreadyParser = exports.getFFmpegVar = exports.getFFmpegPercentage = exports.ffmpegParser = exports.handbrakeParser = void 0; exports.editreadyParser = exports.getFFmpegVar = exports.getFFmpegPercentage = exports.ffmpegParser = exports.handbrakeParser = void 0;
var handbrakeParser = function (_a) { var handbrakeParser = function (_a) {
var str = _a.str; var str = _a.str, hbPass = _a.hbPass;
if (typeof str !== 'string') { if (typeof str !== 'string') {
return 0; return 0;
} }
@ -19,14 +19,14 @@ var handbrakeParser = function (_a) {
var outputNum = Number(output); var outputNum = Number(output);
if (outputNum > 0) { if (outputNum > 0) {
percentage = outputNum; percentage = outputNum;
} if (hbPass === 1) {
}
if (str.includes('task 1 of 2')) {
percentage /= 2; percentage /= 2;
} }
else if (str.includes('task 2 of 2')) { else if (hbPass === 2) {
percentage = 50 + (percentage / 2); percentage = 50 + (percentage / 2);
} }
}
}
return percentage; return percentage;
}; };
exports.handbrakeParser = handbrakeParser; exports.handbrakeParser = handbrakeParser;

@ -92,6 +92,7 @@ var CLI = /** @class */ (function () {
this.oldEstSize = 0; this.oldEstSize = 0;
this.oldProgress = 0; this.oldProgress = 0;
this.lastProgCheck = 0; this.lastProgCheck = 0;
this.hbPass = 0;
this.updateETA = function (perc) { this.updateETA = function (perc) {
if (perc > 0) { if (perc > 0) {
if (_this.lastProgCheck === 0) { if (_this.lastProgCheck === 0) {
@ -154,8 +155,15 @@ var CLI = /** @class */ (function () {
_this.config.jobLog(str); _this.config.jobLog(str);
} }
if (_this.config.cli.toLowerCase().includes('handbrake')) { if (_this.config.cli.toLowerCase().includes('handbrake')) {
if (str.includes('task 1 of 2')) {
_this.hbPass = 1;
}
else if (str.includes('task 2 of 2')) {
_this.hbPass = 2;
}
var percentage = (0, cliParsers_1.handbrakeParser)({ var percentage = (0, cliParsers_1.handbrakeParser)({
str: str, str: str,
hbPass: _this.hbPass,
}); });
if (percentage > 0) { if (percentage > 0) {
_this.updateETA(percentage); _this.updateETA(percentage);

@ -1,8 +1,10 @@
const handbrakeParser = ({ const handbrakeParser = ({
str, str,
hbPass,
}: }:
{ {
str: string str: string,
hbPass: number
}): number => { }): number => {
if (typeof str !== 'string') { if (typeof str !== 'string') {
return 0; return 0;
@ -25,14 +27,14 @@ const handbrakeParser = ({
const outputNum = Number(output); const outputNum = Number(output);
if (outputNum > 0) { if (outputNum > 0) {
percentage = outputNum; percentage = outputNum;
}
}
if (str.includes('task 1 of 2')) { if (hbPass === 1) {
percentage /= 2; percentage /= 2;
} else if (str.includes('task 2 of 2')) { } else if (hbPass === 2) {
percentage = 50 + (percentage / 2); percentage = 50 + (percentage / 2);
} }
}
}
return percentage; return percentage;
}; };

@ -85,6 +85,8 @@ class CLI {
lastProgCheck = 0; lastProgCheck = 0;
hbPass = 0;
constructor(config: Iconfig) { constructor(config: Iconfig) {
this.config = config; this.config = config;
} }
@ -163,9 +165,17 @@ class CLI {
} }
if (this.config.cli.toLowerCase().includes('handbrake')) { if (this.config.cli.toLowerCase().includes('handbrake')) {
if (str.includes('task 1 of 2')) {
this.hbPass = 1;
} else if (str.includes('task 2 of 2')) {
this.hbPass = 2;
}
const percentage = handbrakeParser({ const percentage = handbrakeParser({
str, str,
hbPass: this.hbPass,
}); });
if (percentage > 0) { if (percentage > 0) {
this.updateETA(percentage); this.updateETA(percentage);
this.config.updateWorker({ this.config.updateWorker({

Loading…
Cancel
Save