mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-14 09:45:55 -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 fs_1 = require("fs");
|
||||||
var fileUtils_1 = require("./fileUtils");
|
var fileUtils_1 = require("./fileUtils");
|
||||||
var runClassicPlugin = function (args, type) { return __awaiter(void 0, void 0, void 0, function () {
|
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;
|
var _a;
|
||||||
return __generator(this, function (_b) {
|
return __generator(this, function (_b) {
|
||||||
switch (_b.label) {
|
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);
|
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);
|
cacheFilePath = "".concat((0, fileUtils_1.getPluginWorkDir)(args), "/").concat((0, fileUtils_1.getFileName)(args.inputFileObj._id), ".").concat(container);
|
||||||
scanTypes = (0, fileUtils_1.getScanTypes)([pluginSrcStr]);
|
scanTypes = (0, fileUtils_1.getScanTypes)([pluginSrcStr]);
|
||||||
return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
inputFileScanArgs = {
|
||||||
file: {
|
_id: args.inputFileObj._id,
|
||||||
_id: args.inputFileObj._id,
|
file: args.inputFileObj.file,
|
||||||
file: args.inputFileObj.file,
|
DB: args.inputFileObj.DB,
|
||||||
DB: args.inputFileObj.DB,
|
footprintId: args.inputFileObj.footprintId,
|
||||||
footprintId: args.inputFileObj.footprintId,
|
};
|
||||||
},
|
originalLibraryFileScanArgs = {
|
||||||
scanTypes: scanTypes,
|
_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:
|
case 10:
|
||||||
pluginInputFileObj = _b.sent();
|
pluginInputFileObj = _b.sent();
|
||||||
return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
return [4 /*yield*/, args.scanIndividualFile(originalLibraryFileScanArgs, scanTypes)];
|
||||||
file: {
|
|
||||||
_id: args.originalLibraryFile._id,
|
|
||||||
file: args.originalLibraryFile.file,
|
|
||||||
DB: args.originalLibraryFile.DB,
|
|
||||||
footprintId: args.originalLibraryFile.footprintId,
|
|
||||||
},
|
|
||||||
scanTypes: scanTypes,
|
|
||||||
})];
|
|
||||||
case 11:
|
case 11:
|
||||||
originalLibraryFile = _b.sent();
|
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 = {
|
otherArguments = {
|
||||||
handbrakePath: args.handbrakePath,
|
handbrakePath: args.handbrakePath,
|
||||||
ffmpegPath: args.ffmpegPath,
|
ffmpegPath: args.ffmpegPath,
|
||||||
|
|
@ -135,7 +150,7 @@ var runClassicPlugin = function (args, type) { return __awaiter(void 0, void 0,
|
||||||
job: args.job,
|
job: args.job,
|
||||||
};
|
};
|
||||||
return [4 /*yield*/, classicPlugin.plugin(pluginInputFileObj, args.librarySettings, args.inputs, otherArguments)];
|
return [4 /*yield*/, classicPlugin.plugin(pluginInputFileObj, args.librarySettings, args.inputs, otherArguments)];
|
||||||
case 12:
|
case 16:
|
||||||
result = _b.sent();
|
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) {
|
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
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import {
|
||||||
getContainer, getFileName, getPluginWorkDir, getScanTypes,
|
getContainer, getFileName, getPluginWorkDir, getScanTypes,
|
||||||
} from './fileUtils';
|
} from './fileUtils';
|
||||||
import { IpluginInputArgs } from './interfaces/interfaces';
|
import { IpluginInputArgs } from './interfaces/interfaces';
|
||||||
|
import { IFileObject } from './interfaces/synced/IFileObject';
|
||||||
|
|
||||||
export interface IrunClassicPlugin {
|
export interface IrunClassicPlugin {
|
||||||
result:{
|
result:{
|
||||||
|
|
@ -90,25 +91,41 @@ export const runClassicPlugin = async (args:IpluginInputArgs, type:'filter'|'tra
|
||||||
|
|
||||||
const scanTypes = getScanTypes([pluginSrcStr]);
|
const scanTypes = getScanTypes([pluginSrcStr]);
|
||||||
|
|
||||||
const pluginInputFileObj = await args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
let pluginInputFileObj:IFileObject;
|
||||||
file: {
|
let originalLibraryFile:IFileObject;
|
||||||
_id: args.inputFileObj._id,
|
|
||||||
file: args.inputFileObj.file,
|
|
||||||
DB: args.inputFileObj.DB,
|
|
||||||
footprintId: args.inputFileObj.footprintId,
|
|
||||||
},
|
|
||||||
scanTypes,
|
|
||||||
});
|
|
||||||
|
|
||||||
const originalLibraryFile = await args.deps.axiosMiddleware('api/v2/scan-individual-file', {
|
const inputFileScanArgs = {
|
||||||
file: {
|
_id: args.inputFileObj._id,
|
||||||
_id: args.originalLibraryFile._id,
|
file: args.inputFileObj.file,
|
||||||
file: args.originalLibraryFile.file,
|
DB: args.inputFileObj.DB,
|
||||||
DB: args.originalLibraryFile.DB,
|
footprintId: args.inputFileObj.footprintId,
|
||||||
footprintId: args.originalLibraryFile.footprintId,
|
};
|
||||||
},
|
|
||||||
scanTypes,
|
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 = {
|
const otherArguments = {
|
||||||
handbrakePath: args.handbrakePath,
|
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';
|
import Ijob from './synced/jobInterface';
|
||||||
|
|
||||||
export interface IpluginInputUi {
|
export interface IpluginInputUi {
|
||||||
|
|
@ -136,6 +137,7 @@ export interface IpluginInputArgs {
|
||||||
updateWorker: IupdateWorker,
|
updateWorker: IupdateWorker,
|
||||||
logFullCliOutput: boolean,
|
logFullCliOutput: boolean,
|
||||||
logOutcome: (outcome: string) => void,
|
logOutcome: (outcome: string) => void,
|
||||||
|
scanIndividualFile?: (filee: IFileObjectMin, scanTypes: IscanTypes) => IFileObject,
|
||||||
deps: {
|
deps: {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
fsextra: any,
|
fsextra: any,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue