mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-14 17:55:55 -07:00
Merge pull request #643 from HaveAGitGat/cli
Add useCustomCliPath and customCliPath inputs
This commit is contained in:
commit
11a623c212
2 changed files with 160 additions and 43 deletions
|
|
@ -62,6 +62,16 @@ var details = function () { return ({
|
||||||
sidebarPosition: -1,
|
sidebarPosition: -1,
|
||||||
icon: '',
|
icon: '',
|
||||||
inputs: [
|
inputs: [
|
||||||
|
{
|
||||||
|
label: 'Use Custom CLI Path?',
|
||||||
|
name: 'useCustomCliPath',
|
||||||
|
type: 'boolean',
|
||||||
|
defaultValue: 'false',
|
||||||
|
inputUI: {
|
||||||
|
type: 'switch',
|
||||||
|
},
|
||||||
|
tooltip: 'Specify whether to use a custom CLI path',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'CLI',
|
label: 'CLI',
|
||||||
name: 'userCli',
|
name: 'userCli',
|
||||||
|
|
@ -73,9 +83,49 @@ var details = function () { return ({
|
||||||
'mkvmerge',
|
'mkvmerge',
|
||||||
'mkvpropedit',
|
'mkvpropedit',
|
||||||
],
|
],
|
||||||
|
displayConditions: {
|
||||||
|
logic: 'AND',
|
||||||
|
sets: [
|
||||||
|
{
|
||||||
|
logic: 'AND',
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
name: 'useCustomCliPath',
|
||||||
|
value: 'false',
|
||||||
|
condition: '===',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tooltip: 'CLI to run',
|
tooltip: 'CLI to run',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Custom CLI Path',
|
||||||
|
name: 'customCliPath',
|
||||||
|
type: 'string',
|
||||||
|
defaultValue: '/usr/bin/mkvmerge',
|
||||||
|
inputUI: {
|
||||||
|
type: 'text',
|
||||||
|
displayConditions: {
|
||||||
|
logic: 'AND',
|
||||||
|
sets: [
|
||||||
|
{
|
||||||
|
logic: 'AND',
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
name: 'useCustomCliPath',
|
||||||
|
value: 'true',
|
||||||
|
condition: '===',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tooltip: 'Specify the path to the CLI to run',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Does Command Create Output File?',
|
label: 'Does Command Create Output File?',
|
||||||
name: 'doesCommandCreateOutputFile',
|
name: 'doesCommandCreateOutputFile',
|
||||||
|
|
@ -112,6 +162,17 @@ var details = function () { return ({
|
||||||
},
|
},
|
||||||
tooltip: "\n This path can be accessed using ${outputFilePath} in the \"CLI Arguments\" input below.\n\n \\n\n ${cacheDir} is a special variable that points to the Tdarr worker cache directory.\n\n \\n \n ${fileName} is a special variable for the filename without extension.\n \n \\nExample\\n\n ${cacheDir}/${fileName}.{{{args.inputFileObj.container}}}\n ",
|
tooltip: "\n This path can be accessed using ${outputFilePath} in the \"CLI Arguments\" input below.\n\n \\n\n ${cacheDir} is a special variable that points to the Tdarr worker cache directory.\n\n \\n \n ${fileName} is a special variable for the filename without extension.\n \n \\nExample\\n\n ${cacheDir}/${fileName}.{{{args.inputFileObj.container}}}\n ",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'CLI Arguments',
|
||||||
|
name: 'cliArguments',
|
||||||
|
type: 'string',
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
defaultValue: '-o "${outputFilePath}" "{{{args.inputFileObj._id}}}"',
|
||||||
|
inputUI: {
|
||||||
|
type: 'text',
|
||||||
|
},
|
||||||
|
tooltip: "Specify arguments to pass to the CLI. \n Normal variable templating with {{{}}} applies but ${outputFilePath} is a special\n variable from the \"Output File Path\" input above.\n\n \\nExample\\n\n -o \"${outputFilePath}\" \"{{{args.inputFileObj._id}}}\"\n ",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Output File Becomes Working File?',
|
label: 'Output File Becomes Working File?',
|
||||||
name: 'outputFileBecomesWorkingFile',
|
name: 'outputFileBecomesWorkingFile',
|
||||||
|
|
@ -137,17 +198,6 @@ var details = function () { return ({
|
||||||
},
|
},
|
||||||
tooltip: 'Toggle this on to make the output file become the working file for the next plugin.',
|
tooltip: 'Toggle this on to make the output file become the working file for the next plugin.',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'CLI Arguments',
|
|
||||||
name: 'cliArguments',
|
|
||||||
type: 'string',
|
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
|
||||||
defaultValue: '-o "${outputFilePath}" "{{{args.inputFileObj._id}}}"',
|
|
||||||
inputUI: {
|
|
||||||
type: 'text',
|
|
||||||
},
|
|
||||||
tooltip: "Specify arguments to pass to the CLI. \n Normal variable templating with {{{}}} applies but ${outputFilePath} is a special\n variable from the \"Output File Path\" input above.\n\n \\nExample\\n\n -o \"${outputFilePath}\" \"{{{args.inputFileObj._id}}}\"\n ",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
outputs: [
|
outputs: [
|
||||||
{
|
{
|
||||||
|
|
@ -159,7 +209,7 @@ var details = function () { return ({
|
||||||
exports.details = details;
|
exports.details = details;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
||||||
var lib, userCli, outputFileBecomesWorkingFile, userOutputFilePath, cliArguments, cacheDir, fileName, cliArgs, availableCli, msg, cli, res, msg;
|
var lib, userCli, useCustomCliPath, customCliPath, cliPath, outputFileBecomesWorkingFile, userOutputFilePath, cliArguments, cacheDir, fileName, cliArgs, availableCli, msg, cli, res, msg;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -167,6 +217,9 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||||
userCli = String(args.inputs.userCli);
|
userCli = String(args.inputs.userCli);
|
||||||
|
useCustomCliPath = args.inputs.useCustomCliPath;
|
||||||
|
customCliPath = String(args.inputs.customCliPath);
|
||||||
|
cliPath = '';
|
||||||
outputFileBecomesWorkingFile = args.inputs.outputFileBecomesWorkingFile;
|
outputFileBecomesWorkingFile = args.inputs.outputFileBecomesWorkingFile;
|
||||||
userOutputFilePath = String(args.inputs.userOutputFilePath);
|
userOutputFilePath = String(args.inputs.userOutputFilePath);
|
||||||
cliArguments = String(args.inputs.cliArguments);
|
cliArguments = String(args.inputs.cliArguments);
|
||||||
|
|
@ -189,14 +242,19 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
mkvpropedit: args.mkvpropeditPath,
|
mkvpropedit: args.mkvpropeditPath,
|
||||||
mkvmerge: 'mkvmerge',
|
mkvmerge: 'mkvmerge',
|
||||||
};
|
};
|
||||||
if (!availableCli[userCli]) {
|
if (useCustomCliPath) {
|
||||||
msg = "CLI ".concat(userCli, " not available to run in this plugin");
|
cliPath = customCliPath;
|
||||||
args.jobLog(msg);
|
}
|
||||||
throw new Error(msg);
|
else {
|
||||||
|
if (!availableCli[userCli]) {
|
||||||
|
msg = "CLI ".concat(userCli, " not available to run in this plugin");
|
||||||
|
args.jobLog(msg);
|
||||||
|
throw new Error(msg);
|
||||||
|
}
|
||||||
|
cliPath = availableCli[userCli];
|
||||||
}
|
}
|
||||||
userCli = availableCli[userCli];
|
|
||||||
cli = new cliUtils_1.CLI({
|
cli = new cliUtils_1.CLI({
|
||||||
cli: userCli,
|
cli: cliPath,
|
||||||
spawnArgs: cliArgs,
|
spawnArgs: cliArgs,
|
||||||
spawnOpts: {},
|
spawnOpts: {},
|
||||||
jobLog: args.jobLog,
|
jobLog: args.jobLog,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,16 @@ const details = (): IpluginDetails => ({
|
||||||
sidebarPosition: -1,
|
sidebarPosition: -1,
|
||||||
icon: '',
|
icon: '',
|
||||||
inputs: [
|
inputs: [
|
||||||
|
{
|
||||||
|
label: 'Use Custom CLI Path?',
|
||||||
|
name: 'useCustomCliPath',
|
||||||
|
type: 'boolean',
|
||||||
|
defaultValue: 'false',
|
||||||
|
inputUI: {
|
||||||
|
type: 'switch',
|
||||||
|
},
|
||||||
|
tooltip: 'Specify whether to use a custom CLI path',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'CLI',
|
label: 'CLI',
|
||||||
name: 'userCli',
|
name: 'userCli',
|
||||||
|
|
@ -31,9 +41,49 @@ const details = (): IpluginDetails => ({
|
||||||
'mkvmerge',
|
'mkvmerge',
|
||||||
'mkvpropedit',
|
'mkvpropedit',
|
||||||
],
|
],
|
||||||
|
displayConditions: {
|
||||||
|
logic: 'AND',
|
||||||
|
sets: [
|
||||||
|
{
|
||||||
|
logic: 'AND',
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
name: 'useCustomCliPath',
|
||||||
|
value: 'false',
|
||||||
|
condition: '===',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tooltip: 'CLI to run',
|
tooltip: 'CLI to run',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Custom CLI Path',
|
||||||
|
name: 'customCliPath',
|
||||||
|
type: 'string',
|
||||||
|
defaultValue: '/usr/bin/mkvmerge',
|
||||||
|
inputUI: {
|
||||||
|
type: 'text',
|
||||||
|
displayConditions: {
|
||||||
|
logic: 'AND',
|
||||||
|
sets: [
|
||||||
|
{
|
||||||
|
logic: 'AND',
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
name: 'useCustomCliPath',
|
||||||
|
value: 'true',
|
||||||
|
condition: '===',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tooltip: 'Specify the path to the CLI to run',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Does Command Create Output File?',
|
label: 'Does Command Create Output File?',
|
||||||
name: 'doesCommandCreateOutputFile',
|
name: 'doesCommandCreateOutputFile',
|
||||||
|
|
@ -82,6 +132,24 @@ const details = (): IpluginDetails => ({
|
||||||
\${cacheDir}/\${fileName}.{{{args.inputFileObj.container}}}
|
\${cacheDir}/\${fileName}.{{{args.inputFileObj.container}}}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'CLI Arguments',
|
||||||
|
name: 'cliArguments',
|
||||||
|
type: 'string',
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
defaultValue: '-o "${outputFilePath}" "{{{args.inputFileObj._id}}}"',
|
||||||
|
inputUI: {
|
||||||
|
type: 'text',
|
||||||
|
},
|
||||||
|
tooltip: `Specify arguments to pass to the CLI.
|
||||||
|
Normal variable templating with {{{}}} applies but \${outputFilePath} is a special
|
||||||
|
variable from the "Output File Path" input above.
|
||||||
|
|
||||||
|
\\nExample\\n
|
||||||
|
-o "\${outputFilePath}" "{{{args.inputFileObj._id}}}"
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
label: 'Output File Becomes Working File?',
|
label: 'Output File Becomes Working File?',
|
||||||
name: 'outputFileBecomesWorkingFile',
|
name: 'outputFileBecomesWorkingFile',
|
||||||
|
|
@ -108,23 +176,6 @@ const details = (): IpluginDetails => ({
|
||||||
tooltip:
|
tooltip:
|
||||||
'Toggle this on to make the output file become the working file for the next plugin.',
|
'Toggle this on to make the output file become the working file for the next plugin.',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'CLI Arguments',
|
|
||||||
name: 'cliArguments',
|
|
||||||
type: 'string',
|
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
|
||||||
defaultValue: '-o "${outputFilePath}" "{{{args.inputFileObj._id}}}"',
|
|
||||||
inputUI: {
|
|
||||||
type: 'text',
|
|
||||||
},
|
|
||||||
tooltip: `Specify arguments to pass to the CLI.
|
|
||||||
Normal variable templating with {{{}}} applies but \${outputFilePath} is a special
|
|
||||||
variable from the "Output File Path" input above.
|
|
||||||
|
|
||||||
\\nExample\\n
|
|
||||||
-o "\${outputFilePath}" "{{{args.inputFileObj._id}}}"
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
outputs: [
|
outputs: [
|
||||||
{
|
{
|
||||||
|
|
@ -140,7 +191,11 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||||
|
|
||||||
let userCli = String(args.inputs.userCli);
|
const userCli = String(args.inputs.userCli);
|
||||||
|
const { useCustomCliPath } = args.inputs;
|
||||||
|
const customCliPath = String(args.inputs.customCliPath);
|
||||||
|
let cliPath = '';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
outputFileBecomesWorkingFile,
|
outputFileBecomesWorkingFile,
|
||||||
} = args.inputs;
|
} = args.inputs;
|
||||||
|
|
@ -175,16 +230,20 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
mkvmerge: 'mkvmerge',
|
mkvmerge: 'mkvmerge',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!availableCli[userCli]) {
|
if (useCustomCliPath) {
|
||||||
const msg = `CLI ${userCli} not available to run in this plugin`;
|
cliPath = customCliPath;
|
||||||
args.jobLog(msg);
|
} else {
|
||||||
throw new Error(msg);
|
if (!availableCli[userCli]) {
|
||||||
|
const msg = `CLI ${userCli} not available to run in this plugin`;
|
||||||
|
args.jobLog(msg);
|
||||||
|
throw new Error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
cliPath = availableCli[userCli];
|
||||||
}
|
}
|
||||||
|
|
||||||
userCli = availableCli[userCli];
|
|
||||||
|
|
||||||
const cli = new CLI({
|
const cli = new CLI({
|
||||||
cli: userCli,
|
cli: cliPath,
|
||||||
spawnArgs: cliArgs,
|
spawnArgs: cliArgs,
|
||||||
spawnOpts: {},
|
spawnOpts: {},
|
||||||
jobLog: args.jobLog,
|
jobLog: args.jobLog,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue