From 11228bd18eb25125bd0e2ed825c72d814aa4af8d Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Fri, 21 Mar 2025 10:47:14 -0400 Subject: [PATCH] fix make_default_tracks_first duplicating streams --- README.md | 2 ++ Tdarr_Plugin_gabehf_Make_Default_Tracks_First.js | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fc7be98..a565484 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ Sets the first audio stream as default. Removes all other default audio tracks' Moves the default audio and default subtitle tracks to the first index, if they aren't there already. # Todo +- [x] Make_Default_Tracks_First will duplicate streams when more than one default exists. Make it quit instantly when the first track is already default to fix this. +- [ ] Give Anime_Subtitle_Fixer the option to set honorific tracks as default (enm language code or "honorific"/"weeb" in the title). - [ ] Create a flow plugin to check if a file both has ASS/SSA subtitles, and does not have attached fonts - [ ] Create a flow plugin to check if a file has an audio track in a certain lang - [ ] Create a flow plugin to check if a file has embedded subtitle tracks diff --git a/Tdarr_Plugin_gabehf_Make_Default_Tracks_First.js b/Tdarr_Plugin_gabehf_Make_Default_Tracks_First.js index ae572fc..6aa26c9 100644 --- a/Tdarr_Plugin_gabehf_Make_Default_Tracks_First.js +++ b/Tdarr_Plugin_gabehf_Make_Default_Tracks_First.js @@ -50,6 +50,8 @@ const details = () => ({ let processSubtitles = false; let hasDefaultSubTrack = false; let hasDefaultAudioTrack = false; + let firstAudioTrackIsDefault = false; + let firstSubTrackIsDefault = false; // [false, true, true] @@ -59,9 +61,10 @@ const details = () => ({ if (file.ffProbeData.streams[i].disposition.default === 1) { hasDefaultAudioTrack = true; if (audioIdx === 0) { + firstAudioTrackIsDefault = true response.infoLog += "☒Default audio stream is already first \n" audioFfmpegInsert += "-map 0:a " - } else { + } else if (!firstAudioTrackIsDefault) { convert = true; processAudio = true; defaultAudioIdx = audioIdx; @@ -74,9 +77,10 @@ const details = () => ({ if (file.ffProbeData.streams[i].disposition.default === 1) { hasDefaultSubTrack = true; if (subtitleIdx === 0) { + firstSubTrackIsDefault = true response.infoLog += "☒Default subtitle stream is already first \n" subtitleFfmpegInsert += "-map 0:s " - } else { + } else if (!firstSubTrackIsDefault) { convert = true; processSubtitles = true; defaultSubtitleIdx = subtitleIdx;