mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-14 09:45:55 -07:00
Poll server for job report and add optional server ip/port inputs
This commit is contained in:
parent
efd12b23cb
commit
fdd67655c5
1 changed files with 95 additions and 64 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars, no-await-in-loop */
|
||||||
module.exports.dependencies = ['axios@0.27.2'];
|
module.exports.dependencies = ['axios@0.27.2'];
|
||||||
|
|
||||||
// PLugin runs multipass loudnorm filter
|
// PLugin runs multipass loudnorm filter
|
||||||
|
|
@ -57,6 +57,25 @@ Output will be MKV to allow metadata to be added for tracking normalisation stag
|
||||||
tooltip: `Desired "tp" value. \\n Defaults to -2.0
|
tooltip: `Desired "tp" value. \\n Defaults to -2.0
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'serverIp',
|
||||||
|
type: 'string',
|
||||||
|
defaultValue: '',
|
||||||
|
inputUI: {
|
||||||
|
type: 'text',
|
||||||
|
},
|
||||||
|
tooltip: 'Enter the IP address of the server if plugin having trouble connecting.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'serverPort',
|
||||||
|
type: 'string',
|
||||||
|
defaultValue: '',
|
||||||
|
inputUI: {
|
||||||
|
type: 'text',
|
||||||
|
},
|
||||||
|
tooltip: 'Enter the port number of the server if plugin having trouble connecting.',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -69,14 +88,21 @@ const parseJobName = (text) => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getloudNormValues = async (response, file) => {
|
const getloudNormValues = async (inputs, response, file) => {
|
||||||
// eslint-disable-next-line import/no-unresolved
|
// eslint-disable-next-line import/no-unresolved
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const serverUrl = `http://${process.env.serverIp}:${process.env.serverPort}`;
|
|
||||||
let loudNormValues = {};
|
const serverIp = inputs.serverIp ? inputs.serverIp : process.env.serverIp;
|
||||||
|
const serverPort = inputs.serverPort ? inputs.serverPort : process.env.serverPort;
|
||||||
|
const serverUrl = `http://${serverIp}:${serverPort}`;
|
||||||
|
let loudNormValues = false;
|
||||||
|
let tries = 0;
|
||||||
|
let error = false;
|
||||||
|
while (tries < 15) {
|
||||||
try {
|
try {
|
||||||
|
tries += 1;
|
||||||
// wait for job report to be updated by server,
|
// wait for job report to be updated by server,
|
||||||
await new Promise((resolve) => setTimeout(resolve, 10000));
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
|
|
||||||
const logFilesReq = await axios.post(`${serverUrl}/api/v2/list-footprintId-reports`, {
|
const logFilesReq = await axios.post(`${serverUrl}/api/v2/list-footprintId-reports`, {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -128,7 +154,6 @@ const getloudNormValues = async (response, file) => {
|
||||||
|
|
||||||
const loudNormDataArr = [];
|
const loudNormDataArr = [];
|
||||||
|
|
||||||
// {
|
|
||||||
for (let i = (idx + 1); i < lines.length; i += 1) {
|
for (let i = (idx + 1); i < lines.length; i += 1) {
|
||||||
const lineArr = lines[i].split(' ');
|
const lineArr = lines[i].split(' ');
|
||||||
lineArr.shift();
|
lineArr.shift();
|
||||||
|
|
@ -139,9 +164,15 @@ const getloudNormValues = async (response, file) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
loudNormValues = JSON.parse(loudNormDataArr.join(''));
|
loudNormValues = JSON.parse(loudNormDataArr.join(''));
|
||||||
|
break;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
response.infoLog += err;
|
response.infoLog += err;
|
||||||
throw new Error(err);
|
error = err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loudNormValues === false && error) {
|
||||||
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return loudNormValues;
|
return loudNormValues;
|
||||||
|
|
@ -195,7 +226,7 @@ const plugin = async (file, librarySettings, inputs, otherArguments) => {
|
||||||
} if (
|
} if (
|
||||||
probeData.format.tags.NORMALISATIONSTAGE === 'FirstPassComplete'
|
probeData.format.tags.NORMALISATIONSTAGE === 'FirstPassComplete'
|
||||||
) {
|
) {
|
||||||
const loudNormValues = await getloudNormValues(response, file);
|
const loudNormValues = await getloudNormValues(inputs, response, file);
|
||||||
|
|
||||||
response.infoLog += `Loudnorm first pass values returned: \n${JSON.stringify(loudNormValues)}`;
|
response.infoLog += `Loudnorm first pass values returned: \n${JSON.stringify(loudNormValues)}`;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue