make subtitle fixer avoid signs&songs

main
Gabe Farrell 9 months ago
parent 305d0c5d67
commit aeb06a7d11

@ -6,8 +6,8 @@ const details = () => ({
Type: 'Subtitle',
Operation: 'Transcode',
Description:
'If no subtitles in the preferred language are made default already, this plugin sets the subtitle stream in that language as default that is not named "Forced". \\n '
+ 'This is meant to set the full subtitle stream as default for anime who use the naming scheme "English" as full, and "English Forced" for signs & songs. \\n',
'If no subtitles in the preferred language are made default already, this plugin sets the subtitle stream in that language as default that is not named "Forced" and is not Signs & Songs. \\n '
+ 'This is meant to set the full subtitle stream as default for anime that use an unnamed track for full subtitles. \\n',
Version: '1.0',
Tags: 'pre-processing,ffmpeg,subtitle only,configurable',
Inputs: [{
@ -55,12 +55,17 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
let ffmpegCommandInsert = '';
let subtitleIdx = 0;
let convert = false;
let titles_to_avoid = ['forced', 'signs & songs', 'sign', 'song']
const defaults = []; // list of tracks currently set as default
for (let i = 0; i < file.ffProbeData.streams.length; i++) {
try {
if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'subtitle') {
defaults[subtitleIdx] = file.ffProbeData.streams[i].disposition.default === 1;
if (!convert && file.ffProbeData.streams[i].disposition.default === 0 && languages.includes(file.ffProbeData.streams[i].tags.language) && !file.ffProbeData.streams[i].tags.title.toLowerCase().includes('forced')) {
if (
!convert && file.ffProbeData.streams[i].disposition.default === 0 && // not default
languages.includes(file.ffProbeData.streams[i].tags.language) && // in preferred lang
titles_to_avoid.some((s) => file.ffProbeData.streams[i].tags.title.toLowerCase().includes(s)) // not named 'forced' or 'signs & songs'
) {
convert = true;
ffmpegCommandInsert += `-disposition:s:${subtitleIdx} default `;
response.infoLog += `☒Subtitle stream 0:s:${subtitleIdx} is the first track in preferred language, not named forced, and not currently default; setting as default. \n`;

Loading…
Cancel
Save