Updated Subtitle Downloading
@STRATOS99K This should include the things you requested. Once again if you have any issues just bring them up.
This commit is contained in:
parent
09d774c229
commit
be9e53da04
2 changed files with 13 additions and 9 deletions
14
funi.js
14
funi.js
|
|
@ -66,7 +66,7 @@ let fnTitle = '',
|
|||
fnSuffix = '',
|
||||
fnOutput = '',
|
||||
tsDlPath = false,
|
||||
stDlPath = false,
|
||||
stDlPath = undefined,
|
||||
batchDL = false;
|
||||
|
||||
// select mode
|
||||
|
|
@ -399,7 +399,10 @@ function getSubsUrl(m){
|
|||
let fpp = m[i].filePath.split('.');
|
||||
let fpe = fpp[fpp.length-1];
|
||||
if(fpe == 'vtt' && (( !m[i].languages ) || (m[i].languages[0].code === argv.subLang))){ // dfxp (TTML), srt, vtt
|
||||
return m[i].filePath;
|
||||
return {
|
||||
path: m[i].filePath,
|
||||
ext: `.${(m[i].languages ? m[i].languages[0].code : 'en')}`
|
||||
};
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -575,7 +578,7 @@ async function downloadStreams(){
|
|||
}
|
||||
|
||||
// add subs
|
||||
let subsUrl = stDlPath;
|
||||
let subsUrl = stDlPath ? stDlPath.path : false;
|
||||
let subsExt = !argv.mp4 || argv.mp4 && !argv.mks && argv.ass ? '.ass' : '.srt';
|
||||
let addSubs = argv.mks && subsUrl ? true : false;
|
||||
|
||||
|
|
@ -589,8 +592,9 @@ async function downloadStreams(){
|
|||
debug: argv.debug,
|
||||
});
|
||||
if(subsSrc.ok){
|
||||
let assData = vttConvert(subsSrc.res.body, (subsExt == '.srt' ? true : false));
|
||||
let assFile = path.join(cfg.dir.content, fnOutput) + subsExt;
|
||||
let langName = iso639.iso_639_1[argv.subLang].name;
|
||||
let assData = vttConvert(subsSrc.res.body, (subsExt == '.srt' ? true : false), langName ? langName : undefined );
|
||||
let assFile = path.join(cfg.dir.content, fnOutput) + stDlPath.ext + subsExt;
|
||||
fs.writeFileSync(assFile, assData);
|
||||
console.log('[INFO] Subtitles downloaded!');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ function loadVtt(vttStr) {
|
|||
}
|
||||
|
||||
// ass specific
|
||||
function convertToAss(vttStr){
|
||||
function convertToAss(vttStr, lang){
|
||||
let ass = [
|
||||
'\ufeff[Script Info]',
|
||||
'Title: English',
|
||||
`Title: ${lang}`,
|
||||
'ScriptType: v4.00+',
|
||||
'PlayResX: 1280',
|
||||
'PlayResY: 720',
|
||||
|
|
@ -160,7 +160,7 @@ function padTimeNum(sep, input, pad){
|
|||
}
|
||||
|
||||
// export module
|
||||
module.exports = (vttStr, toSrt) => {
|
||||
module.exports = (vttStr, toSrt, lang = 'English') => {
|
||||
const convert = toSrt ? convertToSrt : convertToAss;
|
||||
return convert(vttStr);
|
||||
return convert(vttStr, lang);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue