|
|
|
@ -22,23 +22,39 @@ const details = (): IpluginDetails => ({
|
|
|
|
label: 'Variable',
|
|
|
|
label: 'Variable',
|
|
|
|
name: 'variable',
|
|
|
|
name: 'variable',
|
|
|
|
type: 'string',
|
|
|
|
type: 'string',
|
|
|
|
defaultValue: '',
|
|
|
|
defaultValue: '{{{args.librarySettings._id}}}',
|
|
|
|
inputUI: {
|
|
|
|
inputUI: {
|
|
|
|
type: 'text',
|
|
|
|
type: 'text',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tooltip: `Variable to check. For example ,
|
|
|
|
tooltip: `Variable to check using templating.
|
|
|
|
|
|
|
|
\\n
|
|
|
|
|
|
|
|
\\n
|
|
|
|
|
|
|
|
https://docs.tdarr.io/docs/plugins/flow-plugins/basics#plugin-variable-templating
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\\n
|
|
|
|
|
|
|
|
\\n
|
|
|
|
|
|
|
|
For example ,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\\nExample\\n
|
|
|
|
|
|
|
|
{{{args.librarySettings._id}}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\\nExample\\n
|
|
|
|
|
|
|
|
{{{args.inputFileObj._id}}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\\nExample\\n
|
|
|
|
|
|
|
|
{{{args.userVariables.library.test}}}
|
|
|
|
|
|
|
|
|
|
|
|
\\nExample\\n
|
|
|
|
\\nExample\\n
|
|
|
|
args.librarySettings._id
|
|
|
|
{{{args.userVariables.global.test}}}
|
|
|
|
|
|
|
|
|
|
|
|
\\nExample\\n
|
|
|
|
\\nExample\\n
|
|
|
|
args.inputFileObj._id
|
|
|
|
{{{args.inputFileObj.mediaInfo.track.0.IsStreamable}}}
|
|
|
|
|
|
|
|
|
|
|
|
\\nExample\\n
|
|
|
|
\\nExample\\n
|
|
|
|
args.userVariables.library.test
|
|
|
|
{{{args.inputFileObj.ffProbeData.format.nb_streams}}}
|
|
|
|
|
|
|
|
|
|
|
|
\\nExample\\n
|
|
|
|
\\nExample\\n
|
|
|
|
args.userVariables.global.test
|
|
|
|
{{{args.inputFileObj.ffProbeData.streams.1.codec_name}}}
|
|
|
|
`,
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -87,40 +103,50 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
|
|
|
|
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
|
|
|
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
|
|
|
|
|
|
|
|
|
|
|
const variable = String(args.inputs.variable).trim();
|
|
|
|
const variable = String(args.inputs.variable).trim();
|
|
|
|
|
|
|
|
let targetValue;
|
|
|
|
const condition = String(args.inputs.condition);
|
|
|
|
const condition = String(args.inputs.condition);
|
|
|
|
const value = String(args.inputs.value);
|
|
|
|
const value = String(args.inputs.value);
|
|
|
|
|
|
|
|
|
|
|
|
// variable could be e.g. args.librarySettings._id or args.inputFileObj._id
|
|
|
|
// comment to force mediaInfo scan
|
|
|
|
// condition could be e.g. '==' or '!='
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const variableParts = variable.split('.');
|
|
|
|
args.jobLog(`variable = ${JSON.stringify(variable)}`);
|
|
|
|
|
|
|
|
|
|
|
|
let targetValue;
|
|
|
|
if (variable.startsWith('args.')) {
|
|
|
|
switch (variableParts.length) {
|
|
|
|
// variable could be e.g. args.librarySettings._id or args.inputFileObj._id
|
|
|
|
case 1:
|
|
|
|
// condition could be e.g. '==' or '!='
|
|
|
|
targetValue = args;
|
|
|
|
|
|
|
|
break;
|
|
|
|
const variableParts = variable.split('.');
|
|
|
|
case 2:
|
|
|
|
switch (variableParts.length) {
|
|
|
|
// @ts-expect-error index
|
|
|
|
case 1:
|
|
|
|
targetValue = args[variableParts[1]];
|
|
|
|
targetValue = args;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 2:
|
|
|
|
// @ts-expect-error index
|
|
|
|
// @ts-expect-error index
|
|
|
|
targetValue = args[variableParts[1]][variableParts[2]];
|
|
|
|
targetValue = args[variableParts[1]];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 3:
|
|
|
|
// @ts-expect-error index
|
|
|
|
// @ts-expect-error index
|
|
|
|
targetValue = args[variableParts[1]][variableParts[2]][variableParts[3]];
|
|
|
|
targetValue = args[variableParts[1]][variableParts[2]];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
case 4:
|
|
|
|
// @ts-expect-error index
|
|
|
|
// @ts-expect-error index
|
|
|
|
targetValue = args[variableParts[1]][variableParts[2]][variableParts[3]][variableParts[4]];
|
|
|
|
targetValue = args[variableParts[1]][variableParts[2]][variableParts[3]];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case 5:
|
|
|
|
throw new Error(`Invalid variable: ${variable}`);
|
|
|
|
// @ts-expect-error index
|
|
|
|
|
|
|
|
targetValue = args[variableParts[1]][variableParts[2]][variableParts[3]][variableParts[4]];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
throw new Error(`Invalid variable: ${variable}`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
targetValue = variable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
targetValue = String(targetValue);
|
|
|
|
targetValue = String(targetValue);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args.jobLog(`targetValue = ${targetValue}`);
|
|
|
|
|
|
|
|
|
|
|
|
let outputNumber = 1;
|
|
|
|
let outputNumber = 1;
|
|
|
|
|
|
|
|
|
|
|
|
const valuesArr = value.trim().split(',');
|
|
|
|
const valuesArr = value.trim().split(',');
|
|
|
|
|