From b2fb0e7260e19e9e32e11b67f2dc3752474fd8de Mon Sep 17 00:00:00 2001 From: Izuco <57068530+izu-co@users.noreply.github.com> Date: Tue, 25 May 2021 19:07:16 +0200 Subject: [PATCH] Subtitle font size support --- funi.js | 4 ++-- modules/module.app-args.js | 6 ++++++ modules/module.vttconvert.js | 10 +++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/funi.js b/funi.js index b603dfd..685dc54 100644 --- a/funi.js +++ b/funi.js @@ -395,7 +395,7 @@ function getSubsUrl(m){ 'esLA': 'Spanish (Latin Am)', 'ptBR': 'Portuguese (Brazil)' }; - + let subLangAvailable = m.some(a => { return a.ext == 'vtt' && a.language === subType[subLang] }); @@ -605,7 +605,7 @@ async function downloadStreams(){ debug: argv.debug, }); if(subsSrc.ok){ - let assData = vttConvert(subsSrc.res.body, (subsExt == '.srt' ? true : false), stDlPath.langName ); + let assData = vttConvert(subsSrc.res.body, (subsExt == '.srt' ? true : false), stDlPath.langName, argv.fontSize); subFile = path.join(cfg.dir.content, fnOutput) + stDlPath.ext + subsExt; subTrashFile = path.join(cfg.dir.trash, fnOutput) + stDlPath.ext + subsExt; fs.writeFileSync(subFile, assData); diff --git a/modules/module.app-args.js b/modules/module.app-args.js index 5c4d11b..a0b4925 100644 --- a/modules/module.app-args.js +++ b/modules/module.app-args.js @@ -81,6 +81,12 @@ const appArgv = (cfg) => { choices: [ 'enUS', 'esLA', 'ptBR' ], type: 'string' }) + .option('fontSize', { + group: 'Downloading:', + describe: 'Used to set the fontsize of the subtitles', + default: cfg.fontSize || 55, + type: 'number' + }) // simulcast .option('simul', { group: 'Downloading:', diff --git a/modules/module.vttconvert.js b/modules/module.vttconvert.js index 9af46f7..dcdfba9 100644 --- a/modules/module.vttconvert.js +++ b/modules/module.vttconvert.js @@ -35,7 +35,7 @@ function loadVtt(vttStr) { } // ass specific -function convertToAss(vttStr, lang){ +function convertToAss(vttStr, lang, fontSize){ let ass = [ '\ufeff[Script Info]', `Title: ${lang}`, @@ -49,8 +49,8 @@ function convertToAss(vttStr, lang){ 'Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, ' + 'Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, ' + 'BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding', - 'Style: Main,Noto Sans,55,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,0,0,0,0,100,100,0,0,1,3,0,2,10,10,10,1', - 'Style: MainTop,Noto Sans,55,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,0,0,0,0,100,100,0,0,1,3,0,8,10,10,10,1', + `Style: Main,Noto Sans,${fontSize},&H00FFFFFF,&H000000FF,&H00020713,&H00000000,0,0,0,0,100,100,0,0,1,3,0,2,10,10,10,1`, + `Style: MainTop,Noto Sans,${fontSize},&H00FFFFFF,&H000000FF,&H00020713,&H00000000,0,0,0,0,100,100,0,0,1,3,0,8,10,10,10`, '', '[Events]', 'Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text', @@ -160,7 +160,7 @@ function padTimeNum(sep, input, pad){ } // export module -module.exports = (vttStr, toSrt, lang = 'English') => { +module.exports = (vttStr, toSrt, lang = 'English', fontSize) => { const convert = toSrt ? convertToSrt : convertToAss; - return convert(vttStr, lang); + return convert(vttStr, lang, fontSize); };