From 7be22ec132881302d9b3cc92fcfe6595bbd20fd1 Mon Sep 17 00:00:00 2001 From: AnimeDL Date: Mon, 29 Jan 2024 22:45:36 -0800 Subject: [PATCH] [CR] Fixes subtitles when directory doesn't exist Now creates the directory before making the files, similar to how videos work. --- crunchy.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crunchy.ts b/crunchy.ts index cb49aca..e03c95c 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -1832,6 +1832,12 @@ export default class Crunchy implements ServiceClass { const isCC = langItem.code === audDub; sxData.file = langsData.subsFile(fileName as string, subsIndex, langItem, isCC, options.ccTag); sxData.path = path.join(this.cfg.dir.content, sxData.file); + const split = sxData.path.split(path.sep).slice(0, -1); + split.forEach((val, ind, arr) => { + const isAbsolut = path.isAbsolute(sxData.path as string); + 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)) continue; if(options.dlsubs.includes('all') || options.dlsubs.includes(langItem.locale)){