Commit 7f4b7b63a507baa026a19818cb94eee5ea41f1c3
1 parent
389bfd4f
Exists in
master
and in
1 other branch
legendas sendo baixadas quando fornecido o link e consertado a queue
Showing
2 changed files
with
16 additions
and
16 deletions
Show diff stats
endpoints/videornp.js
| ... | ... | @@ -17,7 +17,7 @@ function init(req, res, Request) { |
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - if (_.includes(req.body.revisaomanual, "SIM", "NAO")) { | |
| 20 | + if (_.includes(req.body.revisaomanual.toUpperCase(), "SIM", "NAO")) { | |
| 21 | 21 | res.send(500, parameters.errorMessage('O valor do parâmetro revisaomanual é inválido.')); |
| 22 | 22 | return; |
| 23 | 23 | } |
| ... | ... | @@ -120,13 +120,22 @@ function process(req, res, Request) { |
| 120 | 120 | |
| 121 | 121 | function downloadAndMoveFiles(folder, req, locals, callback) { |
| 122 | 122 | async.parallel([ |
| 123 | - // Download video | |
| 124 | 123 | function(callback) { |
| 125 | - files.downloadAndMoveVideo(folder, req, locals, callback); | |
| 124 | + if (_.isEmpty(req.body.legenda_url)) { // video_url present | |
| 125 | + // Download video | |
| 126 | + files.downloadAndMoveVideo(folder, req, locals, callback); | |
| 127 | + } else { | |
| 128 | + // Download subtitle | |
| 129 | + files.downloadAndMoveSubtitle(folder, req, locals, callback); | |
| 130 | + } | |
| 131 | + | |
| 126 | 132 | } |
| 127 | 133 | ], function(err) { |
| 128 | - console.log("=== Video baixado"); | |
| 129 | - | |
| 134 | + if (_.isEmpty(req.body.legenda_url)) { // video_url present | |
| 135 | + console.log("== Video baixado"); | |
| 136 | + } else { | |
| 137 | + console.log("== Legenda baixada"); | |
| 138 | + } | |
| 130 | 139 | // Callback chamado depois de todas as tarefas |
| 131 | 140 | // Se tiver erro, vai passar para cima |
| 132 | 141 | callback(err); | ... | ... |
helpers/queue.js
| ... | ... | @@ -2,16 +2,12 @@ var exec = require('child_process').exec, child; |
| 2 | 2 | |
| 3 | 3 | exports.exec_command_line = function (command_line, done) { |
| 4 | 4 | |
| 5 | - // child = exec(command_line, function(err, stdout, stderr) { | |
| 6 | - child = exec("curl -O http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_20mb.mp4", function(err, stdout, stderr) { | |
| 5 | + child = exec(command_line, function(err, stdout, stderr) { | |
| 7 | 6 | // console.log('Err: ' + err); |
| 8 | 7 | // console.log('STDOUT: ' + stdout); |
| 9 | 8 | // console.log('STDERR: ' + stderr); |
| 10 | 9 | }); |
| 11 | - //done(); | |
| 12 | - // if (child === undefined) { | |
| 13 | - // throw "Erro ao conectar com o core"; | |
| 14 | - // } | |
| 10 | + | |
| 15 | 11 | child.on('error', function(code, signal) { |
| 16 | 12 | throw "Erro ao conectar com o core"; |
| 17 | 13 | }); |
| ... | ... | @@ -19,11 +15,6 @@ exports.exec_command_line = function (command_line, done) { |
| 19 | 15 | throw "Disconectado do core"; |
| 20 | 16 | }); |
| 21 | 17 | |
| 22 | - // tentar com isso descomentado no lugar de chamar o done() direto | |
| 23 | - // child.on('close', function(code, signal) { | |
| 24 | - // console.log("close com done"); | |
| 25 | - // done(); | |
| 26 | - // }); | |
| 27 | 18 | done(); |
| 28 | 19 | return child; |
| 29 | 20 | ... | ... |