diff --git a/hidive.ts b/hidive.ts index e994290..1282c95 100644 --- a/hidive.ts +++ b/hidive.ts @@ -1317,22 +1317,8 @@ export default class Hidive implements ServiceClass { const getVttContent = await this.req.getData(sub.url); if (getVttContent.ok && getVttContent.res) { console.info(`Subtitle Downloaded: ${sub.url}`); - const cssLines = []; - const cssGroups = getVttContent.res.body.matchAll(/::cue(?:.(.+)\))?{([^}]+)}/g); - let defaultCss = ''; - for (const cssGroup of cssGroups) { - //Below code will bulldoze defined sizes for custom ones - /*if (!options.originalFontSize) { - cssGroup[2] = cssGroup[2].replace(/( font-size:.+?;)/g, '').replace(/(font-size:.+?;)/g, ''); - }*/ - if (cssGroup[1]) { - cssLines.push(`${cssGroup[1]}{${defaultCss}${cssGroup[2]}}`); - } else { - defaultCss = cssGroup[2]; - } - } //vttConvert(getVttContent.res.body, false, subLang.name, fontSize); - const sBody = vtt(undefined, chosenFontSize, getVttContent.res.body, cssLines.join('\r\n'), subsMargin, options.fontName); + const sBody = vtt(undefined, chosenFontSize, getVttContent.res.body, '', subsMargin, options.fontName); sxData.title = `${subLang.language} / ${sxData.title}`; sxData.fonts = fontsData.assFonts(sBody) as Font[]; fs.writeFileSync(sxData.path, sBody); diff --git a/modules/module.vtt2ass.ts b/modules/module.vtt2ass.ts index 004f08b..9c5f7ea 100644 --- a/modules/module.vtt2ass.ts +++ b/modules/module.vtt2ass.ts @@ -410,6 +410,23 @@ function vtt(group: string | undefined, xFontSize: number | undefined, vttStr: s fontSize = xFontSize && xFontSize > 0 ? xFontSize : 34; // 1em to pix tmMrg = timeMargin ? timeMargin : 0; // rFont = replaceFont ? replaceFont : rFont; + if (vttStr.match(/::cue(?:.(.+)\))?{([^}]+)}/g)) { + const cssLines = []; + let defaultCss = ''; + const cssGroups = vttStr.matchAll(/::cue(?:.(.+)\))?{([^}]+)}/g); + for (const cssGroup of cssGroups) { + //Below code will bulldoze defined sizes for custom ones + /*if (!options.originalFontSize) { + cssGroup[2] = cssGroup[2].replace(/( font-size:.+?;)/g, '').replace(/(font-size:.+?;)/g, ''); + }*/ + if (cssGroup[1]) { + cssLines.push(`${cssGroup[1]}{${defaultCss}${cssGroup[2]}}`); + } else { + defaultCss = cssGroup[2]; + } + } + cssStr += cssLines.join('\r\n'); + } return convert( loadCSS(cssStr), loadVTT(vttStr)