From d2b4adf09baf435fc274ae5a64ac5b69309c8867 Mon Sep 17 00:00:00 2001 From: AnimeDL Date: Tue, 6 Feb 2024 19:46:14 -0800 Subject: [PATCH] [CR] Improve Captions support Renames what was previously called CC to `Signs`. Also prevents a possible collision where not all subs would be downloaded --- @types/crunchyTypes.d.ts | 1 + crunchy.ts | 4 +++- modules/module.merger.ts | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/@types/crunchyTypes.d.ts b/@types/crunchyTypes.d.ts index 7de374e..2ffa9c7 100644 --- a/@types/crunchyTypes.d.ts +++ b/@types/crunchyTypes.d.ts @@ -97,6 +97,7 @@ export type DownloadedMedia = { path: string } | ({ type: 'Subtitle', + signs: boolean, cc: boolean } & sxItem ) diff --git a/crunchy.ts b/crunchy.ts index edc431b..2f685fc 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -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, diff --git a/modules/module.merger.ts b/modules/module.merger.ts index 989667f..e3d8b56 100644 --- a/modules/module.merger.ts +++ b/modules/module.merger.ts @@ -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) {