Plugin to filter by modified date age

make-only-subtitle-default
Tailslide 3 years ago committed by GitHub
parent df9195c0d7
commit 1b16da3009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,61 @@
const details = () => ({
id: 'Tdarr_Plugin_tsld_filter_modified_date',
Stage: 'Pre-processing',
Name: 'Filter modified date',
Type: 'Video',
Operation: 'Filter',
Description: 'This plugin prevents processing files older than 30 days \n\n',
Version: '1.00',
Tags: '',
Inputs: [
// (Optional) Inputs you'd like the user to enter to allow your plugin to be easily configurable from the UI
{
name: 'minModifiedDaysOld',
type: 'number',
defaultValue: '30',
inputUI: {
type: 'number',
},
tooltip: `Enter minimum number of days since modified since now file must be.
\\nExample:\\n
365
\\nExample:\\n
30`
},
]
});
// eslint-disable-next-line no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => {
const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details);
const response = {
processFile: true,
infoLog: '',
};
//response.infoLog += `Filter preventing processing. File mod time ${file.statSync.mtimeMs}`;
//response.infoLog += ` Now ${Date.now()}`;
const age = Date.now() - file.statSync.mtimeMs;
const reqage = Number(inputs.minModifiedDaysOld) * 86400000;
// response.infoLog += ` Age ${age} Require Min Age: ${reqage}`;
if (reqage < age)
{
// response.infoLog += " Old enough, lets do this!";
response.processFile = true;
}
else
{
response.infoLog += " Skipping, file modified date not old enough";
response.processFile = false;
}
return response;
};
module.exports.details = details;
module.exports.plugin = plugin;
Loading…
Cancel
Save