[CR] Improve Captions support

Renames what was previously called CC to `Signs`.

Also prevents a possible collision where not all subs would be downloaded
This commit is contained in:
AnimeDL 2024-02-06 19:46:14 -08:00
parent 66e1ee5702
commit d2b4adf09b
3 changed files with 7 additions and 3 deletions

View file

@ -97,6 +97,7 @@ export type DownloadedMedia = {
path: string
} | ({
type: 'Subtitle',
signs: boolean,
cc: boolean
} & sxItem )

View file

@ -1972,7 +1972,7 @@ export default class Crunchy implements ServiceClass {
if (!fs.existsSync(path.join(isAbsolut ? '' : this.cfg.dir.content, ...arr.slice(0, ind), val)))
fs.mkdirSync(path.join(isAbsolut ? '' : this.cfg.dir.content, ...arr.slice(0, ind), val));
});
if (files.some(a => a.type === 'Subtitle' && (a.language.cr_locale == langItem.cr_locale || a.language.locale == langItem.locale) && a.cc === isCC))
if (files.some(a => a.type === 'Subtitle' && (a.language.cr_locale == langItem.cr_locale || a.language.locale == langItem.locale) && a.cc === isCC && a.signs === isSigns))
continue;
if(options.dlsubs.includes('all') || options.dlsubs.includes(langItem.locale)){
const subsAssReq = await this.req.getData(subsItem.url);
@ -1999,6 +1999,7 @@ export default class Crunchy implements ServiceClass {
type: 'Subtitle',
...sxData as sxItem,
cc: isCC,
signs: isSigns,
});
}
else{
@ -2061,6 +2062,7 @@ export default class Crunchy implements ServiceClass {
file: a.path,
language: a.language,
closedCaption: a.cc,
signs: a.signs,
};
}),
simul: false,

View file

@ -21,6 +21,7 @@ export type SubtitleInput = {
language: LanguageItem,
file: string,
closedCaption?: boolean,
signs?: boolean,
delay?: number
}
@ -182,7 +183,7 @@ class Merger {
'-c:a copy',
this.options.output.split('.').pop()?.toLowerCase() === 'mp4' ? '-c:s mov_text' : '-c:s ass',
...this.options.subtitles.map((sub, subindex) => `-metadata:s:s:${subindex} title="${
(sub.language.language || sub.language.name) + `${sub.closedCaption === true ? ` ${this.options.ccTag}` : ''}`
(sub.language.language || sub.language.name) + `${sub.closedCaption === true ? ` ${this.options.ccTag}` : ''}` + `${sub.signs === true ? ' Signs' : ''}`
}" -metadata:s:s:${subindex} language=${sub.language.code}`)
);
args.push(...this.options.options.ffmpeg);
@ -285,7 +286,7 @@ class Merger {
`--sync 0:-${Math.ceil(subObj.delay*1000)}`
);
}
args.push('--track-name', `0:"${(subObj.language.language || subObj.language.name) + `${subObj.closedCaption === true ? ` ${this.options.ccTag}` : ''}`}"`);
args.push('--track-name', `0:"${(subObj.language.language || subObj.language.name) + `${subObj.closedCaption === true ? ` ${this.options.ccTag}` : ''}` + `${subObj.signs === true ? ' Signs' : ''}`}"`);
args.push('--language', `0:"${subObj.language.code}"`);
//TODO: look into making Closed Caption default if it's the only sub of the default language downloaded
if (this.options.defaults.sub.code === subObj.language.code && !subObj.closedCaption) {