UNPKG

crunchy

Version:

Crunchy is a fork of Crunchyroll.js, capable of downloading anime episodes from the popular CrunchyRoll streaming service.

51 lines 1.5 kB
'use strict'; exports.__esModule = true; var childProcess = require("child_process"); var os = require("os"); var path = require("path"); var my_request = require("../my_request"); var log = require("../log"); /** * Streams the video to disk. */ function default_1(rtmpUrl, rtmpInputPath, swfUrl, filePath, fileExt, mode, verbose, done) { var cp; var cmd; if (mode === 'RTMP') { cmd = command('rtmpdump') + ' ' + '-r "' + rtmpUrl + '" ' + '-y "' + rtmpInputPath + '" ' + '-W "' + swfUrl + '" ' + '-o "' + filePath + fileExt + '"'; } else if (mode === 'HLS') { cmd = command('ffmpeg') + ' ' + '-user_agent "' + my_request.getUserAgent() + '" ' + '-y -xerror -discard none ' + '-i "' + rtmpInputPath + '" ' + '-c copy -bsf:a aac_adtstoasc ' + '"' + filePath + '.mp4"'; } 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); } } exports["default"] = default_1; /** * Determines the command for the operating system. */ function command(exe) { if (os.platform() !== 'win32') { return exe; } return '"' + path.join(__dirname, '../../bin/' + exe + '.exe') + '"'; } //# sourceMappingURL=stream.js.map