diff --git a/Community/Tdarr_Plugin_0house_filter_by_size.js b/Community/Tdarr_Plugin_0house_filter_by_size.js new file mode 100644 index 0000000..0733808 --- /dev/null +++ b/Community/Tdarr_Plugin_0house_filter_by_size.js @@ -0,0 +1,57 @@ +const details = () => ({ + id: 'Tdarr_Plugin_0house_filter_by_size', + Stage: 'Pre-processing', + Name: 'Filter by size', + Type: 'Video', + Operation: 'Filter', + Description: 'Only allow files to be transcoded which are within the lower and upper bounds (MB) \n\n', + Version: '1.00', + Tags: 'filter', + Inputs: [ + { + name: 'upperBound', + type: 'number', + defaultValue: 100000, + inputUI: { + type: 'text', + }, + tooltip: + 'Enter the upper bound size in MB for files which should be processed.', + }, + { + name: 'lowerBound', + type: 'number', + defaultValue: 0, + inputUI: { + type: 'text', + }, + tooltip: + 'Enter the lower bound size in MB for files which should be processed.', + }, + ], +}); + +// eslint-disable-next-line no-unused-vars +const plugin = (file, librarySettings, inputs, otherArguments) => { + // eslint-disable-next-line global-require + const lib = require('../methods/lib')(); + // eslint-disable-next-line no-unused-vars,no-param-reassign + inputs = lib.loadDefaultValues(inputs, details); + const response = { + processFile: false, + infoLog: '', + }; + + const fileSize = file.file_size; + if (fileSize >= inputs.lowerBound && fileSize <= inputs.upperBound) { + response.processFile = true; + response.infoLog += 'File is within lower and upper bound size limits. Moving to next plugin.'; + } else { + response.infoLog += 'File is not within lower and upper bound size limits. Breaking out of plugin stack.'; + } + + return response; +}; + +module.exports.details = details; +module.exports.plugin = plugin;