fix: pass full args object to CLI constructors in all plugins to prevent cliUtils TypeError on variables/liveSizeCompare
Build / Lint & Test (push) Successful in 15s
Build / Lint & Test (push) Successful in 15s
This commit is contained in:
1 parent
5447c1cbc7
commit
27fee1ee95
4 files changed
+25
-9
No files matched your search
@@ -78,6 +78,7 @@ const plugin = async (args) => {
|
|||||||
jobLog,
|
jobLog,
|
||||||
inputFileObj,
|
inputFileObj,
|
||||||
updateWorker,
|
updateWorker,
|
||||||
|
args,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { cliExitCode } = await cli.runCli();
|
const { cliExitCode } = await cli.runCli();
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ const fs = require('fs');
|
|||||||
* Naming: <baseName>.<lang>[.forced][.default][.sdh].srt
|
* Naming: <baseName>.<lang>[.forced][.default][.sdh].srt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const TEXT_CODECS = new Set(['subrip', 'srt', 'ass', 'ssa', 'webvtt', 'mov_text']);
|
const TEXT_CODECS = new Set(['subrip', 'srt', 'ass', 'ssa', 'webvtt', 'mov_text']);
|
||||||
const BITMAP_CODECS = new Set(['hdmv_pgs_subtitle', 'dvd_subtitle', 'pgssub', 'dvbsub']);
|
const BITMAP_CODECS = new Set(['hdmv_pgs_subtitle', 'dvd_subtitle', 'pgssub', 'dvbsub']);
|
||||||
|
|
||||||
const details = () => ({
|
const details = () => ({
|
||||||
name: 'Extract Subtitles & OCR Fallback',
|
name: 'Extract Subtitles & OCR Fallback',
|
||||||
@@ -79,10 +79,21 @@ const buildSuffix = (lang, stream) => {
|
|||||||
return parts.join('.');
|
return parts.join('.');
|
||||||
};
|
};
|
||||||
|
|
||||||
const runFFmpeg = async (spawnArgs, workDir, ffmpegPath, jobLog, inputFileObj, updateWorker) => {
|
/**
|
||||||
|
* Run FFmpeg via Tdarr's CLI helper.
|
||||||
|
* Passes the full args object so cliUtils can access any field it needs
|
||||||
|
* (inputFileObj, updateWorker, variables, etc.) without us having to predict them.
|
||||||
|
*/
|
||||||
|
const runFFmpeg = async (spawnArgs, args) => {
|
||||||
const { CLI } = require('../../../../FlowHelpers/1.0.0/cliUtils');
|
const { CLI } = require('../../../../FlowHelpers/1.0.0/cliUtils');
|
||||||
const cli = new CLI({
|
const cli = new CLI({
|
||||||
cli: ffmpegPath, spawnArgs, WorkDir: workDir, jobLog, inputFileObj, updateWorker,
|
cli: args.ffmpegPath,
|
||||||
|
spawnArgs,
|
||||||
|
WorkDir: args.workDir,
|
||||||
|
jobLog: args.jobLog,
|
||||||
|
inputFileObj: args.inputFileObj,
|
||||||
|
updateWorker: args.updateWorker,
|
||||||
|
args,
|
||||||
});
|
});
|
||||||
return cli.runCli();
|
return cli.runCli();
|
||||||
};
|
};
|
||||||
@@ -90,7 +101,7 @@ const runFFmpeg = async (spawnArgs, workDir, ffmpegPath, jobLog, inputFileObj, u
|
|||||||
// ─── Plugin ───────────────────────────────────────────────────────────────────
|
// ─── Plugin ───────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const plugin = async (args) => {
|
const plugin = async (args) => {
|
||||||
const { jobLog, inputFileObj, variables, workDir, updateWorker } = args;
|
const { jobLog, inputFileObj, variables, workDir } = args;
|
||||||
|
|
||||||
const inputFile = inputFileObj._id;
|
const inputFile = inputFileObj._id;
|
||||||
const sourceDir = path.dirname(inputFile);
|
const sourceDir = path.dirname(inputFile);
|
||||||
@@ -129,7 +140,7 @@ const plugin = async (args) => {
|
|||||||
if (TEXT_CODECS.has(codec)) {
|
if (TEXT_CODECS.has(codec)) {
|
||||||
const { cliExitCode } = await runFFmpeg(
|
const { cliExitCode } = await runFFmpeg(
|
||||||
['-y', '-i', inputFile, '-map', `0:${stream.index}`, '-c:s', 'srt', outSrt],
|
['-y', '-i', inputFile, '-map', `0:${stream.index}`, '-c:s', 'srt', outSrt],
|
||||||
workDir, args.ffmpegPath, jobLog, inputFileObj, updateWorker,
|
args,
|
||||||
);
|
);
|
||||||
if (cliExitCode !== 0) {
|
if (cliExitCode !== 0) {
|
||||||
jobLog(`[extractSubtitlesAndOcr] WARNING: FFmpeg failed for stream #${stream.index} (exit ${cliExitCode}).\n`);
|
jobLog(`[extractSubtitlesAndOcr] WARNING: FFmpeg failed for stream #${stream.index} (exit ${cliExitCode}).\n`);
|
||||||
@@ -146,7 +157,7 @@ const plugin = async (args) => {
|
|||||||
// Step 1: Extract to .sup
|
// Step 1: Extract to .sup
|
||||||
const { cliExitCode: extractExit } = await runFFmpeg(
|
const { cliExitCode: extractExit } = await runFFmpeg(
|
||||||
['-y', '-i', inputFile, '-map', `0:${stream.index}`, '-c:s', 'copy', tmpSup],
|
['-y', '-i', inputFile, '-map', `0:${stream.index}`, '-c:s', 'copy', tmpSup],
|
||||||
workDir, args.ffmpegPath, jobLog, inputFileObj, updateWorker,
|
args,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (extractExit !== 0) {
|
if (extractExit !== 0) {
|
||||||
@@ -164,10 +175,11 @@ const plugin = async (args) => {
|
|||||||
'/track-number:0',
|
'/track-number:0',
|
||||||
`/outputfolder:${sourceDir}`,
|
`/outputfolder:${sourceDir}`,
|
||||||
],
|
],
|
||||||
WorkDir: workDir,
|
WorkDir: workDir,
|
||||||
jobLog,
|
jobLog,
|
||||||
inputFileObj,
|
inputFileObj,
|
||||||
updateWorker,
|
updateWorker: args.updateWorker,
|
||||||
|
args,
|
||||||
});
|
});
|
||||||
const { cliExitCode: seExit } = await seCli.runCli();
|
const { cliExitCode: seExit } = await seCli.runCli();
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ const plugin = async (args) => {
|
|||||||
jobLog,
|
jobLog,
|
||||||
inputFileObj,
|
inputFileObj,
|
||||||
updateWorker,
|
updateWorker,
|
||||||
|
args,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { cliExitCode } = await cli.runCli();
|
const { cliExitCode } = await cli.runCli();
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ const plugin = async (args) => {
|
|||||||
jobLog,
|
jobLog,
|
||||||
inputFileObj,
|
inputFileObj,
|
||||||
updateWorker,
|
updateWorker,
|
||||||
|
args,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { cliExitCode: pass1Exit } = await pass1Cli.runCli();
|
const { cliExitCode: pass1Exit } = await pass1Cli.runCli();
|
||||||
@@ -211,6 +212,7 @@ const plugin = async (args) => {
|
|||||||
jobLog,
|
jobLog,
|
||||||
inputFileObj,
|
inputFileObj,
|
||||||
updateWorker,
|
updateWorker,
|
||||||
|
args,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { cliExitCode: pass2Exit } = await pass2Cli.runCli();
|
const { cliExitCode: pass2Exit } = await pass2Cli.runCli();
|
||||||
|
|||||||
Reference in new issue
Block a user