Commit de519bcef14920ea59d3acceb28ef7dc7dbeced2
1 parent
b2b00c25
Exists in
master
and in
1 other branch
update subtitle name
Showing
3 changed files
with
29 additions
and
22 deletions
Show diff stats
endpoints/videornp.js
... | ... | @@ -3,7 +3,8 @@ var properties = require('../helpers/properties'); |
3 | 3 | var files = require('../helpers/files'); |
4 | 4 | var core = require('../helpers/core'); |
5 | 5 | var db = require('../db/api'); |
6 | - | |
6 | +var queue_helper = require('../helpers/queue'); | |
7 | +var exec = require('child_process').exec, child; | |
7 | 8 | var uuid = require('node-uuid'); |
8 | 9 | var mkdirp = require('mkdirp'); |
9 | 10 | var async = require('async'); |
... | ... | @@ -147,7 +148,8 @@ function downloadAndMoveFiles(folder, req, locals, callback) { |
147 | 148 | if (_.isEmpty(req.body.legenda_url)) { // video_url present |
148 | 149 | console.log("== Video baixado"); |
149 | 150 | } else { |
150 | - console.log("== Legenda baixada"); | |
151 | + // nao chama corretamente | |
152 | + // console.log("== Legenda baixada"); | |
151 | 153 | } |
152 | 154 | // Callback chamado depois de todas as tarefas |
153 | 155 | // Se tiver erro, vai passar para cima |
... | ... | @@ -170,25 +172,31 @@ function callCore(id, video, subtitle, req, res, Request, request_object) { |
170 | 172 | |
171 | 173 | function callCoreSubtitle(id, subtitle, req, res, Request, request_object) { |
172 | 174 | /* Move a legenda submetido para a pasta com o seu ID correspondente */ |
173 | - fs.rename(req.files.legenda.path, __dirname + '/uploads/' + id + '/' + req.files.legenda.name, function(error) { | |
174 | - if (error) { console.log(error); } | |
175 | - }); | |
176 | 175 | |
177 | 176 | /* Cria a linha de comando */ |
177 | + var legenda_name = ""; | |
178 | + if(req.body.legenda_url !== undefined) { | |
179 | + legenda_name = req.body.legenda_url.substring(req.body.legenda_url.lastIndexOf('/') + 1); | |
180 | + legenda_name = legenda_name.split(".")[0]; | |
181 | + } else if (req.files.legenda.name !== undefined) { | |
182 | + legenda_name = req.files.legenda.name; | |
183 | + } | |
184 | + | |
178 | 185 | var command_line = 'vlibras_user/vlibras-core/./vlibras -S ' + ' uploads/' + id + '/' + |
179 | - req.files.legenda.name + ' -l portugues -b opaco --id' + id + ' --mode devel > /tmp/core_log 2>&1'; | |
186 | + legenda_name + ' -l portugues -b opaco --id' + id + ' --mode devel > /tmp/core_log 2>&1'; | |
187 | + | |
180 | 188 | |
181 | - var child; | |
182 | - var job = queue.create('exec_command_line' + id, { | |
183 | - title: 'Command Line for: ' + req.body.servico, | |
184 | - command_line: command_line | |
185 | - }).removeOnComplete( true ).save(); | |
189 | + var child; | |
190 | + var job = queue.create('exec_command_line' + id, { | |
191 | + title: 'Command Line for: ' + req.body.servico, | |
192 | + command_line: command_line | |
193 | + }).removeOnComplete( true ).save(); | |
186 | 194 | |
187 | - queue.process('exec_command_line' + id, function(job, done){ | |
188 | - child = queue_helper.exec_command_line(job.data.command_line, done); | |
189 | - }); | |
195 | + queue.process('exec_command_line' + id, function(job, done){ | |
196 | + child = queue_helper.exec_command_line(job.data.command_line, done); | |
197 | + }); | |
190 | 198 | |
191 | - job.on('complete', function() { | |
199 | + job.on('complete', function() { | |
192 | 200 | /* Executa a linha de comando */ |
193 | 201 | child = exec(command_line, function(err, stdout, stderr) { |
194 | 202 | // [stdout] = vlibras-core output | ... | ... |
helpers/files.js
... | ... | @@ -95,7 +95,6 @@ function downloadAndMoveVideo(folder, req, locals, callback) { |
95 | 95 | * Deve retornar um objeto contendo o nome e o caminho |
96 | 96 | */ |
97 | 97 | function downloadAndMoveSubtitle(folder, req, locals, callback) { |
98 | - | |
99 | 98 | // Se enviou o arquivo na requisição |
100 | 99 | if (req.files.legenda !== undefined) { |
101 | 100 | |
... | ... | @@ -147,7 +146,6 @@ function downloadAndMoveSubtitle(folder, req, locals, callback) { |
147 | 146 | |
148 | 147 | // Salva o arquivo em disco |
149 | 148 | response.pipe(file); |
150 | - | |
151 | 149 | // Quando a escrita acabar |
152 | 150 | file.on('finish', function() { |
153 | 151 | |
... | ... | @@ -160,6 +158,7 @@ function downloadAndMoveSubtitle(folder, req, locals, callback) { |
160 | 158 | }; |
161 | 159 | |
162 | 160 | // Chama o callback para prosseguir execução |
161 | + console.log("== Legenda baixada"); | |
163 | 162 | callback(); |
164 | 163 | }); |
165 | 164 | }); | ... | ... |
logsystem/errors.log
1 | 1 | { |
2 | 2 | "resumo": { |
3 | 3 | "bloqueante": { |
4 | - "1": 2, | |
4 | + "1": 3, | |
5 | 5 | "2": 0, |
6 | - "3": 0, | |
7 | - "4": 48 | |
6 | + "3": 2, | |
7 | + "4": 49 | |
8 | 8 | }, |
9 | 9 | "nao-bloqueante": { |
10 | 10 | "1": 0, |
... | ... | @@ -14,9 +14,9 @@ |
14 | 14 | } |
15 | 15 | }, |
16 | 16 | "detalhado": { |
17 | - "1": "detalhe do erro", | |
17 | + "1": "Erro no retorno do core. Código: 127", | |
18 | 18 | "2": "detalhe", |
19 | - "3": "detalhe", | |
19 | + "3": {}, | |
20 | 20 | "4": "Rota nao encontrada" |
21 | 21 | } |
22 | 22 | } |
23 | 23 | \ No newline at end of file | ... | ... |