-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
28 lines (23 loc) · 953 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var bodyParser = require('body-parser')
let express = require('express')
let app = express()
app.use(bodyParser.json({ limit: '10000kb', extended: true }))
app.use(bodyParser.urlencoded({ limit: '10000kb', extended: true }))
app.use(express.static('public'));
app.post('/download', (req, res) => {
const { exec } = require('child_process');
const yt = exec('ytdl ' + req.body.url + ' | ffmpeg -i pipe:0 -b:a 320K -vn "/Users/damon/Downloads/' + req.body.nomefile + '.mp3"', function (error, stdout, stderr) {
if (error) {
console.log(error.stack);
console.log('Error code: '+error.code);
console.log('Signal received: '+error.signal);
}
console.log('Child Process STDOUT: '+stdout);
console.log('Child Process STDERR: '+stderr);
});
console.log(req.body)
res.status(200).send('ok')
})
let port = 8081
app.listen(port);
console.log('Server listening on: ' + port);