     return uri.path.replace '/', ''
 
 
-module.exports = (robot) ->
-  robot.respond /xbmc (.*youtu\.?be.*)/i, (msg) ->
+module.exports = (robot) -> 
+  robot.respond /xbmc (\S*youtu\.?be\S*)/i, (msg) ->
     if /(^|\/\/)((www.)?(youtube.com)|youtu.be)\//.test msg.match[1]
       video_id = get_youtube_video_id_from msg.match[1]
       if video_id?

http = require 'http'
url = require 'url' 

xbmc_uri = url.parse process.env.HUBOT_XBMC_URL
xbmc_user = process.env.HUBOT_XBMC_USER
xbmc_password = process.env.HUBOT_XBMC_PASSWORD



xbmc_request = (method, params, msg) ->
  data = JSON.stringify({"jsonrpc": "2.0", "method": method, "params": params, "id": 1})
  req = msg.http(xbmc_uri).auth(xbmc_user, xbmc_password)
  
  console.log("Sending '"+data+"' to " + xbmc_uri)
  
  req.post(data) (err, res, body) ->
      if res.statusCode == 401
        msg.send "XBMC is saying I'm unauthorised. Check my credentials, would you?" 
      if res.statusCode == 200
