From 79d595af3eadd000271df14e69560d0db7ce970d Mon Sep 17 00:00:00 2001 From: r0guepacket <117168297+r0guepacket@users.noreply.github.com> Date: Sat, 21 Sep 2024 12:14:50 +0100 Subject: [PATCH 1/4] Create index.ts --- .../file/checkFileDuration/1.0.0/index.ts | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts diff --git a/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts new file mode 100644 index 000000000..fede08b39 --- /dev/null +++ b/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts @@ -0,0 +1,97 @@ +import { + IpluginDetails, + IpluginInputArgs, + IpluginOutputArgs, + } from '../../../../FlowHelpers/1.0.0/interfaces/interfaces'; + import { IFileObject } from '../../../../FlowHelpers/1.0.0/interfaces/synced/IFileObject'; + +/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ +const details = (): IpluginDetails => ({ + name: 'Check File Duration', + description: 'Check duration of file in seconds. Do something differently if above threshold.', + style: { + borderColor: 'orange', + }, + tags: '', + isStartPlugin: false, + pType: '', + requiresVersion: '2.11.01', + sidebarPosition: -1, + icon: 'faQuestion', + inputs: [ + { + label: 'Threshold (in seconds)', + name: 'thresholdSecs', + type: 'number', + defaultValue: '3900', + inputUI: { + type: 'text', + }, + tooltip: 'Specify Threshold.' + + ' Default value is 3,900 seconds (65 minutes); durations longer than this will be assumed as feature length / Films and processed via Output 2, otherwise Output 1 is selected.', + }, + ], + outputs: [ + { + number: 1, + tooltip: 'Working file duration is below threshold', + }, + { + number: 2, + tooltip: 'Working file duration is above threshold', + }, + ], +}); + +// 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 getData = (obj:IFileObject) => { + try { + if (obj?.ffProbeData?.format?.duration) { + const dur = Number(obj.ffProbeData.format.duration); + + if (dur > 0) { + return dur; + } + } + } catch (err) { + // err + } + return 0; + }; + + const origFileDuration: number = getData(args.originalLibraryFile); + + args.jobLog(`origFileDuration: ${origFileDuration}`); + + const thresholdSecs: number = Number(args.inputs.thresholdSecs); + const durationText: string = `File has duration is ${origFileDuration.toFixed(3)} seconds`; + const seriesText: string = 'File duration within series limits. must be a series.'; + const filmText: string = 'File duration longer than series limits. must be a film.'; + + let outputNumber: number = 1; + + if (origFileDuration < thresholdSecs) { + args.jobLog(`${seriesText} ${durationText}, threshold is ${thresholdSecs} seconds`); + outputNumber = 1; + } else if (origFileDuration >= thresholdSecs) { + args.jobLog(`${filmText} ${durationText}, threshold is ${thresholdSecs} seconds`); + outputNumber = 2; + } else { + args.jobLog(durationText); + } + + return { + outputFileObj: args.inputFileObj, + outputNumber, + variables: args.variables, + }; +}; +export { + details, + plugin, +}; \ No newline at end of file From 4a9d35b957983cfc0f6bb949e4b678952aeb13e4 Mon Sep 17 00:00:00 2001 From: r0guepacket <117168297+r0guepacket@users.noreply.github.com> Date: Sat, 21 Sep 2024 12:26:41 +0100 Subject: [PATCH 2/4] Update index.ts --- .../file/checkFileDuration/1.0.0/index.ts | 158 +++++++++--------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts index fede08b39..a4f32bc57 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts @@ -1,97 +1,97 @@ import { - IpluginDetails, - IpluginInputArgs, - IpluginOutputArgs, - } from '../../../../FlowHelpers/1.0.0/interfaces/interfaces'; - import { IFileObject } from '../../../../FlowHelpers/1.0.0/interfaces/synced/IFileObject'; + IpluginDetails, + IpluginInputArgs, + IpluginOutputArgs, +} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces'; +import { IFileObject } from '../../../../FlowHelpers/1.0.0/interfaces/synced/IFileObject'; /* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ const details = (): IpluginDetails => ({ - name: 'Check File Duration', - description: 'Check duration of file in seconds. Do something differently if above threshold.', - style: { - borderColor: 'orange', + name: 'Check File Duration', + description: 'Check duration of file in seconds. Do something differently if above threshold.', + style: { + borderColor: 'orange', + }, + tags: '', + isStartPlugin: false, + pType: '', + requiresVersion: '2.11.01', + sidebarPosition: -1, + icon: 'faQuestion', + inputs: [ + { + label: 'Threshold (in seconds)', + name: 'thresholdSecs', + type: 'number', + defaultValue: '3900', + inputUI: { + type: 'text', + }, + tooltip: 'Specify Threshold.' + + ' Default value is 3,900 seconds (65 minutes).', }, - tags: '', - isStartPlugin: false, - pType: '', - requiresVersion: '2.11.01', - sidebarPosition: -1, - icon: 'faQuestion', - inputs: [ - { - label: 'Threshold (in seconds)', - name: 'thresholdSecs', - type: 'number', - defaultValue: '3900', - inputUI: { - type: 'text', - }, - tooltip: 'Specify Threshold.' + - ' Default value is 3,900 seconds (65 minutes); durations longer than this will be assumed as feature length / Films and processed via Output 2, otherwise Output 1 is selected.', - }, - ], - outputs: [ - { - number: 1, - tooltip: 'Working file duration is below threshold', - }, - { - number: 2, - tooltip: 'Working file duration is above threshold', - }, - ], + ], + outputs: [ + { + number: 1, + tooltip: 'Working file duration is below threshold', + }, + { + number: 2, + tooltip: 'Working file duration is above threshold', + }, + ], }); // 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 getData = (obj:IFileObject) => { - try { - if (obj?.ffProbeData?.format?.duration) { - const dur = Number(obj.ffProbeData.format.duration); - - if (dur > 0) { - return dur; - } + 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 getData = (obj:IFileObject) => { + try { + if (obj?.ffProbeData?.format?.duration) { + const dur = Number(obj.ffProbeData.format.duration); + + if (dur > 0) { + return dur; } - } catch (err) { - // err } - return 0; - }; + } catch (err) { + // err + } + return 0; + }; - const origFileDuration: number = getData(args.originalLibraryFile); - - args.jobLog(`origFileDuration: ${origFileDuration}`); + const origFileDuration: number = getData(args.originalLibraryFile); - const thresholdSecs: number = Number(args.inputs.thresholdSecs); - const durationText: string = `File has duration is ${origFileDuration.toFixed(3)} seconds`; - const seriesText: string = 'File duration within series limits. must be a series.'; - const filmText: string = 'File duration longer than series limits. must be a film.'; + args.jobLog(`origFileDuration: ${origFileDuration}`); - let outputNumber: number = 1; + const thresholdSecs = Number(args.inputs.thresholdSecs); + const durationText = `File has duration is ${origFileDuration.toFixed(3)} seconds`; + const seriesText = 'File duration within series limits. must be a series.'; + const filmText = 'File duration longer than series limits. must be a film.'; - if (origFileDuration < thresholdSecs) { - args.jobLog(`${seriesText} ${durationText}, threshold is ${thresholdSecs} seconds`); - outputNumber = 1; - } else if (origFileDuration >= thresholdSecs) { - args.jobLog(`${filmText} ${durationText}, threshold is ${thresholdSecs} seconds`); - outputNumber = 2; - } else { - args.jobLog(durationText); - } + let outputNumber = 1; - return { - outputFileObj: args.inputFileObj, - outputNumber, - variables: args.variables, - }; + if (origFileDuration < thresholdSecs) { + args.jobLog(`${seriesText} ${durationText}, threshold is ${thresholdSecs} seconds`); + outputNumber = 1; + } else if (origFileDuration >= thresholdSecs) { + args.jobLog(`${filmText} ${durationText}, threshold is ${thresholdSecs} seconds`); + outputNumber = 2; + } else { + args.jobLog(durationText); + } + + return { + outputFileObj: args.inputFileObj, + outputNumber, + variables: args.variables, + }; }; export { - details, - plugin, -}; \ No newline at end of file + details, + plugin, +}; From 2055f0f019aa07dbac5535e758ec1464fb81c2bc Mon Sep 17 00:00:00 2001 From: r0guepacket <117168297+r0guepacket@users.noreply.github.com> Date: Sat, 21 Sep 2024 12:35:35 +0100 Subject: [PATCH 3/4] Create index.js --- .../file/checkFileDuration/1.0.0/index.js | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 FlowPlugins/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.js diff --git a/FlowPlugins/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.js new file mode 100644 index 000000000..ca49452c4 --- /dev/null +++ b/FlowPlugins/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.js @@ -0,0 +1,86 @@ +"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: 'Check File Duration', + description: 'Check duration of file in seconds. Do something differently if above threshold.', + style: { + borderColor: 'orange', + }, + tags: '', + isStartPlugin: false, + pType: '', + requiresVersion: '2.11.01', + sidebarPosition: -1, + icon: 'faQuestion', + inputs: [ + { + label: 'Threshold (in seconds)', + name: 'thresholdSecs', + type: 'number', + defaultValue: '3900', + inputUI: { + type: 'text', + }, + tooltip: 'Specify Threshold.' + + ' Default value is 3,900 seconds (65 minutes).', + }, + ], + outputs: [ + { + number: 1, + tooltip: 'Working file duration is below threshold', + }, + { + number: 2, + tooltip: 'Working file duration is above threshold', + }, + ], +}); }; +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 getData = function (obj) { + var _a, _b; + try { + if ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.ffProbeData) === null || _a === void 0 ? void 0 : _a.format) === null || _b === void 0 ? void 0 : _b.duration) { + var dur = Number(obj.ffProbeData.format.duration); + if (dur > 0) { + return dur; + } + } + } + catch (err) { + // err + } + return 0; + }; + var origFileDuration = getData(args.originalLibraryFile); + args.jobLog("origFileDuration: ".concat(origFileDuration)); + var thresholdSecs = Number(args.inputs.thresholdSecs); + var durationText = "File has duration is ".concat(origFileDuration.toFixed(3), " seconds"); + var seriesText = 'File duration within series limits. must be a series.'; + var filmText = 'File duration longer than series limits. must be a film.'; + var outputNumber = 1; + if (origFileDuration < thresholdSecs) { + args.jobLog("".concat(seriesText, " ").concat(durationText, ", threshold is ").concat(thresholdSecs, " seconds")); + outputNumber = 1; + } + else if (origFileDuration >= thresholdSecs) { + args.jobLog("".concat(filmText, " ").concat(durationText, ", threshold is ").concat(thresholdSecs, " seconds")); + outputNumber = 2; + } + else { + args.jobLog(durationText); + } + return { + outputFileObj: args.inputFileObj, + outputNumber: outputNumber, + variables: args.variables, + }; +}; +exports.plugin = plugin; From f61f8e1302bc68f20fe43099079b39abb88738a7 Mon Sep 17 00:00:00 2001 From: r0guepacket <117168297+r0guepacket@users.noreply.github.com> Date: Sat, 21 Sep 2024 13:18:13 +0100 Subject: [PATCH 4/4] Log texts have been generalised Updated the log output to a more generalised text --- .../file/checkFileDuration/1.0.0/index.js | 8 ++++---- .../file/checkFileDuration/1.0.0/index.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.js index ca49452c4..161177524 100644 --- a/FlowPlugins/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.js @@ -63,15 +63,15 @@ var plugin = function (args) { args.jobLog("origFileDuration: ".concat(origFileDuration)); var thresholdSecs = Number(args.inputs.thresholdSecs); var durationText = "File has duration is ".concat(origFileDuration.toFixed(3), " seconds"); - var seriesText = 'File duration within series limits. must be a series.'; - var filmText = 'File duration longer than series limits. must be a film.'; + var belowText = 'File duration is below threshold.'; + var aboveText = 'File duration is above threshold.'; var outputNumber = 1; if (origFileDuration < thresholdSecs) { - args.jobLog("".concat(seriesText, " ").concat(durationText, ", threshold is ").concat(thresholdSecs, " seconds")); + args.jobLog("".concat(belowText, " ").concat(durationText, ", threshold is ").concat(thresholdSecs, " seconds")); outputNumber = 1; } else if (origFileDuration >= thresholdSecs) { - args.jobLog("".concat(filmText, " ").concat(durationText, ", threshold is ").concat(thresholdSecs, " seconds")); + args.jobLog("".concat(aboveText, " ").concat(durationText, ", threshold is ").concat(thresholdSecs, " seconds")); outputNumber = 2; } else { diff --git a/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts index a4f32bc57..54b15a593 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/file/checkFileDuration/1.0.0/index.ts @@ -70,16 +70,16 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => { const thresholdSecs = Number(args.inputs.thresholdSecs); const durationText = `File has duration is ${origFileDuration.toFixed(3)} seconds`; - const seriesText = 'File duration within series limits. must be a series.'; - const filmText = 'File duration longer than series limits. must be a film.'; + const belowText = 'File duration is below threshold.'; + const aboveText = 'File duration is above threshold.'; let outputNumber = 1; if (origFileDuration < thresholdSecs) { - args.jobLog(`${seriesText} ${durationText}, threshold is ${thresholdSecs} seconds`); + args.jobLog(`${belowText} ${durationText}, threshold is ${thresholdSecs} seconds`); outputNumber = 1; } else if (origFileDuration >= thresholdSecs) { - args.jobLog(`${filmText} ${durationText}, threshold is ${thresholdSecs} seconds`); + args.jobLog(`${aboveText} ${durationText}, threshold is ${thresholdSecs} seconds`); outputNumber = 2; } else { args.jobLog(durationText);