v2 Dependencies addition

make-only-subtitle-default
HaveAGitGat 5 years ago
parent 13b0ec0221
commit b79f45db6b

@ -1,19 +1,24 @@
// List any npm dependencies which the plugin needs, they will be auto installed when the plugin runs:
module.exports.dependencies = [
'import-fresh',
];
module.exports.details = function details() { module.exports.details = function details() {
return { return {
id: "Tdarr_Plugin_aaaa_Pre_Proc_Example", id: 'Tdarr_Plugin_aaaa_Pre_Proc_Example',
Stage: "Pre-processing", //Preprocessing or Post-processing. Determines when the plugin will be executed. Stage: 'Pre-processing', // Preprocessing or Post-processing. Determines when the plugin will be executed.
Name: "No title meta data ", Name: 'No title meta data ',
Type: "Video", Type: 'Video',
Operation: "Transcode", Operation: 'Transcode',
Description: `This plugin removes metadata (if a title exists). The output container is the same as the original. \n\n`, Description: 'This plugin removes metadata (if a title exists). The output container is the same as the original. \n\n',
Version: "1.00", Version: '1.00',
Link: "https://github.com/HaveAGitGat/Tdarr_Plugin_aaaa_Pre_Proc_Example", Link: 'https://github.com/HaveAGitGat/Tdarr_Plugin_aaaa_Pre_Proc_Example',
Tags: "ffmpeg,h265", //Provide tags to categorise your plugin in the plugin browser.Tag options: h265,hevc,h264,nvenc h265,nvenc h264,video only,audio only,subtitle only,handbrake,ffmpeg,radarr,sonarr,pre-processing,post-processing,configurable Tags: 'ffmpeg,h265', // Provide tags to categorise your plugin in the plugin browser.Tag options: h265,hevc,h264,nvenc h265,nvenc h264,video only,audio only,subtitle only,handbrake,ffmpeg,radarr,sonarr,pre-processing,post-processing,configurable
Inputs: [ Inputs: [
//(Optional) Inputs you'd like the user to enter to allow your plugin to be easily configurable from the UI // (Optional) Inputs you'd like the user to enter to allow your plugin to be easily configurable from the UI
{ {
name: "language", name: 'language',
tooltip: `Enter one language tag here for the language of the subtitles you'd like to keep. tooltip: `Enter one language tag here for the language of the subtitles you'd like to keep.
\\nExample:\\n \\nExample:\\n
@ -25,10 +30,10 @@ module.exports.details = function details() {
\\nExample:\\n \\nExample:\\n
de`, //Each line following `Example:` will be clearly formatted. \\n used for line breaks de`, // Each line following `Example:` will be clearly formatted. \\n used for line breaks
}, },
{ {
name: "channels", name: 'channels',
tooltip: `Desired audio channel number. tooltip: `Desired audio channel number.
\\nExample:\\n \\nExample:\\n
@ -39,67 +44,69 @@ module.exports.details = function details() {
}; };
module.exports.plugin = function plugin(file, librarySettings, inputs) { module.exports.plugin = function plugin(file, librarySettings, inputs) {
//Must return this object at some point in the function else plugin will fail. // Only 'require' dependencies within this function or other functions. Do not require in the top scope.
const importFresh = require('import-fresh');
// Must return this object at some point in the function else plugin will fail.
var response = { const response = {
processFile: false, //If set to false, the file will be skipped. Set to true to have the file transcoded. processFile: false, // If set to false, the file will be skipped. Set to true to have the file transcoded.
preset: "", //HandBrake/FFmpeg CLI arguments you'd like to use. preset: '', // HandBrake/FFmpeg CLI arguments you'd like to use.
//For FFmpeg, the input arguments come first followed by <io>, followed by the output argument. // For FFmpeg, the input arguments come first followed by <io>, followed by the output argument.
// Examples // Examples
//HandBrake // HandBrake
// '-Z "Very Fast 1080p30"' // '-Z "Very Fast 1080p30"'
//FFmpeg // FFmpeg
// '-sn <io> -map_metadata -1 -c:v copy -c:a copy' // '-sn <io> -map_metadata -1 -c:v copy -c:a copy'
container: ".mp4", // The container of the transcoded output file. container: '.mp4', // The container of the transcoded output file.
handBrakeMode: false, //Set whether to use HandBrake or FFmpeg for transcoding handBrakeMode: false, // Set whether to use HandBrake or FFmpeg for transcoding
FFmpegMode: false, FFmpegMode: false,
reQueueAfter: true, //Leave as true. File will be re-qeued afterwards and pass through the plugin filter again to make sure it meets conditions. reQueueAfter: true, // Leave as true. File will be re-qeued afterwards and pass through the plugin filter again to make sure it meets conditions.
infoLog: "", //This will be shown when the user clicks the 'i' (info) button on a file in the output queue if infoLog: '', // This will be shown when the user clicks the 'i' (info) button on a file in the output queue if
//it has been skipped. // it has been skipped.
// Give reasons why it has been skipped ('File has no title metadata, File meets conditions!') // Give reasons why it has been skipped ('File has no title metadata, File meets conditions!')
//Optional (include together) // Optional (include together)
file, file,
removeFromDB: false, //Tell Tdarr to remove file from database if true removeFromDB: false, // Tell Tdarr to remove file from database if true
updateDB: false, //Change file object above and update database if true updateDB: false, // Change file object above and update database if true
}; };
console.log(inputs.language); //eng if user entered 'eng' in input box in Tdarr plugin UI console.log(inputs.language); // eng if user entered 'eng' in input box in Tdarr plugin UI
console.log(inputs.channels); //2 if user entered '2' in input box in Tdarr plugin UI console.log(inputs.channels); // 2 if user entered '2' in input box in Tdarr plugin UI
//Here we specify that we want the output file container to be the same as the current container. // Here we specify that we want the output file container to be the same as the current container.
response.container = "." + file.container; response.container = `.${file.container}`;
//We will use FFmpeg for this procedure. // We will use FFmpeg for this procedure.
response.FFmpegMode = true; response.FFmpegMode = true;
//Check if file has title metadata // Check if file has title metadata
if (file.meta.Title != undefined) { if (file.meta.Title != undefined) {
//if so, remove it // if so, remove it
response.infoLog += " File has title metadata"; response.infoLog += ' File has title metadata';
response.preset = ",-map_metadata -1 -c:v copy -c:a copy"; response.preset = ',-map_metadata -1 -c:v copy -c:a copy';
response.processFile = true; response.processFile = true;
return response; return response;
} else {
response.infoLog += " File has no title metadata";
} }
response.infoLog += ' File has no title metadata';
response.infoLog += " File meets conditions!"; response.infoLog += ' File meets conditions!';
return response; return response;
}; };
module.exports.onTranscodeSuccess = function onTranscodeSuccess( module.exports.onTranscodeSuccess = function onTranscodeSuccess(
file, file,
librarySettings, librarySettings,
inputs inputs,
) { ) {
console.log( console.log(
"Transcode success! Now do some stuff with the newly scanned file." 'Transcode success! Now do some stuff with the newly scanned file.',
); );
//Optional response if you need to modify database // Optional response if you need to modify database
var response = { const response = {
file, file,
removeFromDB: false, removeFromDB: false,
updateDB: false, updateDB: false,
@ -111,12 +118,12 @@ module.exports.onTranscodeSuccess = function onTranscodeSuccess(
module.exports.onTranscodeError = function onTranscodeError( module.exports.onTranscodeError = function onTranscodeError(
file, file,
librarySettings, librarySettings,
inputs inputs,
) { ) {
console.log("Transcode fail! Now do some stuff with the original file."); console.log('Transcode fail! Now do some stuff with the original file.');
//Optional response if you need to modify database // Optional response if you need to modify database
var response = { const response = {
file, file,
removeFromDB: false, removeFromDB: false,
updateDB: false, updateDB: false,
@ -125,7 +132,7 @@ module.exports.onTranscodeError = function onTranscodeError(
return response; return response;
}; };
//Example file object: // Example file object:
// { // {
// _id: 'C:/Users/H/Desktop/Test Input1/Sample.mp4', // _id: 'C:/Users/H/Desktop/Test Input1/Sample.mp4',
// DB: 'ZRPDmnmpyuAEQi7nG', // DB: 'ZRPDmnmpyuAEQi7nG',

@ -1,19 +1,24 @@
// List any npm dependencies which the plugin needs, they will be auto installed when the plugin runs:
module.exports.dependencies = [
'import-fresh',
];
module.exports.details = function details() { module.exports.details = function details() {
return { return {
id: "Tdarr_Plugin_zzzz_Post_Proc_Example", id: 'Tdarr_Plugin_zzzz_Post_Proc_Example',
Stage: "Post-processing", //Preprocessing or Post-processing. Determines when the plugin will be executed. This plugin does some stuff after all plugins have been executed Stage: 'Post-processing', // Preprocessing or Post-processing. Determines when the plugin will be executed. This plugin does some stuff after all plugins have been executed
Name: "Post proc ", Name: 'Post proc ',
Type: "Video", Type: 'Video',
Operation: "", Operation: '',
Description: `This plugin does some stuff after all plugins have been executed. \n\n`, Description: 'This plugin does some stuff after all plugins have been executed. \n\n',
Version: "1.00", Version: '1.00',
Link: "https://github.com/HaveAGitGat/Tdarr_Plugin_aaaa_Post_Proc_Example", Link: 'https://github.com/HaveAGitGat/Tdarr_Plugin_aaaa_Post_Proc_Example',
Tags: "ffmpeg,h265", //Provide tags to categorise your plugin in the plugin browser.Tag options: h265,hevc,h264,nvenc h265,nvenc h264,video only,audio only,subtitle only,handbrake,ffmpeg,radarr,sonarr,pre-processing,post-processing,configurable Tags: 'ffmpeg,h265', // Provide tags to categorise your plugin in the plugin browser.Tag options: h265,hevc,h264,nvenc h265,nvenc h264,video only,audio only,subtitle only,handbrake,ffmpeg,radarr,sonarr,pre-processing,post-processing,configurable
Inputs: [ Inputs: [
//(Optional) Inputs you'd like the user to enter to allow your plugin to be easily configurable from the UI // (Optional) Inputs you'd like the user to enter to allow your plugin to be easily configurable from the UI
{ {
name: "language", name: 'language',
tooltip: `Enter one language tag here for the language of the subtitles you'd like to keep. tooltip: `Enter one language tag here for the language of the subtitles you'd like to keep.
\\nExample:\\n \\nExample:\\n
@ -23,10 +28,10 @@ module.exports.details = function details() {
fr fr
\\nExample:\\n \\nExample:\\n
de`, //Each line following `Example:` will be clearly formatted. \\n used for line breaks de`, // Each line following `Example:` will be clearly formatted. \\n used for line breaks
}, },
{ {
name: "channels", name: 'channels',
tooltip: `Desired audio channel number. tooltip: `Desired audio channel number.
\\nExample:\\n \\nExample:\\n
@ -37,12 +42,15 @@ module.exports.details = function details() {
}; };
module.exports.plugin = function plugin(file, librarySettings, inputs) { module.exports.plugin = function plugin(file, librarySettings, inputs) {
// Only 'require' dependencies within this function or other functions. Do not require in the top scope.
const importFresh = require('import-fresh');
console.log( console.log(
"Transcode success! Now do some stuff with the newly scanned file." 'Transcode success! Now do some stuff with the newly scanned file.',
); );
//Optional response if you need to modify database // Optional response if you need to modify database
var response = { const response = {
file, file,
removeFromDB: false, removeFromDB: false,
updateDB: false, updateDB: false,
@ -51,7 +59,7 @@ module.exports.plugin = function plugin(file, librarySettings, inputs) {
return response; return response;
}; };
//Example file object: // Example file object:
// { // {
// _id: 'C:/Users/H/Desktop/Test Input1/Sample.mp4', // _id: 'C:/Users/H/Desktop/Test Input1/Sample.mp4',
// DB: 'ZRPDmnmpyuAEQi7nG', // DB: 'ZRPDmnmpyuAEQi7nG',

Loading…
Cancel
Save