From 7be5905cf953d15d02539ad1851e02f51f065413 Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Sun, 21 Apr 2024 20:06:51 +0000 Subject: [PATCH] Add detection for subtitles with no language. Fixes error where processing halts in subtitles with no language --- Tdarr_Plugin_MM1_MrMeeb_Full_Stack.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Tdarr_Plugin_MM1_MrMeeb_Full_Stack.js b/Tdarr_Plugin_MM1_MrMeeb_Full_Stack.js index 224a02b..36c37f7 100644 --- a/Tdarr_Plugin_MM1_MrMeeb_Full_Stack.js +++ b/Tdarr_Plugin_MM1_MrMeeb_Full_Stack.js @@ -649,11 +649,11 @@ const response = { // Go through all subtitles, removing non-English/German subs and commentary subs for (let i = 0; i < file.ffProbeData.streams.length; i ++) { + console.log(file.ffProbeData.streams[i].codec_type) + // Work with subtitle streams only if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'subtitle') { - - //console.log(`Stream ${i} is a subtitle stream`); - + // Keep track of subtitle stream relative numbers try { if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle") { @@ -661,10 +661,18 @@ const response = { } } catch (err) {} - //console.log(`language = ${file.ffProbeData.streams[i].tags.language.toLowerCase()}`) + // Remove any subtitles with no language set + if (file.ffProbeData.streams[i].tags.language == undefined) { + console.log(`Stream ${i} (subtitle stream ${subIdx}) has no language. Removing.`) + response.infoLog += `Stream ${i} (subtitle stream ${subIdx}) has no language. Removing. \n` + + ffmpegSubs += ` -map -0:s:${subIdx}` + + } + // Remove any subtitles not in English or German - if ( + else if ( file.ffProbeData.streams[i].tags.language.toLowerCase() !== "eng" && file.ffProbeData.streams[i].tags.language.toLowerCase() !== "ger" ) {