Update Tdarr_Plugin_x7ac_Remove_Closed_Captions.js

This commit is contained in:
Will Segatto 2021-11-13 15:10:21 -03:00
parent 1adf2a2a91
commit 25b67c2cfa

View file

@ -1,4 +1,3 @@
/* eslint-disable */
function details() { function details() {
return { return {
id: "Tdarr_Plugin_x7ac_Remove_Closed_Captions", id: "Tdarr_Plugin_x7ac_Remove_Closed_Captions",
@ -16,46 +15,39 @@ function details() {
} }
function plugin(file) { function plugin(file) {
//Must return this object const response = {
var response = {
processFile: false, processFile: false,
preset: "", preset: ',-map 0 -codec copy -bsf:v "filter_units=remove_types=6"',
container: ".mp4", container: "." + file.container,
handBrakeMode: false, handBrakeMode: false,
FFmpegMode: false, FFmpegMode: true,
reQueueAfter: true, reQueueAfter: true,
infoLog: "", infoLog: "",
}; };
if (file.fileMedium !== "video") { if (file.fileMedium !== "video") {
console.log("File is not video");
response.infoLog += "☒File is not video \n"; response.infoLog += "☒File is not video \n";
response.processFile = false;
return response; return response;
} else { }
if (file.hasClosedCaptions === true) {
response = {
processFile: true,
preset: ',-map 0 -codec copy -bsf:v "filter_units=remove_types=6"',
container: "." + file.container,
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: "☒This file has closed captions \n",
};
return response; //Check if Closed Captions are set at file level
} else { if (file.hasClosedCaptions) {
response.infoLog += response.processFile = true;
"☑Closed captions have not been detected on this file \n"; response.infoLog += '☒This file has closed captions \n';
response.processFile = false; return response;
}
return response; //If not, check for Closed Captions in the streams
for (const stream in file.ffProbeData.streams) {
if (stream.closed_captions) {
response.processFile = true;
} }
} }
response.infoLog +=
response.processFile ? '☒This file has burnt closed captions \n'
: '☑Closed captions have not been detected on this file \n';
return response;
} }
module.exports.details = details; module.exports.details = details;