Subtitle font size support

This commit is contained in:
Izuco 2021-05-25 19:07:16 +02:00
parent 85341e9b91
commit b2fb0e7260
3 changed files with 13 additions and 7 deletions

View file

@ -395,7 +395,7 @@ function getSubsUrl(m){
'esLA': 'Spanish (Latin Am)', 'esLA': 'Spanish (Latin Am)',
'ptBR': 'Portuguese (Brazil)' 'ptBR': 'Portuguese (Brazil)'
}; };
let subLangAvailable = m.some(a => { let subLangAvailable = m.some(a => {
return a.ext == 'vtt' && a.language === subType[subLang] return a.ext == 'vtt' && a.language === subType[subLang]
}); });
@ -605,7 +605,7 @@ async function downloadStreams(){
debug: argv.debug, debug: argv.debug,
}); });
if(subsSrc.ok){ 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; subFile = path.join(cfg.dir.content, fnOutput) + stDlPath.ext + subsExt;
subTrashFile = path.join(cfg.dir.trash, fnOutput) + stDlPath.ext + subsExt; subTrashFile = path.join(cfg.dir.trash, fnOutput) + stDlPath.ext + subsExt;
fs.writeFileSync(subFile, assData); fs.writeFileSync(subFile, assData);

View file

@ -81,6 +81,12 @@ const appArgv = (cfg) => {
choices: [ 'enUS', 'esLA', 'ptBR' ], choices: [ 'enUS', 'esLA', 'ptBR' ],
type: 'string' type: 'string'
}) })
.option('fontSize', {
group: 'Downloading:',
describe: 'Used to set the fontsize of the subtitles',
default: cfg.fontSize || 55,
type: 'number'
})
// simulcast // simulcast
.option('simul', { .option('simul', {
group: 'Downloading:', group: 'Downloading:',

View file

@ -35,7 +35,7 @@ function loadVtt(vttStr) {
} }
// ass specific // ass specific
function convertToAss(vttStr, lang){ function convertToAss(vttStr, lang, fontSize){
let ass = [ let ass = [
'\ufeff[Script Info]', '\ufeff[Script Info]',
`Title: ${lang}`, `Title: ${lang}`,
@ -49,8 +49,8 @@ function convertToAss(vttStr, lang){
'Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, ' 'Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, '
+ 'Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, ' + 'Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, '
+ 'BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding', + '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: 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,55,&H00FFFFFF,&H000000FF,&H00020713,&H00000000,0,0,0,0,100,100,0,0,1,3,0,8,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]', '[Events]',
'Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text', 'Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text',
@ -160,7 +160,7 @@ function padTimeNum(sep, input, pad){
} }
// export module // export module
module.exports = (vttStr, toSrt, lang = 'English') => { module.exports = (vttStr, toSrt, lang = 'English', fontSize) => {
const convert = toSrt ? convertToSrt : convertToAss; const convert = toSrt ? convertToSrt : convertToAss;
return convert(vttStr, lang); return convert(vttStr, lang, fontSize);
}; };