Set funimation font name

This commit is contained in:
Izuco 2021-11-06 14:06:43 +01:00
parent 0184dcbd04
commit aa40658599
No known key found for this signature in database
GPG key ID: 318460063D70949F
4 changed files with 13 additions and 7 deletions

View file

@ -700,7 +700,7 @@ async function downloadStreams(){
debug: argv.debug,
});
if(subsSrc.ok && subsSrc.res){
const assData = vttConvert(subsSrc.res.body, (subsExt == '.srt' ? true : false), subObject.langName, argv.fontSize);
const assData = vttConvert(subsSrc.res.body, (subsExt == '.srt' ? true : false), subObject.langName, argv.fontSize, argv.fontName);
subObject.file = path.join(cfg.dir.content, ...fnOutput.slice(0, -1), `${fnOutput.slice(-1)}.subtitle${subObject.ext}${subsExt}`);
fs.writeFileSync(subObject.file, assData);
}

View file

@ -290,6 +290,12 @@ const appArgv = (cfg: {
type: 'boolean',
default: false
})
.option('fontName', {
group: groups.fonts,
describe: 'Set the font to use in subtiles (Funi only)',
type: 'string',
default: parseDefault<string|undefined>('fontName', undefined)
})
.parseSync();
return argv;
};

View file

@ -43,7 +43,7 @@ function loadVtt(vttStr: string) {
}
// ass specific
function convertToAss(vttStr: string, lang: string, fontSize: number){
function convertToAss(vttStr: string, lang: string, fontSize: number, fontName?: string){
let ass = [
'\ufeff[Script Info]',
`Title: ${lang}`,
@ -57,8 +57,8 @@ function convertToAss(vttStr: string, lang: string, fontSize: number){
'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,${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`,
`Style: Main,${fontName || '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,${fontName || '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',
@ -167,8 +167,8 @@ function padTimeNum(sep: string, input: string|number , pad:number){
}
// export module
const _default = (vttStr: string, toSrt: boolean, lang = 'English', fontSize: number) => {
const _default = (vttStr: string, toSrt: boolean, lang = 'English', fontSize: number, fontName?: string) => {
const convert = toSrt ? convertToSrt : convertToAss;
return convert(vttStr, lang, fontSize);
return convert(vttStr, lang, fontSize, fontName);
};
export default _default;

View file

@ -1,7 +1,7 @@
{
"name": "multi-downloader-nx",
"short_name": "aniDL",
"version": "1.0.2",
"version": "1.0.3",
"description": "Download videos from Funimation or Crunchyroll via cli",
"keywords": [
"download",