diff --git a/src/batch.ts b/src/batch.ts index 9639684..26cf1e0 100644 --- a/src/batch.ts +++ b/src/batch.ts @@ -187,5 +187,6 @@ function parse(args: string[]): IConfigLine '1080') .option('-g, --rebuildcrp', 'Rebuild the crpersistant file.') .option('-b, --batch ', 'Batch file', 'CrunchyRoll.txt') + .option('--verbose', 'Make tool verbose') .parse(args); } diff --git a/src/episode.ts b/src/episode.ts index 5950470..9250055 100644 --- a/src/episode.ts +++ b/src/episode.ts @@ -141,7 +141,7 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d const isSubtited = Boolean(player.subtitle); log.dispEpisode(fileName, 'Merging...', false); - video.merge(config, isSubtited, player.video.file, filePath, player.video.mode, (errVM) => + video.merge(config, isSubtited, player.video.file, filePath, player.video.mode, config.verbose, (errVM) => { if (errVM) { @@ -198,11 +198,11 @@ function downloadSubtitle(config: IConfig, player: IEpisodePlayer, filePath: str /** * Streams the video to disk. */ -function downloadVideo(ignored/*config*/: IConfig, page: IEpisodePage, player: IEpisodePlayer, +function downloadVideo(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, filePath: string, done: (err: Error) => void) { video.stream(player.video.host, player.video.file, page.swf, filePath, - path.extname(player.video.file), player.video.mode, done); + path.extname(player.video.file), player.video.mode, config.verbose, done); } /** diff --git a/src/interface/IConfig.d.ts b/src/interface/IConfig.d.ts index ff75dc0..acda699 100644 --- a/src/interface/IConfig.d.ts +++ b/src/interface/IConfig.d.ts @@ -19,4 +19,5 @@ interface IConfig { video_quality?: string; rebuildcrp?: boolean; batch?: string; + verbose?: boolean; } diff --git a/src/video/merge.ts b/src/video/merge.ts index 25c2c8d..9c59d25 100644 --- a/src/video/merge.ts +++ b/src/video/merge.ts @@ -10,10 +10,11 @@ import subtitle from '../subtitle/index'; * Merges the subtitle and video files into a Matroska Multimedia Container. */ export default function(config: IConfig, isSubtitled: boolean, rtmpInputPath: string, filePath: string, - streamMode: string, done: (err: Error) => void) + streamMode: string, verbose: boolean, done: (err: Error) => void) { const subtitlePath = filePath + '.' + (subtitle.formats[config.format] ? config.format : 'ass'); let videoPath = filePath; + let cp; if (streamMode === 'RTMP') { @@ -24,7 +25,7 @@ export default function(config: IConfig, isSubtitled: boolean, rtmpInputPath: st videoPath += '.mp4'; } - childProcess.exec(command() + ' ' + + cp = childProcess.exec(command() + ' ' + '-o "' + filePath + '.mkv" ' + '"' + videoPath + '" ' + (isSubtitled ? '"' + subtitlePath + '"' : ''), { @@ -46,6 +47,13 @@ export default function(config: IConfig, isSubtitled: boolean, rtmpInputPath: st done(null); }); }); + + if (verbose === true) + { + cp.stdin.pipe(process.stdin); + cp.stdout.pipe(process.stdout); + cp.stderr.pipe(process.stderr); + } } /** diff --git a/src/video/stream.ts b/src/video/stream.ts index 77d498a..f10da5b 100644 --- a/src/video/stream.ts +++ b/src/video/stream.ts @@ -9,33 +9,41 @@ import log = require('../log'); * Streams the video to disk. */ export default function(rtmpUrl: string, rtmpInputPath: string, swfUrl: string, filePath: string, - fileExt: string, mode: string, done: (err: Error) => void) + fileExt: string, mode: string, verbose: boolean, done: (err: Error) => void) { + let cp; + let cmd; if (mode === 'RTMP') { - childProcess.exec(command('rtmpdump') + ' ' + + cmd = command('rtmpdump') + ' ' + '-r "' + rtmpUrl + '" ' + '-y "' + rtmpInputPath + '" ' + '-W "' + swfUrl + '" ' + - '-o "' + filePath + fileExt + '"', { - maxBuffer: Infinity, - }, done); + '-o "' + filePath + fileExt + '"'; } else if (mode === 'HLS') { - const cmd = command('ffmpeg') + ' ' + + cmd = command('ffmpeg') + ' ' + '-i "' + rtmpInputPath + '" ' + '-c copy -bsf:a aac_adtstoasc ' + '"' + filePath + '.mp4"'; - childProcess.exec(cmd, - { - maxBuffer: Infinity, - }, done); } else { log.error('No such mode: ' + mode); } + + cp = childProcess.exec(cmd, + { + maxBuffer: Infinity, + }, done); + + if (verbose === true) + { + cp.stdin.pipe(process.stdin); + cp.stdout.pipe(process.stdout); + cp.stderr.pipe(process.stderr); + } } /**