mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-10 07:50:29 -07:00
Update file operation plugins
This commit is contained in:
parent
579aab99e9
commit
80f02bf810
22 changed files with 692 additions and 47 deletions
|
|
@ -0,0 +1,70 @@
|
|||
import { getContainer, getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
import {
|
||||
IpluginDetails,
|
||||
IpluginInputArgs,
|
||||
IpluginOutputArgs,
|
||||
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
|
||||
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
const details = (): IpluginDetails => ({
|
||||
name: 'Check File Name Includes',
|
||||
description: 'Check if a file name includes specific terms. Only needs to match one term',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
sidebarPosition: -1,
|
||||
icon: 'faQuestion',
|
||||
inputs: [
|
||||
{
|
||||
name: 'terms',
|
||||
type: 'string',
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
defaultValue: '_720p,_1080p',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
tooltip: 'Specify terms to check for in file name using comma seperated list e.g. _720p,_1080p',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'File name contains terms',
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
tooltip: 'File name does not contains terms',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// 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 fileName = `${getFileName(args.inputFileObj._id)}.${getContainer(args.inputFileObj._id)}`;
|
||||
const terms = String(args.inputs.terms).trim().split(',');
|
||||
let containsTerms = false;
|
||||
|
||||
for (let i = 0; i < terms.length; i++) {
|
||||
if (fileName.includes(terms[i])) {
|
||||
containsTerms = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: containsTerms ? 1 : 2,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
export {
|
||||
details,
|
||||
plugin,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue