stickyPiston
72d934713a
Installed youtube-mp3-downloader, set up a new route and when that route is visited the package will download the video specified. Simple as that.
31 lines
702 B
JavaScript
31 lines
702 B
JavaScript
var express = require('express');
|
|
var YoutubeMp3Downloader = require("youtube-mp3-downloader");
|
|
|
|
var router = express.Router();
|
|
var YD = new YoutubeMp3Downloader({
|
|
"ffmpegPath": __dirname + "/../bin/ffmpeg",
|
|
"outputPath": __dirname + "/../music",
|
|
"youtubeVideoQuality": "highest",
|
|
"queueParallelism": 1,
|
|
"progressTimeout": 2000
|
|
});
|
|
|
|
/* GET home page. */
|
|
router.get('/', (req, res, next) => {
|
|
res.render('index', { title: 'Express' });
|
|
});
|
|
|
|
router.get('/download', (req, res, next) => {
|
|
YD.download(req.query.url);
|
|
|
|
YD.on('finished', (err, data) => {
|
|
if (err) {
|
|
res.json({ result: err });
|
|
} else {
|
|
res.json({ result: data });
|
|
}
|
|
});
|
|
})
|
|
|
|
module.exports = router;
|