Permalink
Browse files

Convert XBMC variables to camel case

  • Loading branch information...
1 parent c05e52d commit 2c4fa9353155c571edfa5a95dfc03e4fa9ce8e72 @lucaswilric lucaswilric committed Oct 9, 2012
Showing with 17 additions and 17 deletions.
  1. +17 −17 src/scripts/xbmc.coffee
@@ -27,27 +27,27 @@
http = require 'http'
url = require 'url'
-xbmc_uri = process.env.HUBOT_XBMC_URL
-xbmc_user = process.env.HUBOT_XBMC_USER
-xbmc_password = process.env.HUBOT_XBMC_PASSWORD || ''
+xbmcUri = process.env.HUBOT_XBMC_URL
+xbmcUser = process.env.HUBOT_XBMC_USER
+xbmcPassword = process.env.HUBOT_XBMC_PASSWORD || ''
-play_youtube = (video_id, msg) ->
- xbmc_request "Player.Open", {"item":{"file":"plugin://plugin.video.youtube/?action=play_video&videoid=" + video_id }}, msg
+playYouTube = (videoId, msg) ->
+ xbmcRequest "Player.Open", {"item":{"file":"plugin://plugin.video.youtube/?action=play_video&videoid=" + videoId }}, msg
-xbmc_stop = (msg) ->
- xbmc_request "Player.Stop", {"playerid": 1}, msg
+xbmcStop = (msg) ->
+ xbmcRequest "Player.Stop", {"playerid": 1}, msg
-xbmc_request = (method, params, msg) ->
- unless xbmc_uri
+xbmcRequest = (method, params, msg) ->
+ unless xbmcUri?
msg.reply "I don't know where XBMC is. Please configure a URL."
return
- unless xbmc_user
+ unless xbmcUser?
msg.reply "I don't have a user name to give XBMC. Please configure one."
return
data = JSON.stringify({"jsonrpc": "2.0", "method": method, "params": params, "id": 1})
- req = msg.http(xbmc_uri + 'jsonrpc').auth(xbmc_user, xbmc_password)
+ req = msg.http(xbmcUri + 'jsonrpc').auth(xbmcUser, xbmcPassword)
req.post(data) (err, res, body) ->
if res.statusCode == 401
@@ -56,8 +56,8 @@ xbmc_request = (method, params, msg) ->
msg.reply "Done."
-get_youtube_video_id_from = (video_url) ->
- uri = url.parse((if /^http/.test video_url then video_url else 'http://'+video_url), true)
+getYouTubeVideoIdFrom = (videoUrl) ->
+ uri = url.parse((if /^http/.test videoUrl then videoUrl else 'http://'+videoUrl), true)
if /youtube.com$/.test uri.host
return uri.query.v if uri.query? and uri.query.v?
return uri.path.match(/\/v\/([^\/]*)/) if /\/v\//.test uri.path
@@ -68,14 +68,14 @@ get_youtube_video_id_from = (video_url) ->
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?
- play_youtube video_id, msg
+ videoId = getYouTubeVideoIdFrom msg.match[1]
+ if videoId?
+ playYouTube videoId, msg
return
msg.reply "That doesn't look like something I can tell XBMC to play. Sorry :("
robot.respond /xbmc stop/i, (msg) ->
- xbmc_stop(msg)
+ xbmcStop(msg)
robot.respond /where('s| is) xbmc\??/i, (msg) ->
msg.send 'XBMC is at ' + process.env.HUBOT_XBMC_URL

0 comments on commit 2c4fa93

Please sign in to comment.