diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c2dd8e3..0cb42ae 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,13 @@ ## Change Log +### 4.7.0 (unreleased) +- Change subtitles parser from ttml to vtt +- Improve help command +- Update modules + +#### Known issues: +- Proxy not supported + ### 4.6.1 (2020/09/19) - Update modules diff --git a/funi.js b/funi.js index 07f5df6..6a8250f 100644 --- a/funi.js +++ b/funi.js @@ -14,13 +14,13 @@ const api_host = 'https://prod-api-funimationnow.dadcdigital.com/api'; // modules extra const yaml = require('yaml'); const shlp = require('sei-helper'); -const yargs = require('yargs'); const { lookpath } = require('lookpath'); const m3u8 = require('m3u8-parsed'); const streamdl = require('hls-download'); // extra const modulesFolder = __dirname + '/modules'; +const appYargs = require(modulesFolder+'/module.app-args'); const getYamlCfg = require(modulesFolder+'/module.cfg-loader'); const getData = require(modulesFolder + '/module.getdata.js'); const vttConvert = require(modulesFolder + '/module.vttconvert'); @@ -49,77 +49,7 @@ if(!token){ } // cli -let argv = yargs - .wrap(Math.min(100)) - .usage('Usage: $0 [options]') - .help(false).version(false) - - // auth - .describe('auth','Enter auth mode') - - // search - .describe('search','Sets the show title for search') - - // params - .describe('s','Sets the show id') - .describe('e','Select episode ids (comma-separated, hyphen-sequence)') - - .describe('q','Video layer (0 is max)') - .choices('q', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) - .default('q', cfg.cli.videoLayer) - - .describe('alt','Alternative episode listing (if available)') - .boolean('alt') - - .describe('sub','Subtitles mode (Dub mode by default)') - .boolean('sub') - - .describe('simul','Forсe download simulcast version instead of uncut') - .boolean('simul') - - .describe('x','Select server') - .choices('x', [1, 2, 3, 4]) - .default('x', cfg.cli.nServer) - - .describe('novids', 'Skip download videos') - .boolean('novids') - - .describe('nosubs','Skip download subtitles for Dub (if available)') - .boolean('nosubs') - - // proxy - // .describe('proxy','http(s)/socks proxy WHATWG url (ex. https://myproxyhost:1080/)') - // .describe('proxy-auth','Colon-separated username and password for proxy') - // .describe('ssp','Ignore proxy settings for stream downloading') - // .boolean('ssp') - - .describe('mp4','Mux into mp4') - .boolean('mp4') - .default('mp4',cfg.cli.mp4mux) - .describe('mks','Add subtitles to mkv or mp4 (if available)') - .boolean('mks') - .default('mks',cfg.cli.muxSubs) - - .describe('a','Filenaming: Release group') - .default('a',cfg.cli.releaseGroup) - .describe('t','Filenaming: Series title override') - .describe('ep','Filenaming: Episode number override (ignored in batch mode)') - .describe('suffix','Filenaming: Filename suffix override (first "SIZEp" will be replaced with actual video size)') - .default('suffix',cfg.cli.fileSuffix) - - // util - .describe('nocleanup','move temporary files to trash folder instead of deleting') - .boolean('nocleanup') - .default('nocleanup',cfg.cli.noCleanUp) - - // help - .describe('h','Show this help') - .alias('h','help') - .boolean('h') - - .version(false) - .help(false) - .argv; +const argv = appYargs.appArgv(cfg.cli); // check page if(!isNaN(parseInt(argv.p, 10)) && parseInt(argv.p, 10) > 0){ @@ -149,7 +79,7 @@ else if(argv.s && !isNaN(parseInt(argv.s, 10)) && parseInt(argv.s, 10) > 0){ getShow(); } else{ - yargs.showHelp(); + appYargs.showHelp(); process.exit(); } @@ -169,7 +99,7 @@ async function auth(){ authData = JSON.parse(authData.res.body); if(authData.token){ console.log('[INFO] Authentication success, your token: %s%s\n', authData.token.slice(0,8),'*'.repeat(32)); - fs.writeFileSync(tokenFile, yaml.stringify({'token': authData.token})); + fs.writeFileSync(tokenFile + '.yml', yaml.stringify({'token': authData.token})); } else if(authData.error){ console.log('[ERROR]%s\n', authData.error); @@ -632,6 +562,10 @@ async function downloadStreams(){ return; } + if(argv.skipmux){ + return; + } + let muxTrg = path.join(cfg.dir.content, fnOutput); let tshTrg = path.join(cfg.dir.trash, fnOutput); diff --git a/modules/module.app-args.js b/modules/module.app-args.js new file mode 100644 index 0000000..0e987aa --- /dev/null +++ b/modules/module.app-args.js @@ -0,0 +1,186 @@ +const yargs = require('yargs'); + +const appArgv = (cfg, langsData) => { + // init + return yargs.parserConfiguration({ + "duplicate-arguments-array": false, + }) + // main + .wrap(Math.min(120)) // yargs.terminalWidth() + .help(false).version(false) + .usage('Usage: $0 [options]') + // auth + .option('auth', { + group: 'Authentication:', + describe: 'Enter authentication mode', + type: 'boolean', + }) + // search + .option('search', { + alias: 'f', + group: 'Search:', + describe: 'Search show ids', + type: 'string', + }) + // select show and eps + .option('s', { + group: 'Downloading:', + describe: 'Sets the show id', + type: 'number', + }) + .option('e', { + group: 'Downloading:', + describe: 'Select episode ids (comma-separated, hyphen-sequence)', + type: 'string', + }) + // quality + .option('q', { + group: 'Downloading:', + describe: 'Select video layer (0 is max)', + choices: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + default: cfg.videoLayer || 7, + type: 'number', + }) + // alt listing + .option('alt', { + group: 'Downloading:', + describe: 'Alternative episode listing (if available)', + default: cfg.altList || false, + type: 'boolean', + }) + // switch to subs + .option('sub', { + group: 'Downloading:', + describe: 'Japanese Dub with subtitles mode (English Dub mode by default)', + default: cfg.subsMode || false, + type: 'boolean', + }) + // simulcast + .option('simul', { + group: 'Downloading:', + describe: 'Force downloading simulcast ver. instead of uncut ver. (if uncut ver. available)', + default: cfg.forceSimul || false, + type: 'boolean', + }) + // server number + .option('x', { + alias: 'server', + group: 'Downloading:', + describe: 'Select server', + choices: [1, 2, 3, 4], + default: cfg.nServer || 1, + type: 'number', + }) + // skip + .option('novids', { + group: 'Downloading:', + alias: 'skipdl', + describe: 'Skip downloading video (for downloading subtitles only)', + type: 'boolean', + }) + .option('nosubs', { + group: 'Downloading:', + describe: 'Skip downloading subtitles for English Dub (if available)', + type: 'boolean', + }) + // proxy + .option('proxy', { + group: 'Proxy:', + describe: 'Set http(s)/socks proxy WHATWG url', + default: cfg.proxy || false, + hidden: true, + }) + .option('proxy-auth', { + group: 'Proxy:', + describe: 'Colon-separated username and password for proxy', + default: cfg.proxy_auth || false, + hidden: true, + }) + .option('ssp', { + group: 'Proxy:', + describe: 'Don\'t use proxy for stream and subtitles downloading', + default: cfg.proxy_ssp || false, + hidden: true, + type: 'boolean', + }) + // muxing + .option('skipmux', { + group: 'Muxing:', + describe: 'Skip muxing video and subtitles', + type: 'boolean', + }) + .option('mp4', { + group: 'Muxing:', + describe: 'Mux into mp4', + default: cfg.mp4mux || false, + type: 'boolean' + }) + .option('mks', { + group: 'Muxing:', + describe: 'Add subtitles to mkv/mp4 (if available)', + default: cfg.muxSubs || false, + type: 'boolean' + }) + // filenaming + .option('a', { + alias: 'grouptag', + group: 'Filename Template:', + describe: 'Release group', + default: cfg.releaseGroup || 'Funimation', + type: 'string' + }) + .option('t', { + alias: 'title', + group: 'Filename Template:', + describe: 'Series title override', + type: 'string' + }) + .option('ep', { + group: 'Filename Template:', + describe: 'Episode number override (ignored in batch mode)', + type: 'string' + }) + .option('suffix', { + group: 'Filename Template:', + describe: 'Filename suffix override (first "SIZEp" will be replaced with actual video size)', + default: cfg.fileSuffix || 'SIZEp', + type: 'string' + }) + // util + .option('nocleanup', { + group: 'Utilities:', + describe: 'Move temporary files to trash folder instead of deleting', + default: cfg.noCleanUp || false, + type: 'boolean' + }) + .option('notrashfolder', { + implies: ['nocleanup'], + group: 'Utilities:', + describe: 'Don\'t move temporary files to trash folder (Used with --nocleanup)', + default: cfg.noTrashFolder || false, + type: 'boolean' + }) + // help + .option('help', { + alias: 'h', + group: 'Help:', + describe: 'Show this help', + type: 'boolean' + }) + // usage + .example([ + ['$0 --search "My Hero"', 'search "My Hero" in title'], + ['$0 -s 124389 -e 1,2,3', 'download episodes 1-3 from show with id 124389'], + ['$0 -s 124389 -e 1-3,2-7,s1-2', 'download episodes 1-7 and "S"-episodes 1-2 from show with id 124389'], + ]) + + // -- + .argv; +} + +const showHelp = yargs.showHelp; + +module.exports = { + appArgv, + showHelp +}; diff --git a/package.json b/package.json index 5882695..61e9428 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "funimation-downloader-nx", "short_name": "funi", - "version": "4.7.0-beta.1", + "version": "4.7.0-beta.2", "description": "Download videos from Funimation via cli.", "keywords": [ "download",