mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-10 07:50:29 -07:00
Beta plugins
This commit is contained in:
parent
50a795dc97
commit
e2cb06f0f2
117 changed files with 4414 additions and 168 deletions
|
|
@ -5,18 +5,72 @@ import {
|
|||
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
|
||||
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
const details = ():IpluginDetails => ({
|
||||
const details = (): IpluginDetails => ({
|
||||
name: 'Send Web Request',
|
||||
description: 'Send Web Request',
|
||||
style: {
|
||||
borderColor: 'green',
|
||||
opacity: 0.5,
|
||||
},
|
||||
tags: '',
|
||||
isStartPlugin: false,
|
||||
pType: '',
|
||||
requiresVersion: '2.11.01',
|
||||
sidebarPosition: -1,
|
||||
icon: 'faArrowRight',
|
||||
inputs: [],
|
||||
inputs: [
|
||||
{
|
||||
name: 'method',
|
||||
type: 'string',
|
||||
defaultValue: 'post',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'get',
|
||||
'post',
|
||||
'put',
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
tooltip: 'Specify request method',
|
||||
},
|
||||
{
|
||||
name: 'requestUrl',
|
||||
type: 'string',
|
||||
defaultValue: 'http://example.com',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify request URL',
|
||||
},
|
||||
{
|
||||
name: 'requestHeaders',
|
||||
type: 'string',
|
||||
defaultValue: `{
|
||||
"Content-Type": "application/json"
|
||||
}`,
|
||||
inputUI: {
|
||||
type: 'textarea',
|
||||
style: {
|
||||
height: '100px',
|
||||
},
|
||||
},
|
||||
tooltip: 'Specify request URL',
|
||||
},
|
||||
{
|
||||
name: 'requestBody',
|
||||
type: 'string',
|
||||
defaultValue: `{
|
||||
"test": "test"
|
||||
}`,
|
||||
inputUI: {
|
||||
type: 'textarea',
|
||||
style: {
|
||||
height: '100px',
|
||||
},
|
||||
},
|
||||
tooltip: 'Specify request body',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
|
|
@ -26,11 +80,32 @@ const details = ():IpluginDetails => ({
|
|||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const plugin = (args:IpluginInputArgs):IpluginOutputArgs => {
|
||||
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 method = String(args.inputs.method);
|
||||
const requestUrl = String(args.inputs.requestUrl);
|
||||
const requestHeaders = JSON.parse(String(args.inputs.requestHeaders));
|
||||
const requestBody = JSON.parse(String(args.inputs.requestBody));
|
||||
|
||||
const requestConfig = {
|
||||
method,
|
||||
url: requestUrl,
|
||||
headers: requestHeaders,
|
||||
data: requestBody,
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await args.deps.axios(requestConfig);
|
||||
args.jobLog(`Web request succeeded: Status Code: ${res.status}`);
|
||||
} catch (err) {
|
||||
args.jobLog('Web Request Failed');
|
||||
args.jobLog(JSON.stringify(err));
|
||||
throw new Error('Web Request Failed');
|
||||
}
|
||||
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue