mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-10 07:50:29 -07:00
Update classic plugin wrapper with scan types
This commit is contained in:
parent
0921ed23bf
commit
0e3ffd5471
6 changed files with 211 additions and 44 deletions
|
|
@ -1,5 +1,8 @@
|
|||
import { promises as fs } from 'fs';
|
||||
import { CLI } from '../../../../FlowHelpers/1.0.0/cliUtils';
|
||||
import { getContainer, getFileName, getPluginWorkDir } from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
import {
|
||||
getContainer, getFileName, getPluginWorkDir, getScanTypes,
|
||||
} from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
import {
|
||||
IpluginDetails,
|
||||
IpluginInputArgs,
|
||||
|
|
@ -61,8 +64,10 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
const absolutePath = path.resolve(__dirname, relativePluginPath);
|
||||
|
||||
let classicPlugin;
|
||||
let pluginSrcStr = '';
|
||||
if (pluginSource === 'Community') {
|
||||
classicPlugin = args.deps.importFresh(relativePluginPath);
|
||||
pluginSrcStr = await fs.readFile(absolutePath, 'utf8');
|
||||
} else {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const res = await args.deps.axiosMiddleware('api/v2/read-plugin', {
|
||||
|
|
@ -73,6 +78,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
});
|
||||
|
||||
classicPlugin = args.deps.requireFromString(res.pluginRaw, absolutePath);
|
||||
pluginSrcStr = res.pluginRaw;
|
||||
}
|
||||
|
||||
if (classicPlugin.details().Operation === 'Filter') {
|
||||
|
|
@ -112,7 +118,24 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
job: args.job,
|
||||
};
|
||||
|
||||
const result = await classicPlugin.plugin(args.inputFileObj, args.librarySettings, args.inputs, otherArguments);
|
||||
const scanTypes = getScanTypes([pluginSrcStr]);
|
||||
|
||||
const pluginInputFileObj = await args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
||||
file: {
|
||||
_id: args.inputFileObj._id,
|
||||
file: args.inputFileObj.file,
|
||||
DB: args.inputFileObj.DB,
|
||||
footprintId: args.inputFileObj.footprintId,
|
||||
},
|
||||
scanTypes,
|
||||
});
|
||||
|
||||
const result = await classicPlugin.plugin(
|
||||
pluginInputFileObj,
|
||||
args.librarySettings,
|
||||
args.inputs,
|
||||
otherArguments,
|
||||
);
|
||||
|
||||
args.jobLog(JSON.stringify(result, null, 2));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue