Merge pull request #39 from controlol/patch-5

Patch
make-only-subtitle-default
HaveAGitGat 6 years ago committed by GitHub
commit 6a21944b4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,7 @@ const execSync = require('child_process').execSync;
function details() {
return {
id: "Tdarr_Plugin_e5c3_CnT_Add_Subtitles",
Stage: "Pre-processing",
Name: "Add subtitles to MKV files",
Type: "Video",
Operation:"Remux",
@ -16,6 +17,10 @@ function details() {
name: 'install_packages',
tooltip: `Please change this to "yes", it allows the plugin to install the required nodemodule. (iso-639-2) \\nExample:\\n yes`
},
{
name: 'container',
tooltip: `Enter the output container of the new file.\\n Default: .mkv\\nExample:\\n.mkv`
},
]
}
}
@ -31,6 +36,11 @@ function plugin(file, librarySettings, inputs, otherArguments) {
reQueueAfter: false,
infoLog: `Searching new subtitles...\n`,
}
if (inputs.container !== undefined) {
response.container = inputs.container;
console.log(`Changed container to: ` + inputs.container);
}
if (inputs.install_packages == "yes") {
if (!fs.existsSync(`${otherArguments.homePath}/Tdarr/node_modules/iso-639-2`)) {

@ -4,34 +4,40 @@ const fs = require('fs');
function details() {
return {
id: "Tdarr_Plugin_e5c3_CnT_Keep_Preferred_Audio",
Stage: "Pre-processing",
Name: "Keep Preffered Audio",
Type: "Video",
Type: "Audio",
Operation:"Remove Audio",
Description: "Plugin that checks for unwanted audio, per 1.104 beta you can change the languages yourself from within Tdarr!\nUntill you enter a value it keep english tracks by default.\nUndefined languages are kept to prevent videos without sound.\nIf you would like to keep track of the languages you have for each file you can use the 'special' option.\nCreated by @control#0405",
Version: "1.1",
Link: "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_e5c3_CnT_Remove_non_English_Audio.js",
Tags:'pre-processing,ffmpeg,audio only,configurable',
Version: "1.2",
Link: "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_e5c3_CnT_Keep_Preferred_Audio.js",
Inputs: [
{
name: 'languages',
tooltip: `Desired Languages you would like to keep, language format has to be according to the iso-639-2 standard: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes\\nExample:\\n eng,dut`
tooltip: `Desired Languages you would like to keep, language format has to be according to the iso-639-2 standard: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes\\nExample:\\eng,dut`
},
{
name: 'special',
tooltip: `This is if you want a specific language to be logged to a file in your Tdarr documents folder.\nIt will add the name of the file that is being processed if this language(s) has been found.\nThe file is created the first time it finds a file with the language. \nThe languages don't have to be in "languages". \\nExample:\\n eng,dut `
tooltip: `This is if you want a specific language to be logged to a file in your Tdarr documents folder.\\nIt will add the name of the file that is being processed if this language(s) has been found.\\nThe file is created the first time it finds a file with the language.\\nThe languages don't have to be in "languages".\\nExample:\\eng,dut`
},
{
name: 'container',
tooltip: `Enter the output container of the new file.\\n Default: .mkv\\nExample:\\n.mkv`
}
]
}
}
function plugin(file, librarySettings, inputs, otherArguments) {
if (inputs.languages == "") {
if (inputs.languages == "" || inputs.special == 'undefined') {
var languages = ["eng", "en"]; //these languages should be kept, named according to ISO 639-2 language scheme
} else {
var languages = inputs.languages.split(','); //these languages should be kept, named according to ISO 639-2 language scheme
var languages = inputs.languages.toLowerCase().split(','); //these languages should be kept, named according to ISO 639-2 language scheme
}
if (inputs.special !== null) {
var special = inputs.special.split(',');
if (inputs.special == "" || inputs.special == 'undefined') {
var special = ``;
} else {
var special = inputs.special.toLowerCase().split(',');
}
if (languages.length >= special.length) {
var length = languages.length;
@ -56,6 +62,11 @@ function plugin(file, librarySettings, inputs, otherArguments) {
infoLog: 'Removing unwanted audio...\n',
};
if (inputs.container !== undefined) {
response.container = inputs.container;
console.log(`Changed container to: ` + inputs.container);
}
for (i = 0; i < file.ffProbeData.streams.length; i++) {
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") {
//check for non-english tracks
@ -83,6 +94,8 @@ function plugin(file, librarySettings, inputs, otherArguments) {
response.infoLog += `Found wanted ${languages[l]}: ${i}\n`;
wanted++;
break;
} else if (i == length-1) {
response.infoLog += `Found unwanted: ${file.ffProbeData.streams[i].tags.language}: ${i}\n`;
}
}
} else {
@ -100,7 +113,7 @@ function plugin(file, librarySettings, inputs, otherArguments) {
}
}
if (audio > wanted && wanted > 1) {
if (audio > wanted && wanted > 0) {
transcode = 1;
}

Loading…
Cancel
Save