From 1a39c64447ade369cdb3a69d5d8d17edf42b1f01 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Fri, 22 Nov 2019 12:04:20 +0000 Subject: [PATCH] New --- ...rr_Plugin_sdd3_Remove_Commentary_Tracks.js | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 Community/Tdarr_Plugin_sdd3_Remove_Commentary_Tracks.js diff --git a/Community/Tdarr_Plugin_sdd3_Remove_Commentary_Tracks.js b/Community/Tdarr_Plugin_sdd3_Remove_Commentary_Tracks.js new file mode 100644 index 0000000..4be5f40 --- /dev/null +++ b/Community/Tdarr_Plugin_sdd3_Remove_Commentary_Tracks.js @@ -0,0 +1,94 @@ + + + +function details() { + + return { + id: "Tdarr_Plugin_sdd3_Remove_Commentary_Tracks", + Name: "Remove video commentary tracks", + Type: "Video", + Operation:"Remux", + Description: `If commentary tracks are detected, they will be removed. \n\n`, + Version: "1.00", + Link: "" + } + +} + +function plugin(file) { + + + //Must return this object + + var response = { + + processFile: false, + preset: '', + container: '.mp4', + handBrakeMode: false, + FFmpegMode: false, + reQueueAfter: false, + infoLog: '', + + } + + if (file.fileMedium !== "video") { + response.processFile = false + response.infoLog += "☒File is not a video! \n" + return response + } else { + response.infoLog += "☑File is a video! \n" + } + + + + var audioIdx = -1 + var hasCommentaryTrack = false + + + for (var i = 0; i < file.ffProbeData.streams.length; i++) { + + //keep track of audio streams for when removing commentary track + try { + if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") { + audioIdx++ + } + } catch (err) { } + + + //check if commentary track and passing audio stream number + try { + if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" && file.ffProbeData.streams[i].tags.title.toLowerCase().includes("commentary")) { + ffmpegCommandInsert += ` -map -0:a:${audioIdx}` + hasCommentaryTrack = true + + } + } catch (err) { } + + } + + if (hasCommentaryTrack === true) { + + response.processFile = true; + response.preset = `, -map 0 ${ffmpegCommandInsert} -c copy` + response.container = '.' + file.container + response.handBrakeMode = false + response.FFmpegMode = true + response.reQueueAfter = true; + response.infoLog += "☒File contains commentary tracks. Removing! \n" + return response + + } else { + + response.infoLog += "☑File doesn't contain commentary tracks! \n" + + } + + response.processFile = false + response.infoLog += "☑File meets conditions! \n" + return response +} + +module.exports.details = details; +module.exports.plugin = plugin; +