From 89f070b26f5adb257cf8640e7ced01f370f793eb Mon Sep 17 00:00:00 2001 From: Bram van der Veen <96aa48@gmail.com> Date: Sun, 7 Jun 2015 21:39:09 +0200 Subject: [PATCH] Added /play command --- app.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index af844c6..1945a59 100644 --- a/app.js +++ b/app.js @@ -45,9 +45,16 @@ var start = function(client) { } } else if (command[0] == '/play') { - if (command[1]) { - if (command[1].substr(0,6) == 'http://' || command[1].substr(0, 7) == 'https://') { + command[1] = command.splice(1).join(' ').replace(/\<.*\"\>|\<\/.*\>/g, ''); + + if (command[1]) { + if (command[1].substr(0,7) == 'http://' || command[1].substr(0, 8) == 'https://') { + dl.exec(command[1], ['-x', '--audio-format', 'mp3', '-o', 'music/%(title)s.%(ext)s'], {}, function (err, output) { + if (err) throw err; + console.log(output) + play(client, output[3].split('music/')[1].replace(/\.m4a/g, '')); + }); } else if (command[1] == 'offline') { }