Made a module for connecting to youtube and downloading mp3's

This commit is contained in:
Bram van der Veen 2015-06-04 21:19:40 +02:00
parent 656f76ad90
commit eb365a2ab2
2 changed files with 15 additions and 0 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ node_modules
mumblemusicbot mumblemusicbot
*.pem *.pem
*.mp3 *.mp3
apikey

14
yt.js Normal file
View 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);
});
})