mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 15:38:19 -07:00
commit
c4adc08df8
8 changed files with 328 additions and 330 deletions
|
|
@ -37,8 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fs_1 = require("fs");
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
var classicPlugins_1 = require("../../../../FlowHelpers/1.0.0/classicPlugins");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Run Classic Filter Plugin',
|
||||
|
|
@ -78,89 +77,17 @@ var details = function () { return ({
|
|||
exports.details = details;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var path, lib, pluginSourceId, parts, pluginSource, pluginId, relativePluginPath, absolutePath, classicPlugin, pluginSrcStr, res, container, cacheFilePath, otherArguments, scanTypes, pluginInputFileObj, result, outputNumber;
|
||||
var lib, outcome, result, outputNumber;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
path = require('path');
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
pluginSourceId = String(args.inputs.pluginSourceId);
|
||||
parts = pluginSourceId.split(':');
|
||||
pluginSource = parts[0];
|
||||
pluginId = parts[1];
|
||||
relativePluginPath = "../../../../../".concat(pluginSource, "/").concat(pluginId, ".js");
|
||||
absolutePath = path.resolve(__dirname, relativePluginPath);
|
||||
pluginSrcStr = '';
|
||||
if (!(pluginSource === 'Community')) return [3 /*break*/, 2];
|
||||
classicPlugin = args.deps.importFresh(relativePluginPath);
|
||||
return [4 /*yield*/, fs_1.promises.readFile(absolutePath, 'utf8')];
|
||||
return [4 /*yield*/, (0, classicPlugins_1.runClassicPlugin)(args, 'filter')];
|
||||
case 1:
|
||||
pluginSrcStr = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 2: return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/read-plugin', {
|
||||
plugin: {
|
||||
id: pluginId,
|
||||
source: pluginSource,
|
||||
},
|
||||
})];
|
||||
case 3:
|
||||
res = _a.sent();
|
||||
classicPlugin = args.deps.requireFromString(res.pluginRaw, absolutePath);
|
||||
pluginSrcStr = res.pluginRaw;
|
||||
_a.label = 4;
|
||||
case 4:
|
||||
if (classicPlugin.details().Operation !== 'Filter') {
|
||||
throw new Error("".concat('This plugin is meant for classic plugins that have '
|
||||
+ 'Operation: Filter. This classic plugin has Operation: ').concat(classicPlugin.details().Operation)
|
||||
+ 'Please use the Run Classic Transcode Flow Plugin plugin instead.');
|
||||
}
|
||||
if (!Array.isArray(classicPlugin.dependencies)) return [3 /*break*/, 8];
|
||||
if (!args.installClassicPluginDeps) return [3 /*break*/, 6];
|
||||
args.jobLog("Installing dependencies for ".concat(pluginSourceId));
|
||||
return [4 /*yield*/, args.installClassicPluginDeps(classicPlugin.dependencies)];
|
||||
case 5:
|
||||
_a.sent();
|
||||
return [3 /*break*/, 7];
|
||||
case 6:
|
||||
args.jobLog("Not installing dependencies for ".concat(pluginSourceId, ", please update Tdarr"));
|
||||
_a.label = 7;
|
||||
case 7: return [3 /*break*/, 9];
|
||||
case 8:
|
||||
args.jobLog("No depedencies to install for ".concat(pluginSourceId));
|
||||
_a.label = 9;
|
||||
case 9:
|
||||
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);
|
||||
otherArguments = {
|
||||
handbrakePath: args.handbrakePath,
|
||||
ffmpegPath: args.ffmpegPath,
|
||||
mkvpropeditPath: args.mkvpropeditPath,
|
||||
originalLibraryFile: args.originalLibraryFile,
|
||||
nodeHardwareType: args.nodeHardwareType,
|
||||
pluginCycle: 0,
|
||||
workerType: args.workerType,
|
||||
version: args.config.version,
|
||||
platform_arch_isdocker: args.platform_arch_isdocker,
|
||||
cacheFilePath: cacheFilePath,
|
||||
job: args.job,
|
||||
};
|
||||
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,
|
||||
})];
|
||||
case 10:
|
||||
pluginInputFileObj = _a.sent();
|
||||
return [4 /*yield*/, classicPlugin.plugin(pluginInputFileObj, args.librarySettings, args.inputs, otherArguments)];
|
||||
case 11:
|
||||
result = _a.sent();
|
||||
outcome = _a.sent();
|
||||
result = outcome.result;
|
||||
args.jobLog(JSON.stringify(result, null, 2));
|
||||
outputNumber = (result === null || result === void 0 ? void 0 : result.processFile) ? 1 : 2;
|
||||
return [2 /*return*/, {
|
||||
|
|
|
|||
|
|
@ -46,9 +46,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fs_1 = require("fs");
|
||||
var cliUtils_1 = require("../../../../FlowHelpers/1.0.0/cliUtils");
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
var classicPlugins_1 = require("../../../../FlowHelpers/1.0.0/classicPlugins");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Run Classic Transcode Plugin',
|
||||
|
|
@ -89,90 +88,19 @@ var replaceContainer = function (filePath, container) {
|
|||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var path, lib, pluginSourceId, parts, pluginSource, pluginId, relativePluginPath, absolutePath, classicPlugin, pluginSrcStr, res_1, container, cacheFilePath, otherArguments, scanTypes, pluginInputFileObj, result, cliPath_1, customArgs, isCustomConfig, presetSplit, workerCommand, cliPath, cli, res;
|
||||
var lib, outcome, result, absolutePath, cacheFilePath, cliPath_1, customArgs, isCustomConfig, presetSplit, workerCommand, cliPath, cli, res;
|
||||
var _a, _b, _c;
|
||||
return __generator(this, function (_d) {
|
||||
switch (_d.label) {
|
||||
case 0:
|
||||
path = require('path');
|
||||
lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
pluginSourceId = String(args.inputs.pluginSourceId);
|
||||
parts = pluginSourceId.split(':');
|
||||
pluginSource = parts[0];
|
||||
pluginId = parts[1];
|
||||
relativePluginPath = "../../../../../".concat(pluginSource, "/").concat(pluginId, ".js");
|
||||
absolutePath = path.resolve(__dirname, relativePluginPath);
|
||||
pluginSrcStr = '';
|
||||
if (!(pluginSource === 'Community')) return [3 /*break*/, 2];
|
||||
classicPlugin = args.deps.importFresh(relativePluginPath);
|
||||
return [4 /*yield*/, fs_1.promises.readFile(absolutePath, 'utf8')];
|
||||
return [4 /*yield*/, (0, classicPlugins_1.runClassicPlugin)(args, 'transcode')];
|
||||
case 1:
|
||||
pluginSrcStr = _d.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 2: return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/read-plugin', {
|
||||
plugin: {
|
||||
id: pluginId,
|
||||
source: pluginSource,
|
||||
},
|
||||
})];
|
||||
case 3:
|
||||
res_1 = _d.sent();
|
||||
classicPlugin = args.deps.requireFromString(res_1.pluginRaw, absolutePath);
|
||||
pluginSrcStr = res_1.pluginRaw;
|
||||
_d.label = 4;
|
||||
case 4:
|
||||
if (classicPlugin.details().Operation === 'Filter') {
|
||||
throw new Error("".concat('This plugin is meant for classic plugins that have '
|
||||
+ 'Operation: Transcode. This classic plugin has Operation: ').concat(classicPlugin.details().Operation)
|
||||
+ 'Please use the Run Classic Filter Flow Plugin plugin instead.');
|
||||
}
|
||||
if (!Array.isArray(classicPlugin.dependencies)) return [3 /*break*/, 8];
|
||||
if (!args.installClassicPluginDeps) return [3 /*break*/, 6];
|
||||
args.jobLog("Installing dependencies for ".concat(pluginSourceId));
|
||||
return [4 /*yield*/, args.installClassicPluginDeps(classicPlugin.dependencies)];
|
||||
case 5:
|
||||
_d.sent();
|
||||
return [3 /*break*/, 7];
|
||||
case 6:
|
||||
args.jobLog("Not installing dependencies for ".concat(pluginSourceId, ", please update Tdarr"));
|
||||
_d.label = 7;
|
||||
case 7: return [3 /*break*/, 9];
|
||||
case 8:
|
||||
args.jobLog("No depedencies to install for ".concat(pluginSourceId));
|
||||
_d.label = 9;
|
||||
case 9:
|
||||
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);
|
||||
otherArguments = {
|
||||
handbrakePath: args.handbrakePath,
|
||||
ffmpegPath: args.ffmpegPath,
|
||||
mkvpropeditPath: args.mkvpropeditPath,
|
||||
originalLibraryFile: args.originalLibraryFile,
|
||||
nodeHardwareType: args.nodeHardwareType,
|
||||
pluginCycle: 0,
|
||||
workerType: args.workerType,
|
||||
version: args.config.version,
|
||||
platform_arch_isdocker: args.platform_arch_isdocker,
|
||||
cacheFilePath: cacheFilePath,
|
||||
job: args.job,
|
||||
};
|
||||
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,
|
||||
})];
|
||||
case 10:
|
||||
pluginInputFileObj = _d.sent();
|
||||
return [4 /*yield*/, classicPlugin.plugin(pluginInputFileObj, args.librarySettings, args.inputs, otherArguments)];
|
||||
case 11:
|
||||
result = _d.sent();
|
||||
outcome = _d.sent();
|
||||
result = outcome.result, absolutePath = outcome.absolutePath;
|
||||
cacheFilePath = outcome.cacheFilePath;
|
||||
args.jobLog(JSON.stringify(result, null, 2));
|
||||
if (!result) {
|
||||
args.jobLog('No result from classic plugin. Continuing to next flow plugin.');
|
||||
|
|
@ -225,11 +153,15 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|||
}
|
||||
customArgs = (_b = result === null || result === void 0 ? void 0 : result.custom) === null || _b === void 0 ? void 0 : _b.args;
|
||||
isCustomConfig = (Array.isArray(customArgs) && customArgs.length > 0)
|
||||
|| (typeof customArgs === 'string' && customArgs.length > 0);
|
||||
|| (typeof customArgs === 'string'
|
||||
// @ts-expect-error length
|
||||
&& customArgs.length
|
||||
> 0);
|
||||
if (!isCustomConfig) {
|
||||
cacheFilePath = replaceContainer(cacheFilePath, result.container);
|
||||
}
|
||||
else {
|
||||
// @ts-expect-error type
|
||||
cacheFilePath = result.custom.outputPath;
|
||||
}
|
||||
if (result.preset.includes('<io>')) {
|
||||
|
|
@ -241,6 +173,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|||
workerCommand = [];
|
||||
cliPath = '';
|
||||
if (isCustomConfig) {
|
||||
// @ts-expect-error cliPath
|
||||
cliPath = (_c = result === null || result === void 0 ? void 0 : result.custom) === null || _c === void 0 ? void 0 : _c.cliPath;
|
||||
if (Array.isArray(customArgs)) {
|
||||
workerCommand = customArgs;
|
||||
|
|
@ -285,7 +218,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|||
updateWorker: args.updateWorker,
|
||||
});
|
||||
return [4 /*yield*/, cli.runCli()];
|
||||
case 12:
|
||||
case 2:
|
||||
res = _d.sent();
|
||||
if (res.cliExitCode !== 0) {
|
||||
args.jobLog("Running ".concat(cliPath, " failed"));
|
||||
|
|
|
|||
|
|
@ -77,15 +77,22 @@ var plugin = function (args) {
|
|||
greaterThanBits *= 1000000;
|
||||
lessThanBits *= 1000000;
|
||||
}
|
||||
var hasVideoBitrate = false;
|
||||
if ((_b = (_a = args.inputFileObj) === null || _a === void 0 ? void 0 : _a.mediaInfo) === null || _b === void 0 ? void 0 : _b.track) {
|
||||
args.inputFileObj.mediaInfo.track.forEach(function (stream) {
|
||||
if (stream['@type'] === 'video') {
|
||||
if (stream.BitRate) {
|
||||
hasVideoBitrate = true;
|
||||
}
|
||||
if (stream.BitRate >= greaterThanBits && stream.BitRate <= lessThanBits) {
|
||||
isWithinRange = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!hasVideoBitrate) {
|
||||
throw new Error('Video bitrate not found');
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: isWithinRange ? 1 : 2,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue