mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 15:38:19 -07:00
Add Apprise
This commit is contained in:
parent
5eb2a9895c
commit
72e28ce23a
2 changed files with 96 additions and 3 deletions
|
|
@ -0,0 +1,90 @@
|
|||
import { CLI } from '../../../../FlowHelpers/1.0.0/cliUtils';
|
||||
import {
|
||||
IpluginDetails,
|
||||
IpluginInputArgs,
|
||||
IpluginOutputArgs,
|
||||
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
|
||||
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
const details = ():IpluginDetails => ({
|
||||
name: 'Apprise',
|
||||
description: 'Use Apprise to send notifications.',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
pType: '',
|
||||
requiresVersion: '2.11.01',
|
||||
sidebarPosition: -1,
|
||||
icon: 'faBell',
|
||||
inputs: [
|
||||
{
|
||||
label: 'Command',
|
||||
name: 'command',
|
||||
type: 'string',
|
||||
defaultValue: '-vv -t "Success" -b "File {{{args.inputFileObj._id}}}" "discord://xxx/xxxx"',
|
||||
inputUI: {
|
||||
type: 'textarea',
|
||||
style: {
|
||||
height: '100px',
|
||||
},
|
||||
},
|
||||
tooltip: `Visit the following for more information on Apprise: https://github.com/caronc/apprise
|
||||
\\nExample\\n
|
||||
-vv -t "Success" -b "File {{{args.inputFileObj._id}}}" "discord://xxx/xxxx"
|
||||
|
||||
|
||||
\\nExample\\n
|
||||
-vv -t "Processing" -b "File {{{args.inputFileObj._id}}}" "discord://{{{args.userVariables.global.discord_webhook}}}"
|
||||
`,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'Continue to next plugin',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const plugin = async (args:IpluginInputArgs):Promise<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 { command } = args.inputs;
|
||||
|
||||
const cliArgs = [
|
||||
...args.deps.parseArgsStringToArgv(command, '', ''),
|
||||
];
|
||||
|
||||
const cli = new CLI({
|
||||
cli: 'apprise',
|
||||
spawnArgs: cliArgs,
|
||||
spawnOpts: {},
|
||||
jobLog: args.jobLog,
|
||||
outputFilePath: '',
|
||||
inputFileObj: args.inputFileObj,
|
||||
logFullCliOutput: args.logFullCliOutput,
|
||||
updateWorker: args.updateWorker,
|
||||
});
|
||||
|
||||
const res = await cli.runCli();
|
||||
|
||||
if (res.cliExitCode !== 0) {
|
||||
args.jobLog('Running Apprise failed');
|
||||
throw new Error('Running Apprise failed');
|
||||
}
|
||||
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
export {
|
||||
details,
|
||||
plugin,
|
||||
};
|
||||
|
|
@ -315,7 +315,8 @@ class CLI {
|
|||
thread.on('error', () => {
|
||||
// catches execution error (bad file)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(1, `Error executing binary: ${this.config.cli}`);
|
||||
console.log(`Error executing binary: ${this.config.cli}`);
|
||||
this.config.jobLog(`Error executing binary: ${this.config.cli}`);
|
||||
resolve(1);
|
||||
});
|
||||
|
||||
|
|
@ -324,14 +325,16 @@ class CLI {
|
|||
thread.on('close', (code: number) => {
|
||||
if (code !== 0) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(code, 'CLI error');
|
||||
console.log(`CLI error code: ${code}`);
|
||||
this.config.jobLog(`CLI error code: ${code}`);
|
||||
}
|
||||
resolve(code);
|
||||
});
|
||||
} catch (err) {
|
||||
// catches execution error (no file)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(1, `Error executing binary: ${this.config.cli}`);
|
||||
console.log(`Error executing binary: ${this.config.cli}: ${err}`);
|
||||
this.config.jobLog(`Error executing binary: ${this.config.cli}: ${err}`);
|
||||
resolve(1);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue