mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-13 09:20:27 -07:00
More accurate hb 2 pass logic
This commit is contained in:
parent
f73157eb82
commit
d949b203e5
4 changed files with 34 additions and 14 deletions
|
|
@ -1,8 +1,10 @@
|
|||
const handbrakeParser = ({
|
||||
str,
|
||||
hbPass,
|
||||
}:
|
||||
{
|
||||
str: string
|
||||
str: string,
|
||||
hbPass: number
|
||||
}): number => {
|
||||
if (typeof str !== 'string') {
|
||||
return 0;
|
||||
|
|
@ -25,13 +27,13 @@ const handbrakeParser = ({
|
|||
const outputNum = Number(output);
|
||||
if (outputNum > 0) {
|
||||
percentage = outputNum;
|
||||
}
|
||||
}
|
||||
|
||||
if (str.includes('task 1 of 2')) {
|
||||
percentage /= 2;
|
||||
} else if (str.includes('task 2 of 2')) {
|
||||
percentage = 50 + (percentage / 2);
|
||||
if (hbPass === 1) {
|
||||
percentage /= 2;
|
||||
} else if (hbPass === 2) {
|
||||
percentage = 50 + (percentage / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return percentage;
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ class CLI {
|
|||
|
||||
lastProgCheck = 0;
|
||||
|
||||
hbPass = 0;
|
||||
|
||||
constructor(config: Iconfig) {
|
||||
this.config = config;
|
||||
}
|
||||
|
|
@ -163,9 +165,17 @@ class CLI {
|
|||
}
|
||||
|
||||
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({
|
||||
str,
|
||||
hbPass: this.hbPass,
|
||||
});
|
||||
|
||||
if (percentage > 0) {
|
||||
this.updateETA(percentage);
|
||||
this.config.updateWorker({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue