diff --git a/endpoints/videornp.js b/endpoints/videornp.js index b66cc79..650ce9d 100644 --- a/endpoints/videornp.js +++ b/endpoints/videornp.js @@ -17,7 +17,7 @@ function init(req, res, Request) { return; } - if (_.includes(req.body.revisaomanual, "SIM", "NAO")) { + if (_.includes(req.body.revisaomanual.toUpperCase(), "SIM", "NAO")) { res.send(500, parameters.errorMessage('O valor do parâmetro revisaomanual é inválido.')); return; } @@ -120,13 +120,22 @@ function process(req, res, Request) { function downloadAndMoveFiles(folder, req, locals, callback) { async.parallel([ - // Download video function(callback) { - files.downloadAndMoveVideo(folder, req, locals, callback); + if (_.isEmpty(req.body.legenda_url)) { // video_url present + // Download video + files.downloadAndMoveVideo(folder, req, locals, callback); + } else { + // Download subtitle + files.downloadAndMoveSubtitle(folder, req, locals, callback); + } + } ], function(err) { - console.log("=== Video baixado"); - + if (_.isEmpty(req.body.legenda_url)) { // video_url present + console.log("== Video baixado"); + } else { + console.log("== Legenda baixada"); + } // Callback chamado depois de todas as tarefas // Se tiver erro, vai passar para cima callback(err); diff --git a/helpers/queue.js b/helpers/queue.js index e0a075c..efd8818 100644 --- a/helpers/queue.js +++ b/helpers/queue.js @@ -2,16 +2,12 @@ var exec = require('child_process').exec, child; exports.exec_command_line = function (command_line, done) { - // child = exec(command_line, function(err, stdout, stderr) { - child = exec("curl -O http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_20mb.mp4", function(err, stdout, stderr) { + child = exec(command_line, function(err, stdout, stderr) { // console.log('Err: ' + err); // console.log('STDOUT: ' + stdout); // console.log('STDERR: ' + stderr); }); - //done(); - // if (child === undefined) { - // throw "Erro ao conectar com o core"; - // } + child.on('error', function(code, signal) { throw "Erro ao conectar com o core"; }); @@ -19,11 +15,6 @@ exports.exec_command_line = function (command_line, done) { throw "Disconectado do core"; }); - // tentar com isso descomentado no lugar de chamar o done() direto - // child.on('close', function(code, signal) { - // console.log("close com done"); - // done(); - // }); done(); return child; -- libgit2 0.21.2