From e3c5b3aa1fa6bce0f03e9e7eb5fe7314ae3cca22 Mon Sep 17 00:00:00 2001 From: f16v1per Date: Wed, 8 Feb 2023 18:36:20 -0500 Subject: [PATCH 1/2] Only remove audio track once --- Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js b/Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js index 32bf0d2..ee53786 100644 --- a/Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js +++ b/Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js @@ -78,7 +78,7 @@ const details = () => ({ \\nDo NOT use this with mp4, as mp4 does not support title tags. \\nExample:\\n true - + \\nExample:\\n false`, }, @@ -127,6 +127,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { ).length; for (let i = 0; i < file.ffProbeData.streams.length; i++) { + let removeTrack = false; // Catch error here incase the language metadata is completely missing. try { // Check if stream is audio @@ -137,12 +138,10 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { file.ffProbeData.streams[i].tags.language.toLowerCase(), ) === -1 ) { - audioStreamsRemoved += 1; - ffmpegCommandInsert += `-map -0:a:${audioIdx} `; response.infoLog += `☒Audio stream 0:a:${audioIdx} has unwanted language tag ${file.ffProbeData.streams[ i ].tags.language.toLowerCase()}, removing. \n`; - convert = true; + removeTrack = true; } } catch (err) { // Error @@ -165,15 +164,18 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { .includes('description') || file.ffProbeData.streams[i].tags.title.toLowerCase().includes('sdh')) ) { - audioStreamsRemoved += 1; - ffmpegCommandInsert += `-map -0:a:${audioIdx} `; + removeTrack = true; response.infoLog += `☒Audio stream 0:a:${audioIdx} detected as being descriptive, removing. \n`; - convert = true; } } catch (err) { // Error } + if (removeTrack){ + audioStreamsRemoved += 1; + ffmpegCommandInsert += `-map -0:a:${audioIdx} `; + convert = true; + } // Check if inputs.tag_language has something entered // (Entered means user actually wants something to happen, empty would disable this) // AND checks that stream is audio. From 7906350dbfa1f6bdd748cea3440ab5a80a29e54c Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Thu, 16 Feb 2023 05:28:12 +0000 Subject: [PATCH 2/2] Fix lint errors --- Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js b/Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js index ee53786..f2e6fc9 100644 --- a/Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js +++ b/Community/Tdarr_Plugin_MC93_Migz3CleanAudio.js @@ -171,10 +171,10 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { // Error } - if (removeTrack){ - audioStreamsRemoved += 1; - ffmpegCommandInsert += `-map -0:a:${audioIdx} `; - convert = true; + if (removeTrack) { + audioStreamsRemoved += 1; + ffmpegCommandInsert += `-map -0:a:${audioIdx} `; + convert = true; } // Check if inputs.tag_language has something entered // (Entered means user actually wants something to happen, empty would disable this)