parent
5f68989571
commit
90e2b3923a
@ -1,55 +1,55 @@
|
||||
const loadDefaultValues = require('../methods/loadDefaultValues');
|
||||
/* eslint-disable */
|
||||
function details() {
|
||||
return {
|
||||
id: "Tdarr_Plugin_075a_FFMPEG_HEVC_Generic",
|
||||
Stage: "Pre-processing",
|
||||
Name: "FFMPEG H265",
|
||||
Type: "Video",
|
||||
Operation: "Transcode",
|
||||
Description: `[Contains built-in filter] This plugin transcodes non h265 files into h265 mkv using default settings. Audio/subtitles not affected. \n\n`,
|
||||
Version: "1.00",
|
||||
Link:
|
||||
"https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_075a_FFMPEG_HEVC_Generic.js",
|
||||
Tags: "pre-processing,ffmpeg,h265,video only",
|
||||
};
|
||||
}
|
||||
const details = () => ({
|
||||
id: 'Tdarr_Plugin_075a_FFMPEG_HEVC_Generic',
|
||||
Stage: 'Pre-processing',
|
||||
Name: 'FFMPEG H265',
|
||||
Type: 'Video',
|
||||
Operation: 'Transcode',
|
||||
Description: '[Contains built-in filter] This plugin transcodes non h265 files into h265 mkv using default settings. Audio/subtitles not affected. \n\n',
|
||||
Version: '1.00',
|
||||
Tags: 'pre-processing,ffmpeg,h265,video only',
|
||||
Inputs: [],
|
||||
});
|
||||
|
||||
function plugin(file) {
|
||||
//Must return this object
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||
// eslint-disable-next-line no-unused-vars,no-param-reassign
|
||||
inputs = loadDefaultValues(inputs, details);
|
||||
// Must return this object
|
||||
|
||||
var response = {
|
||||
const response = {
|
||||
processFile: false,
|
||||
preset: "",
|
||||
container: ".mp4",
|
||||
preset: '',
|
||||
container: '.mp4',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: false,
|
||||
reQueueAfter: false,
|
||||
infoLog: "",
|
||||
infoLog: '',
|
||||
};
|
||||
|
||||
if (file.fileMedium !== "video") {
|
||||
if (file.fileMedium !== 'video') {
|
||||
response.processFile = false;
|
||||
response.infoLog += "☒File is not a video! \n";
|
||||
response.infoLog += '☒File is not a video! \n';
|
||||
return response;
|
||||
} else {
|
||||
response.infoLog += "☑File is a video! \n";
|
||||
}
|
||||
response.infoLog += '☑File is a video! \n';
|
||||
|
||||
if (file.ffProbeData.streams[0].codec_name == "hevc") {
|
||||
if (file.ffProbeData.streams[0].codec_name == 'hevc') {
|
||||
response.processFile = false;
|
||||
response.infoLog += "☑File is already in hevc! \n";
|
||||
response.infoLog += '☑File is already in hevc! \n';
|
||||
return response;
|
||||
}
|
||||
|
||||
response.processFile = true;
|
||||
response.preset = `,-map 0:v -map 0:a -map 0:s? -map 0:d? -c copy -c:v:0 libx265 -max_muxing_queue_size 9999`;
|
||||
response.container = ".mkv";
|
||||
response.preset = ',-map 0:v -map 0:a -map 0:s? -map 0:d? -c copy -c:v:0 libx265 -max_muxing_queue_size 9999';
|
||||
response.container = '.mkv';
|
||||
response.handBrakeMode = false;
|
||||
response.FFmpegMode = true;
|
||||
response.reQueueAfter = true;
|
||||
response.infoLog += `☒File is not hevc! \n`;
|
||||
response.infoLog += '☒File is not hevc! \n';
|
||||
return response;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.details = details;
|
||||
module.exports.plugin = plugin;
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
const loadDefaultValues = (inputs, details) => {
|
||||
if (!inputs) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs = {};
|
||||
}
|
||||
const defaultInputs = details().Inputs;
|
||||
for (let i = 0; i < defaultInputs.length; i += 1) {
|
||||
if (typeof inputs[defaultInputs[i].name] === 'string') {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs[defaultInputs[i].name] = typeof inputs[defaultInputs[i].name].trim();
|
||||
}
|
||||
|
||||
if (inputs[defaultInputs[i].name] === undefined
|
||||
|| inputs[defaultInputs[i].name] === ''
|
||||
) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs[defaultInputs[i].name] = defaultInputs[i].defaultValue;
|
||||
}
|
||||
|
||||
if (defaultInputs[i].type === 'boolean') {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs[defaultInputs[i].name] = inputs[defaultInputs[i].name] === 'true';
|
||||
}
|
||||
|
||||
if (defaultInputs[i].type === 'number') {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs[defaultInputs[i].name] = Number(inputs[defaultInputs[i].name]);
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
if (!isNaN(inputs[defaultInputs[i].name])) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs[defaultInputs[i].name] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return inputs;
|
||||
};
|
||||
|
||||
module.exports = loadDefaultValues;
|
||||
@ -0,0 +1,147 @@
|
||||
/* eslint no-console: 0 */ // --> OFF
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const files = fs.readdirSync('./Community');
|
||||
|
||||
const detailsOrder = [
|
||||
'id',
|
||||
'Stage',
|
||||
'Name',
|
||||
'Type',
|
||||
'Operation',
|
||||
'Description',
|
||||
'Version',
|
||||
'Tags',
|
||||
'Inputs',
|
||||
];
|
||||
const pluginInputTypes = ['string', 'number', 'boolean'];
|
||||
|
||||
for (let i = 0; i < files.length; i += 1) {
|
||||
console.log(`${files[i]}`);
|
||||
|
||||
let read = fs.readFileSync(`./Community/${files[i]}`).toString();
|
||||
|
||||
if (!read.includes('const loadDefaultValues = require(\'../methods/loadDefaultValues\');')) {
|
||||
console.log(`Plugin does not import loadDefaultValues './Community/${files[i]}'`);
|
||||
read = `const loadDefaultValues = require('../methods/loadDefaultValues');\n${read}`;
|
||||
// fs.writeFileSync(`./Community/${files[i]}`, read)
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!read.includes('const details = () =>')) {
|
||||
console.log(`Plugin details syntax is wrong './Community/${files[i]}'`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const syncText = 'const plugin = (file, librarySettings, inputs, otherArguments) => {';
|
||||
const asyncText = 'const plugin = async (file, librarySettings, inputs, otherArguments) => {';
|
||||
|
||||
if (!read.includes(syncText)
|
||||
&& !read.includes(asyncText)
|
||||
) {
|
||||
console.log(`Plugin 'plugin' syntax is wrong './Community/${files[i]}'`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!read.includes('inputs = loadDefaultValues(inputs, details);')
|
||||
) {
|
||||
console.log(`Plugin does not load default inputs './Community/${files[i]}'`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const exportText = `module.exports.details = details;
|
||||
module.exports.plugin = plugin;`;
|
||||
|
||||
if (!read.includes(exportText)) {
|
||||
console.log(`Plugin export syntax is wrong './Community/${files[i]}'`);
|
||||
read = read.replace('module.exports.details = details;', '');
|
||||
read = read.replace('module.exports.plugin = plugin;', '');
|
||||
read += `\n${exportText}`;
|
||||
// fs.writeFileSync(`./Community/${files[i]}`, read)
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let pluginDetails;
|
||||
try {
|
||||
// eslint-disable-next-line import/no-dynamic-require,global-require
|
||||
pluginDetails = require(`../Community/${files[i]}`).details();
|
||||
} catch (err) {
|
||||
console.log(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const detailsKeys = Object.keys(pluginDetails);
|
||||
|
||||
detailsOrder.forEach((detail) => {
|
||||
if (detailsKeys.indexOf(detail) === -1) {
|
||||
console.log(`Plugin details is missing './Community/${files[i]}' : ${detail}`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
detailsKeys.forEach((detail, index) => {
|
||||
if (detailsOrder[index] !== detail) {
|
||||
console.log(`Plugin details keys are not in the correct order: './Community/${files[i]}' ${detail}`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
if (detailsKeys.length < detailsOrder.length) {
|
||||
console.log(`Plugin details are too few './Community/${files[i]}'`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!['Pre-processing', 'Post-processing'].includes(pluginDetails.Stage)) {
|
||||
console.log(`Plugin does not have a valid Type'./Community/${files[i]}'`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!['Video', 'Audio', 'Subtitle', 'Any'].includes(pluginDetails.Type)) {
|
||||
console.log(`Plugin does not have a valid Type'./Community/${files[i]}'`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!['Transcode', 'Filter'].includes(pluginDetails.Operation)) {
|
||||
console.log(`Plugin does not have a valid Operation './Community/${files[i]}'`);
|
||||
process.exit(1);
|
||||
} else if (detailsKeys.length > detailsOrder.length) {
|
||||
console.log(`Plugin details are too many './Community/${files[i]}'`);
|
||||
process.exit(1);
|
||||
} else if (pluginDetails.Inputs && !Array.isArray(pluginDetails.Inputs)) {
|
||||
// Check default values are set;
|
||||
console.log(`Plugin Inputs is not an array: ${files[i]}`);
|
||||
process.exit(1);
|
||||
} else if (pluginDetails.Inputs && Array.isArray(pluginDetails.Inputs)) {
|
||||
const inputs = pluginDetails.Inputs;
|
||||
for (let j = 0; j < inputs.length; j += 1) {
|
||||
const inputKeys = Object.keys(inputs[j]);
|
||||
if (
|
||||
inputKeys[0] !== 'name'
|
||||
|| inputKeys[1] !== 'type'
|
||||
|| inputKeys[2] !== 'defaultValue'
|
||||
|| inputKeys[3] !== 'inputUI'
|
||||
|| inputKeys[4] !== 'tooltip'
|
||||
) {
|
||||
console.log(`Plugin Input keys are not in correct order: './Community/${files[i]}' : ${inputs[j].name}`);
|
||||
process.exit(1);
|
||||
} else if (inputs[j].type === undefined || !pluginInputTypes.includes(inputs[j].type)) {
|
||||
console.log(`Plugin Input does not have a type: './Community/${files[i]}' : ${inputs[j].name}`);
|
||||
process.exit(1);
|
||||
} else if (
|
||||
(inputs[j].type === 'string' && typeof inputs[j].defaultValue !== 'string')
|
||||
|| (inputs[j].type === 'number' && typeof inputs[j].defaultValue !== 'number')
|
||||
|| (inputs[j].type === 'boolean' && typeof inputs[j].defaultValue !== 'boolean')
|
||||
) {
|
||||
console.log(`Plugin Input type does not match defaultValue type:
|
||||
'./Community/${files[i]}' : ${inputs[j].name}`);
|
||||
process.exit(1);
|
||||
} else if (inputs[j].defaultValue === undefined) {
|
||||
console.log(`Plugin Input does not have a default value: './Community/${files[i]}' : ${inputs[j].name}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Done!');
|
||||
Loading…
Reference in new issue