mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 15:38:19 -07:00
Latest updates to Keep_Preferred_Audio
This commit is contained in:
parent
333ade3cad
commit
4c5bf97dd8
1 changed files with 23 additions and 13 deletions
|
|
@ -6,35 +6,38 @@ function details() {
|
|||
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_Keep_Preferred_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_Remove_non_English_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\nIt could look like: "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.\nIt could look like: "eng","dut"\nThe languages don't have to be in "languages".`
|
||||
}
|
||||
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 !== "") {
|
||||
var special = inputs.special.split(',');
|
||||
} else {
|
||||
if (inputs.special == "" || inputs.special == 'undefined') {
|
||||
var special = ``;
|
||||
} else {
|
||||
var special = inputs.special.toLowerCase().split(',');
|
||||
}
|
||||
if (languages.length >= special.length) {
|
||||
var length = languages.length;
|
||||
|
|
@ -59,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
|
||||
|
|
@ -86,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 {
|
||||
|
|
@ -103,7 +113,7 @@ function plugin(file, librarySettings, inputs, otherArguments) {
|
|||
}
|
||||
}
|
||||
|
||||
if (audio > wanted && wanted > 1) {
|
||||
if (audio > wanted && wanted > 0) {
|
||||
transcode = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue