Bug fix for title-less sub tracks

main
Gabe Farrell 7 months ago
parent 2ff516f2f0
commit 8b64fd7123

@ -38,21 +38,22 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
// Set up required variables. // Set up required variables.
let ffmpegCommandInsert = ''; let ffmpegCommandInsert = '';
let subtitleIdx = 0; let subtitleIdx = -1;
let convert = false; let convert = false;
let honorificTrackIdx = -1; let honorificTrackIdx = -1;
for (let i = 0; i < file.ffProbeData.streams.length; i++) { for (let i = 0; i < file.ffProbeData.streams.length; i++) {
try { try {
if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'subtitle') { 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` response.infoLog += `☒Subtitle with id ${subtitleIdx} detected as being honorific, setting default. \n`
convert = true convert = true
ffmpegCommandInsert += `-disposition:s:${subtitleIdx} default ` ffmpegCommandInsert += `-disposition:s:${subtitleIdx} default `
honorificTrackIdx = subtitleIdx honorificTrackIdx = subtitleIdx
} }
subtitleIdx += 1;
} }
} catch (err) { } catch (err) {
// Error // Error

Loading…
Cancel
Save