Made a module for connecting to youtube and downloading mp3's
This commit is contained in:
parent
656f76ad90
commit
eb365a2ab2
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ node_modules
|
|||
mumblemusicbot
|
||||
*.pem
|
||||
*.mp3
|
||||
apikey
|
||||
|
|
14
yt.js
Normal file
14
yt.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
//yt.js
|
||||
var search = require('youtube-search');
|
||||
var dl = require('youtube-dl');
|
||||
var fs = require('fs');
|
||||
|
||||
search('low leaf as one', {key: fs.readFileSync('apikey').toString()}, function (err, results) {
|
||||
if (err) console.warn(err);
|
||||
console.log(results[0].link)
|
||||
dl.exec(results[0].link, ['-x', '--audio-format', 'mp3', '-o', 'music/%(title)s.%(ext)s'], {}, function(err, output) {
|
||||
if (err) throw err;
|
||||
console.log(output);
|
||||
});
|
||||
|
||||
})
|
Reference in a new issue