From 27fee1ee95321ba40f53d6a6f4133261f8e45fe1 Mon Sep 17 00:00:00 2001 From: PickleRick Date: Sat, 19 Sep 2026 14:54:38 +0200 Subject: [PATCH] fix: pass full args object to CLI constructors in all plugins to prevent cliUtils TypeError on variables/liveSizeCompare --- .../audio/backupSourceAudio/1.0.0/index.js | 1 + .../extractSubtitlesAndOcr/1.0.0/index.js | 30 +++++++++++++------ .../utility/extractChaptersXml/1.0.0/index.js | 1 + .../video/transcode2PassX265/1.0.0/index.js | 2 ++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/LocalFlowPlugins/audio/backupSourceAudio/1.0.0/index.js b/LocalFlowPlugins/audio/backupSourceAudio/1.0.0/index.js index a13503d..47af082 100644 --- a/LocalFlowPlugins/audio/backupSourceAudio/1.0.0/index.js +++ b/LocalFlowPlugins/audio/backupSourceAudio/1.0.0/index.js @@ -78,6 +78,7 @@ const plugin = async (args) => { jobLog, inputFileObj, updateWorker, + args, }); const { cliExitCode } = await cli.runCli(); diff --git a/LocalFlowPlugins/subtitles/extractSubtitlesAndOcr/1.0.0/index.js b/LocalFlowPlugins/subtitles/extractSubtitlesAndOcr/1.0.0/index.js index 06054f8..dc705cd 100644 --- a/LocalFlowPlugins/subtitles/extractSubtitlesAndOcr/1.0.0/index.js +++ b/LocalFlowPlugins/subtitles/extractSubtitlesAndOcr/1.0.0/index.js @@ -16,8 +16,8 @@ const fs = require('fs'); * Naming: .[.forced][.default][.sdh].srt */ -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 TEXT_CODECS = new Set(['subrip', 'srt', 'ass', 'ssa', 'webvtt', 'mov_text']); +const BITMAP_CODECS = new Set(['hdmv_pgs_subtitle', 'dvd_subtitle', 'pgssub', 'dvbsub']); const details = () => ({ name: 'Extract Subtitles & OCR Fallback', @@ -79,10 +79,21 @@ const buildSuffix = (lang, stream) => { 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 = 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(); }; @@ -90,7 +101,7 @@ const runFFmpeg = async (spawnArgs, workDir, ffmpegPath, jobLog, inputFileObj, u // ─── Plugin ─────────────────────────────────────────────────────────────────── const plugin = async (args) => { - const { jobLog, inputFileObj, variables, workDir, updateWorker } = args; + const { jobLog, inputFileObj, variables, workDir } = args; const inputFile = inputFileObj._id; const sourceDir = path.dirname(inputFile); @@ -129,7 +140,7 @@ const plugin = async (args) => { if (TEXT_CODECS.has(codec)) { const { cliExitCode } = await runFFmpeg( ['-y', '-i', inputFile, '-map', `0:${stream.index}`, '-c:s', 'srt', outSrt], - workDir, args.ffmpegPath, jobLog, inputFileObj, updateWorker, + args, ); if (cliExitCode !== 0) { 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 const { cliExitCode: extractExit } = await runFFmpeg( ['-y', '-i', inputFile, '-map', `0:${stream.index}`, '-c:s', 'copy', tmpSup], - workDir, args.ffmpegPath, jobLog, inputFileObj, updateWorker, + args, ); if (extractExit !== 0) { @@ -164,10 +175,11 @@ const plugin = async (args) => { '/track-number:0', `/outputfolder:${sourceDir}`, ], - WorkDir: workDir, + WorkDir: workDir, jobLog, inputFileObj, - updateWorker, + updateWorker: args.updateWorker, + args, }); const { cliExitCode: seExit } = await seCli.runCli(); diff --git a/LocalFlowPlugins/utility/extractChaptersXml/1.0.0/index.js b/LocalFlowPlugins/utility/extractChaptersXml/1.0.0/index.js index 5732546..d896b56 100644 --- a/LocalFlowPlugins/utility/extractChaptersXml/1.0.0/index.js +++ b/LocalFlowPlugins/utility/extractChaptersXml/1.0.0/index.js @@ -51,6 +51,7 @@ const plugin = async (args) => { jobLog, inputFileObj, updateWorker, + args, }); const { cliExitCode } = await cli.runCli(); diff --git a/LocalFlowPlugins/video/transcode2PassX265/1.0.0/index.js b/LocalFlowPlugins/video/transcode2PassX265/1.0.0/index.js index fbe36ab..bb9fad4 100644 --- a/LocalFlowPlugins/video/transcode2PassX265/1.0.0/index.js +++ b/LocalFlowPlugins/video/transcode2PassX265/1.0.0/index.js @@ -179,6 +179,7 @@ const plugin = async (args) => { jobLog, inputFileObj, updateWorker, + args, }); const { cliExitCode: pass1Exit } = await pass1Cli.runCli(); @@ -211,6 +212,7 @@ const plugin = async (args) => { jobLog, inputFileObj, updateWorker, + args, }); const { cliExitCode: pass2Exit } = await pass2Cli.runCli();