From 8b64fd71235a4247fde55e6354e2f0839c84043e Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Sat, 24 May 2025 22:07:29 -0700 Subject: [PATCH] Bug fix for title-less sub tracks --- Tdarr_Plugin_gabehf_Prefer_Honorific_Subs.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tdarr_Plugin_gabehf_Prefer_Honorific_Subs.js b/Tdarr_Plugin_gabehf_Prefer_Honorific_Subs.js index edc9422..1b39bb5 100644 --- a/Tdarr_Plugin_gabehf_Prefer_Honorific_Subs.js +++ b/Tdarr_Plugin_gabehf_Prefer_Honorific_Subs.js @@ -38,21 +38,22 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { // Set up required variables. let ffmpegCommandInsert = ''; - let subtitleIdx = 0; + let subtitleIdx = -1; let convert = false; let honorificTrackIdx = -1; for (let i = 0; i < file.ffProbeData.streams.length; i++) { try { if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'subtitle') { - if ((["honorific", "weeb"].some((s) => file.ffProbeData.streams[i].tags.title.toLowerCase().includes(s)) || file.ffProbeData.streams[i].tags.language.toLowerCase() === 'enm') && !convert + subtitleIdx += 1; + if ((["honorific", "weeb"].some((s) => file.ffProbeData.streams[i].tags.title.toLowerCase().includes(s)) || + (file.ffProbeData.streams[i].title !== undefined && file.ffProbeData.streams[i].tags.language.toLowerCase() === 'enm')) && !convert ) { response.infoLog += `☒Subtitle with id ${subtitleIdx} detected as being honorific, setting default. \n` convert = true ffmpegCommandInsert += `-disposition:s:${subtitleIdx} default ` honorificTrackIdx = subtitleIdx } - subtitleIdx += 1; } } catch (err) { // Error