Merge pull request #378 from Tailslide/ModifiedDatePlugin

Modified date filter plugin
make-only-subtitle-default
HaveAGitGat 2 years ago committed by GitHub
commit 3266446c46
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: 'text',
},
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 += "File modified date old enough. Moving to next plugin.";
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;

@ -0,0 +1,63 @@
/* eslint max-len: 0 */
const run = require('../helpers/run');
const tests = [
{
input: {
file: require('../sampleData/media/sampleH264_2.json'),
librarySettings: {},
inputs: {
minModifiedDaysOld: 1
},
otherArguments: {},
},
output: {
processFile: true,
infoLog: 'File modified date old enough. Moving to next plugin.',
},
},
{
input: {
file: require('../sampleData/media/sampleH264_1.json'),
librarySettings: {},
inputs: {
minModifiedDaysOld: 9999
},
otherArguments: {},
},
output: {
processFile: false,
infoLog: 'Skipping, file modified date not old enough',
},
},
{
input: {
file: require('../sampleData/media/sampleH264_1.json'),
librarySettings: {},
inputs: {
minModifiedDaysOld: 1
},
otherArguments: {},
},
output: {
processFile: true,
infoLog: 'File modified date old enough. Moving to next plugin.',
},
},
{
input: {
file: require('../sampleData/media/sampleH264_1.json'),
librarySettings: {},
inputs: {
minModifiedDaysOld: 9999
},
otherArguments: {},
},
output: {
processFile: false,
infoLog: 'Skipping, file modified date not old enough',
},
},
];
run(tests);
Loading…
Cancel
Save