mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 15:38:19 -07:00
Merge pull request #645 from HaveAGitGat/node_scan
Use Node scan function if available
This commit is contained in:
commit
e142db1892
3 changed files with 73 additions and 39 deletions
|
|
@ -40,7 +40,7 @@ exports.runClassicPlugin = void 0;
|
|||
var fs_1 = require("fs");
|
||||
var fileUtils_1 = require("./fileUtils");
|
||||
var runClassicPlugin = function (args, type) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var path, pluginSourceId, parts, pluginSource, pluginId, relativePluginPath, absolutePath, classicPlugin, pluginSrcStr, res, container, cacheFilePath, scanTypes, pluginInputFileObj, originalLibraryFile, otherArguments, result;
|
||||
var path, pluginSourceId, parts, pluginSource, pluginId, relativePluginPath, absolutePath, classicPlugin, pluginSrcStr, res, container, cacheFilePath, scanTypes, pluginInputFileObj, originalLibraryFile, inputFileScanArgs, originalLibraryFileScanArgs, otherArguments, result;
|
||||
var _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
|
|
@ -99,28 +99,43 @@ var runClassicPlugin = function (args, type) { return __awaiter(void 0, void 0,
|
|||
container = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
|
||||
cacheFilePath = "".concat((0, fileUtils_1.getPluginWorkDir)(args), "/").concat((0, fileUtils_1.getFileName)(args.inputFileObj._id), ".").concat(container);
|
||||
scanTypes = (0, fileUtils_1.getScanTypes)([pluginSrcStr]);
|
||||
return [4 /*yield*/, 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: scanTypes,
|
||||
})];
|
||||
inputFileScanArgs = {
|
||||
_id: args.inputFileObj._id,
|
||||
file: args.inputFileObj.file,
|
||||
DB: args.inputFileObj.DB,
|
||||
footprintId: args.inputFileObj.footprintId,
|
||||
};
|
||||
originalLibraryFileScanArgs = {
|
||||
_id: args.originalLibraryFile._id,
|
||||
file: args.originalLibraryFile.file,
|
||||
DB: args.originalLibraryFile.DB,
|
||||
footprintId: args.originalLibraryFile.footprintId,
|
||||
};
|
||||
if (!(typeof args.scanIndividualFile !== 'undefined')) return [3 /*break*/, 12];
|
||||
args.jobLog('Scanning files using Node');
|
||||
return [4 /*yield*/, args.scanIndividualFile(inputFileScanArgs, scanTypes)];
|
||||
case 10:
|
||||
pluginInputFileObj = _b.sent();
|
||||
return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
||||
file: {
|
||||
_id: args.originalLibraryFile._id,
|
||||
file: args.originalLibraryFile.file,
|
||||
DB: args.originalLibraryFile.DB,
|
||||
footprintId: args.originalLibraryFile.footprintId,
|
||||
},
|
||||
scanTypes: scanTypes,
|
||||
})];
|
||||
return [4 /*yield*/, args.scanIndividualFile(originalLibraryFileScanArgs, scanTypes)];
|
||||
case 11:
|
||||
originalLibraryFile = _b.sent();
|
||||
return [3 /*break*/, 15];
|
||||
case 12:
|
||||
args.jobLog('Scanning files using Server API');
|
||||
return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
||||
file: inputFileScanArgs,
|
||||
scanTypes: scanTypes,
|
||||
})];
|
||||
case 13:
|
||||
pluginInputFileObj = _b.sent();
|
||||
return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
||||
file: originalLibraryFileScanArgs,
|
||||
scanTypes: scanTypes,
|
||||
})];
|
||||
case 14:
|
||||
originalLibraryFile = _b.sent();
|
||||
_b.label = 15;
|
||||
case 15:
|
||||
otherArguments = {
|
||||
handbrakePath: args.handbrakePath,
|
||||
ffmpegPath: args.ffmpegPath,
|
||||
|
|
@ -135,7 +150,7 @@ var runClassicPlugin = function (args, type) { return __awaiter(void 0, void 0,
|
|||
job: args.job,
|
||||
};
|
||||
return [4 /*yield*/, classicPlugin.plugin(pluginInputFileObj, args.librarySettings, args.inputs, otherArguments)];
|
||||
case 12:
|
||||
case 16:
|
||||
result = _b.sent();
|
||||
if (((_a = result === null || result === void 0 ? void 0 : result.file) === null || _a === void 0 ? void 0 : _a._id) && args.inputFileObj._id !== result.file._id) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {
|
|||
getContainer, getFileName, getPluginWorkDir, getScanTypes,
|
||||
} from './fileUtils';
|
||||
import { IpluginInputArgs } from './interfaces/interfaces';
|
||||
import { IFileObject } from './interfaces/synced/IFileObject';
|
||||
|
||||
export interface IrunClassicPlugin {
|
||||
result:{
|
||||
|
|
@ -90,25 +91,41 @@ export const runClassicPlugin = async (args:IpluginInputArgs, type:'filter'|'tra
|
|||
|
||||
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,
|
||||
});
|
||||
let pluginInputFileObj:IFileObject;
|
||||
let originalLibraryFile:IFileObject;
|
||||
|
||||
const originalLibraryFile = await args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
||||
file: {
|
||||
_id: args.originalLibraryFile._id,
|
||||
file: args.originalLibraryFile.file,
|
||||
DB: args.originalLibraryFile.DB,
|
||||
footprintId: args.originalLibraryFile.footprintId,
|
||||
},
|
||||
scanTypes,
|
||||
});
|
||||
const inputFileScanArgs = {
|
||||
_id: args.inputFileObj._id,
|
||||
file: args.inputFileObj.file,
|
||||
DB: args.inputFileObj.DB,
|
||||
footprintId: args.inputFileObj.footprintId,
|
||||
};
|
||||
|
||||
const originalLibraryFileScanArgs = {
|
||||
_id: args.originalLibraryFile._id,
|
||||
file: args.originalLibraryFile.file,
|
||||
DB: args.originalLibraryFile.DB,
|
||||
footprintId: args.originalLibraryFile.footprintId,
|
||||
};
|
||||
|
||||
// added in 2.19.01
|
||||
if (typeof args.scanIndividualFile !== 'undefined') {
|
||||
args.jobLog('Scanning files using Node');
|
||||
pluginInputFileObj = await args.scanIndividualFile(inputFileScanArgs, scanTypes);
|
||||
originalLibraryFile = await args.scanIndividualFile(originalLibraryFileScanArgs, scanTypes);
|
||||
} else {
|
||||
args.jobLog('Scanning files using Server API');
|
||||
|
||||
pluginInputFileObj = await args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
||||
file: inputFileScanArgs,
|
||||
scanTypes,
|
||||
});
|
||||
|
||||
originalLibraryFile = await args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
||||
file: originalLibraryFileScanArgs,
|
||||
scanTypes,
|
||||
});
|
||||
}
|
||||
|
||||
const otherArguments = {
|
||||
handbrakePath: args.handbrakePath,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { IFileObject, Istreams } from './synced/IFileObject';
|
||||
import { IscanTypes } from '../fileUtils';
|
||||
import { IFileObject, IFileObjectMin, Istreams } from './synced/IFileObject';
|
||||
import Ijob from './synced/jobInterface';
|
||||
|
||||
export interface IpluginInputUi {
|
||||
|
|
@ -136,6 +137,7 @@ export interface IpluginInputArgs {
|
|||
updateWorker: IupdateWorker,
|
||||
logFullCliOutput: boolean,
|
||||
logOutcome: (outcome: string) => void,
|
||||
scanIndividualFile?: (filee: IFileObjectMin, scanTypes: IscanTypes) => IFileObject,
|
||||
deps: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
fsextra: any,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue