mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 23:48:15 -07:00
Merge branch 'master' into pr/600
This commit is contained in:
commit
50d628da95
18 changed files with 1970 additions and 994 deletions
|
|
@ -16,6 +16,66 @@ var details = function () { return ({
|
|||
sidebarPosition: -1,
|
||||
icon: '',
|
||||
inputs: [
|
||||
{
|
||||
label: 'Use % of Input Bitrate',
|
||||
name: 'useInputBitrate',
|
||||
type: 'boolean',
|
||||
defaultValue: 'false',
|
||||
inputUI: {
|
||||
type: 'switch',
|
||||
},
|
||||
tooltip: 'Specify whether to use a % of input bitrate as the output bitrate',
|
||||
},
|
||||
{
|
||||
label: 'Target Bitrate %',
|
||||
name: 'targetBitratePercent',
|
||||
type: 'string',
|
||||
defaultValue: '50',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
displayConditions: {
|
||||
logic: 'AND',
|
||||
sets: [
|
||||
{
|
||||
logic: 'AND',
|
||||
inputs: [
|
||||
{
|
||||
name: 'useInputBitrate',
|
||||
value: 'true',
|
||||
condition: '===',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
tooltip: 'Specify the target bitrate as a % of the input bitrate',
|
||||
},
|
||||
{
|
||||
label: 'Fallback Bitrate',
|
||||
name: 'fallbackBitrate',
|
||||
type: 'string',
|
||||
defaultValue: '4000',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
displayConditions: {
|
||||
logic: 'AND',
|
||||
sets: [
|
||||
{
|
||||
logic: 'AND',
|
||||
inputs: [
|
||||
{
|
||||
name: 'useInputBitrate',
|
||||
value: 'true',
|
||||
condition: '===',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
tooltip: 'Specify fallback bitrate in kbps if input bitrate is not available',
|
||||
},
|
||||
{
|
||||
label: 'Bitrate',
|
||||
name: 'bitrate',
|
||||
|
|
@ -23,6 +83,21 @@ var details = function () { return ({
|
|||
defaultValue: '5000',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
displayConditions: {
|
||||
logic: 'AND',
|
||||
sets: [
|
||||
{
|
||||
logic: 'AND',
|
||||
inputs: [
|
||||
{
|
||||
name: 'useInputBitrate',
|
||||
value: 'true',
|
||||
condition: '!==',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
tooltip: 'Specify bitrate in kbps',
|
||||
},
|
||||
|
|
@ -40,10 +115,36 @@ var plugin = function (args) {
|
|||
var lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
var useInputBitrate = args.inputs.useInputBitrate;
|
||||
var targetBitratePercent = String(args.inputs.targetBitratePercent);
|
||||
var fallbackBitrate = String(args.inputs.fallbackBitrate);
|
||||
var bitrate = String(args.inputs.bitrate);
|
||||
args.variables.ffmpegCommand.streams.forEach(function (stream) {
|
||||
var _a, _b, _c, _d;
|
||||
if (stream.codec_type === 'video') {
|
||||
var ffType = (0, fileUtils_1.getFfType)(stream.codec_type);
|
||||
stream.outputArgs.push("-b:".concat(ffType, ":{outputTypeIndex}"), "".concat(String(args.inputs.bitrate), "k"));
|
||||
if (useInputBitrate) {
|
||||
args.jobLog('Attempting to use % of input bitrate as output bitrate');
|
||||
// check if input bitrate is available
|
||||
var mediainfoIndex = stream.index + 1;
|
||||
var inputBitrate = (_d = (_c = (_b = (_a = args === null || args === void 0 ? void 0 : args.inputFileObj) === null || _a === void 0 ? void 0 : _a.mediaInfo) === null || _b === void 0 ? void 0 : _b.track) === null || _c === void 0 ? void 0 : _c[mediainfoIndex]) === null || _d === void 0 ? void 0 : _d.BitRate;
|
||||
if (inputBitrate) {
|
||||
args.jobLog("Found input bitrate: ".concat(inputBitrate));
|
||||
// @ts-expect-error type
|
||||
inputBitrate = parseInt(inputBitrate, 10) / 1000;
|
||||
var targetBitrate = (inputBitrate * (parseInt(targetBitratePercent, 10) / 100));
|
||||
args.jobLog("Setting video bitrate as ".concat(targetBitrate, "k"));
|
||||
stream.outputArgs.push("-b:".concat(ffType, ":{outputTypeIndex}"), "".concat(targetBitrate, "k"));
|
||||
}
|
||||
else {
|
||||
args.jobLog("Unable to find input bitrate, setting fallback bitrate as ".concat(fallbackBitrate, "k"));
|
||||
stream.outputArgs.push("-b:".concat(ffType, ":{outputTypeIndex}"), "".concat(fallbackBitrate, "k"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
args.jobLog("Using fixed bitrate. Setting video bitrate as ".concat(bitrate, "k"));
|
||||
stream.outputArgs.push("-b:".concat(ffType, ":{outputTypeIndex}"), "".concat(bitrate, "k"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ var plugin = function (args) {
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
var extensions = String(args.inputs.extensions);
|
||||
var extensionArray = extensions.trim().split(',');
|
||||
var extension = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
|
||||
var extensionArray = extensions.trim().split(',').map(function (row) { return row.toLowerCase(); });
|
||||
var extension = (0, fileUtils_1.getContainer)(args.inputFileObj._id).toLowerCase();
|
||||
var extensionMatch = false;
|
||||
if (extensionArray.includes(extension)) {
|
||||
extensionMatch = true;
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@ var details = function () { return ({
|
|||
label: 'Terms',
|
||||
name: 'terms',
|
||||
type: 'string',
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
defaultValue: '_720p,_1080p',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
tooltip: 'Specify terms to check for in file name using comma seperated list e.g. _720p,_1080p',
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Check File Name Includes',
|
||||
description: 'Check if a file name includes specific terms. Only needs to match one term',
|
||||
style: {
|
||||
borderColor: 'orange',
|
||||
},
|
||||
tags: 'video',
|
||||
isStartPlugin: false,
|
||||
pType: '',
|
||||
requiresVersion: '2.11.01',
|
||||
sidebarPosition: -1,
|
||||
icon: 'faQuestion',
|
||||
inputs: [
|
||||
{
|
||||
label: 'Terms',
|
||||
name: 'terms',
|
||||
type: 'string',
|
||||
defaultValue: '_720p,_1080p',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify terms to check for in file name using comma seperated list e.g. _720p,_1080p',
|
||||
},
|
||||
{
|
||||
label: 'Pattern (regular expression)',
|
||||
name: 'pattern',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Specify the pattern (regex) to check for in file name e.g. ^Pattern.*mkv$',
|
||||
},
|
||||
{
|
||||
label: 'Include file directory in check',
|
||||
name: 'includeFileDirectory',
|
||||
type: 'boolean',
|
||||
defaultValue: 'false',
|
||||
inputUI: {
|
||||
type: 'switch',
|
||||
},
|
||||
tooltip: 'Should the terms and patterns be evaluated against the file directory e.g. false, true',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
number: 1,
|
||||
tooltip: 'File name contains terms or patterns',
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
tooltip: 'File name does not contain any of the terms or patterns',
|
||||
},
|
||||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) {
|
||||
var lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
var terms = String(args.inputs.terms);
|
||||
var pattern = String(args.inputs.pattern);
|
||||
var includeFileDirectory = args.inputs.includeFileDirectory;
|
||||
var fileName = includeFileDirectory
|
||||
? args.inputFileObj._id
|
||||
: "".concat((0, fileUtils_1.getFileName)(args.inputFileObj._id), ".").concat((0, fileUtils_1.getContainer)(args.inputFileObj._id));
|
||||
var searchCriteriasArray = terms.trim().split(',')
|
||||
.map(function (term) { return term.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); }); // https://github.com/tc39/proposal-regex-escaping
|
||||
if (pattern) {
|
||||
searchCriteriasArray.push(pattern);
|
||||
}
|
||||
var searchCriteriaMatched = searchCriteriasArray
|
||||
.find(function (searchCriteria) { return new RegExp(searchCriteria).test(fileName); });
|
||||
var isAMatch = searchCriteriaMatched !== undefined;
|
||||
if (isAMatch) {
|
||||
args.jobLog("'".concat(fileName, "' includes '").concat(searchCriteriaMatched, "'"));
|
||||
}
|
||||
else {
|
||||
args.jobLog("'".concat(fileName, "' does not include any of the terms or patterns"));
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: isAMatch ? 1 : 2,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
exports.plugin = plugin;
|
||||
|
|
@ -150,33 +150,31 @@ var details = function () { return ({
|
|||
],
|
||||
}); };
|
||||
exports.details = details;
|
||||
var doOperation = function (_a) {
|
||||
var args = _a.args, sourcePath = _a.sourcePath, destinationPath = _a.destinationPath, operation = _a.operation;
|
||||
return __awaiter(void 0, void 0, void 0, function () {
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
args.jobLog("Input path: ".concat(sourcePath));
|
||||
args.jobLog("Output path: ".concat(destinationPath));
|
||||
if (!(sourcePath === destinationPath)) return [3 /*break*/, 1];
|
||||
args.jobLog("Input and output path are the same, skipping ".concat(operation));
|
||||
return [3 /*break*/, 3];
|
||||
case 1:
|
||||
args.deps.fsextra.ensureDirSync((0, fileUtils_1.getFileAbosluteDir)(destinationPath));
|
||||
return [4 /*yield*/, (0, fileMoveOrCopy_1.default)({
|
||||
operation: operation,
|
||||
sourcePath: sourcePath,
|
||||
destinationPath: destinationPath,
|
||||
args: args,
|
||||
})];
|
||||
case 2:
|
||||
_b.sent();
|
||||
_b.label = 3;
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
var doOperation = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
||||
var args = _b.args, sourcePath = _b.sourcePath, destinationPath = _b.destinationPath, operation = _b.operation;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
args.jobLog("Input path: ".concat(sourcePath));
|
||||
args.jobLog("Output path: ".concat(destinationPath));
|
||||
if (!(sourcePath === destinationPath)) return [3 /*break*/, 1];
|
||||
args.jobLog("Input and output path are the same, skipping ".concat(operation));
|
||||
return [3 /*break*/, 3];
|
||||
case 1:
|
||||
args.deps.fsextra.ensureDirSync((0, fileUtils_1.getFileAbosluteDir)(destinationPath));
|
||||
return [4 /*yield*/, (0, fileMoveOrCopy_1.default)({
|
||||
operation: operation,
|
||||
sourcePath: sourcePath,
|
||||
destinationPath: destinationPath,
|
||||
args: args,
|
||||
})];
|
||||
case 2:
|
||||
_c.sent();
|
||||
_c.label = 3;
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
};
|
||||
}); };
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var lib, _a, keepRelativePath, allFiles, sourceDirectory, outputDirectory, copyOrMove, fileExtensions, outputPath, subStem, sourceDir, filesInDir, i;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ var details = function () { return ({
|
|||
inputUI: {
|
||||
type: 'text',
|
||||
},
|
||||
tooltip: 'Value of variable to check',
|
||||
tooltip: "Value of variable to check. \nYou can specify multiple values separated by comma. For example: value1,value2,value3",
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
|
|
@ -99,23 +99,24 @@ var plugin = function (args) {
|
|||
}
|
||||
targetValue = String(targetValue);
|
||||
var outputNumber = 1;
|
||||
var valuesArr = value.trim().split(',');
|
||||
if (condition === '==') {
|
||||
if (targetValue === value) {
|
||||
args.jobLog("Variable ".concat(variable, " of value ").concat(targetValue, " matches condition ").concat(condition, " ").concat(value));
|
||||
if (valuesArr.includes(targetValue)) {
|
||||
args.jobLog("Variable ".concat(variable, " of value ").concat(targetValue, " matches condition ").concat(condition, " ").concat(valuesArr));
|
||||
outputNumber = 1;
|
||||
}
|
||||
else {
|
||||
args.jobLog("Variable ".concat(variable, " of value ").concat(targetValue, " does not match condition ").concat(condition, " ").concat(value));
|
||||
args.jobLog("Variable ".concat(variable, " of value ").concat(targetValue, " does not match condition ").concat(condition, " ").concat(valuesArr));
|
||||
outputNumber = 2;
|
||||
}
|
||||
}
|
||||
else if (condition === '!=') {
|
||||
if (targetValue !== value) {
|
||||
args.jobLog("Variable ".concat(variable, " of value ").concat(targetValue, " matches condition ").concat(condition, " ").concat(value));
|
||||
if (!valuesArr.includes(targetValue)) {
|
||||
args.jobLog("Variable ".concat(variable, " of value ").concat(targetValue, " matches condition ").concat(condition, " ").concat(valuesArr));
|
||||
outputNumber = 1;
|
||||
}
|
||||
else {
|
||||
args.jobLog("Variable ".concat(variable, " of value ").concat(targetValue, " does not match condition ").concat(condition, " ").concat(value));
|
||||
args.jobLog("Variable ".concat(variable, " of value ").concat(targetValue, " does not match condition ").concat(condition, " ").concat(valuesArr));
|
||||
outputNumber = 2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue