Create Tdarr_Plugin_0house_filter_by_size.js

This commit is contained in:
HaveAGitGat 2021-12-31 19:51:49 +00:00
parent 68eb996322
commit d7f58b2530

View file

@ -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;