Skip to content

Commit

Permalink
Merge pull request #627 from HaveAGitGat/set_var
Browse files Browse the repository at this point in the history
Set Flow Variable
  • Loading branch information
HaveAGitGat authored May 9, 2024
2 parents 1746d61 + d60d964 commit 0d54452
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.plugin = exports.details = void 0;
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
var details = function () { return ({
name: 'Set Flow Variable',
description: "Set a Flow Variable to whatever you like. This can be used with the 'Check Flow Variable'\n plugin for complex flows with loops in them where you're wanting to keep track \n of where you are in the flow. For example, when attempting to transcode with NVENC, then QSV, then CPU.",
style: {
borderColor: 'green',
},
tags: '',
isStartPlugin: false,
pType: '',
requiresVersion: '2.11.01',
sidebarPosition: 1,
icon: '',
inputs: [
{
label: 'Variable',
name: 'variable',
type: 'string',
defaultValue: '',
inputUI: {
type: 'text',
},
tooltip: "Variable to set.\n \n \\nExample\\n\n transcodeStage\n \n \\n\n You can then check this in the 'Check Flow Variable' plugin\n {{{args.variables.user.transcodeStage}}}\n ",
},
{
label: 'Value',
name: 'value',
type: 'string',
defaultValue: '',
inputUI: {
type: 'text',
},
tooltip: "Value to set.\n \n \\nExample\\n\n 1\n \n \\nExample\\n\n nvenc\n ",
},
],
outputs: [
{
number: 1,
tooltip: 'Continue to next plugin',
},
],
}); };
exports.details = details;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
var plugin = function (args) {
var lib = require('../../../../../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);
var variable = String(args.inputs.variable).trim();
var value = String(args.inputs.value);
if (!args.variables.user) {
// eslint-disable-next-line no-param-reassign
args.variables.user = {};
}
args.jobLog("Setting variable ".concat(variable, " to ").concat(value));
// eslint-disable-next-line no-param-reassign
args.variables.user[variable] = value;
return {
outputFileObj: args.inputFileObj,
outputNumber: 1,
variables: args.variables,
};
};
exports.plugin = plugin;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.plugin = exports.details = void 0;
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
var details = function () { return ({
name: 'Check Video Resolution',
description: 'Check is video is 480p,576p,720p,1080p,1440p,4KUHD,DCI4K,8KUHD,Other',
description: 'Check if video is 480p,576p,720p,1080p,1440p,4KUHD,DCI4K,8KUHD,Other',
style: {
borderColor: 'orange',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import {
IpluginDetails,
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';

/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({
name: 'Set Flow Variable',
description: `Set a Flow Variable to whatever you like. This can be used with the 'Check Flow Variable'
plugin for complex flows with loops in them where you're wanting to keep track
of where you are in the flow. For example, when attempting to transcode with NVENC, then QSV, then CPU.`,
style: {
borderColor: 'green',
},
tags: '',
isStartPlugin: false,
pType: '',
requiresVersion: '2.11.01',
sidebarPosition: 1,
icon: '',
inputs: [
{
label: 'Variable',
name: 'variable',
type: 'string',
defaultValue: '',
inputUI: {
type: 'text',
},
tooltip: `Variable to set.
\\nExample\\n
transcodeStage
\\n
You can then check this in the 'Check Flow Variable' plugin
{{{args.variables.user.transcodeStage}}}
`,
},
{
label: 'Value',
name: 'value',
type: 'string',
defaultValue: '',
inputUI: {
type: 'text',
},
tooltip: `Value to set.
\\nExample\\n
1
\\nExample\\n
nvenc
`,
},
],
outputs: [
{
number: 1,
tooltip: 'Continue to next plugin',
},
],
});

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
const lib = require('../../../../../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);

const variable = String(args.inputs.variable).trim();
const value = String(args.inputs.value);

if (!args.variables.user) {
// eslint-disable-next-line no-param-reassign
args.variables.user = {};
}

args.jobLog(`Setting variable ${variable} to ${value}`);

// eslint-disable-next-line no-param-reassign
args.variables.user[variable] = value;

return {
outputFileObj: args.inputFileObj,
outputNumber: 1,
variables: args.variables,
};
};
export {
details,
plugin,
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = ():IpluginDetails => ({
name: 'Check Video Resolution',
description: 'Check is video is 480p,576p,720p,1080p,1440p,4KUHD,DCI4K,8KUHD,Other',
description: 'Check if video is 480p,576p,720p,1080p,1440p,4KUHD,DCI4K,8KUHD,Other',
style: {
borderColor: 'orange',
},
Expand Down
2 changes: 1 addition & 1 deletion FlowPluginsTs/FlowHelpers/1.0.0/interfaces/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export interface IffmpegCommand {
export interface Ivariables {
ffmpegCommand: IffmpegCommand,
flowFailed: boolean,
inFlow: Record<string, string>,
user: Record<string, string>,
}

export interface IpluginOutputArgs {
Expand Down

0 comments on commit 0d54452

Please sign in to comment.