diff --git a/examples/api-verbose.js b/examples/api-verbose.js index dda1054..660c400 100755 --- a/examples/api-verbose.js +++ b/examples/api-verbose.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var TCPConnection, XbmcApi, config, connection, xbmcApi; diff --git a/examples/config.coffee b/examples/config.coffee index fc47c94..b8f4876 100755 --- a/examples/config.coffee +++ b/examples/config.coffee @@ -6,5 +6,3 @@ module.exports = try module.exports = require './config.local' catch e - - diff --git a/examples/config.js b/examples/config.js index 6c1f9e6..dd915ab 100755 --- a/examples/config.js +++ b/examples/config.js @@ -1,6 +1,6 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { - var e; + var e, error; module.exports = { connection: { @@ -11,8 +11,8 @@ try { module.exports = require('./config.local'); - } catch (_error) { - e = _error; + } catch (error) { + e = error; } }).call(this); diff --git a/examples/hooks.js b/examples/hooks.js index 95f108d..b37c3d2 100755 --- a/examples/hooks.js +++ b/examples/hooks.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var TCPConnection, XbmcApi, config, connection, xbmcApi; diff --git a/examples/input.js b/examples/input.js index 30820c4..6a1c1d8 100755 --- a/examples/input.js +++ b/examples/input.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var TCPConnection, XbmcApi, config, connection, prompt, readline, rl, xbmcApi; diff --git a/examples/list-movies.js b/examples/list-movies.js index c272a3e..93b6fc3 100755 --- a/examples/list-movies.js +++ b/examples/list-movies.js @@ -1,10 +1,10 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { - var TCPConnection, Table, XbmcApi, config, connection, table, xbmcApi, _ref; + var TCPConnection, Table, XbmcApi, config, connection, ref, table, xbmcApi; Table = require('cli-table'); - _ref = require('..'), TCPConnection = _ref.TCPConnection, XbmcApi = _ref.XbmcApi; + ref = require('..'), TCPConnection = ref.TCPConnection, XbmcApi = ref.XbmcApi; config = require('./config'); @@ -30,10 +30,10 @@ table.options.style.compact = true; xbmcApi.on('api:movies', function(movies) { - var movie, _i, _len; - console.log("" + movies.length + " Movies"); - for (_i = 0, _len = movies.length; _i < _len; _i++) { - movie = movies[_i]; + var i, len, movie; + console.log(movies.length + " Movies"); + for (i = 0, len = movies.length; i < len; i++) { + movie = movies[i]; table.push([movie.movieid, movie.label, movie.genre.join(', '), movie.year]); } return console.log(table.toString()); diff --git a/examples/message-chat.js b/examples/message-chat.js index 4f00a88..211bf2d 100755 --- a/examples/message-chat.js +++ b/examples/message-chat.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var TCPConnection, XbmcApi, config, connection, prompt, readline, rl, xbmcApi; diff --git a/examples/messages.js b/examples/messages.js index 1779e1a..65cd623 100755 --- a/examples/messages.js +++ b/examples/messages.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var TCPConnection, XbmcApi, config, connection, xbmcApi; diff --git a/examples/play-file.js b/examples/play-file.js index 94ba6ac..6c1e170 100755 --- a/examples/play-file.js +++ b/examples/play-file.js @@ -1,8 +1,8 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { - var TCPConnection, XbmcApi, config, connection, file, xbmcApi, _ref; + var TCPConnection, XbmcApi, config, connection, file, ref, xbmcApi; - _ref = require('..'), TCPConnection = _ref.TCPConnection, XbmcApi = _ref.XbmcApi; + ref = require('..'), TCPConnection = ref.TCPConnection, XbmcApi = ref.XbmcApi; config = require('./config'); diff --git a/examples/play-youtube.js b/examples/play-youtube.js index bd06c79..23c6c52 100755 --- a/examples/play-youtube.js +++ b/examples/play-youtube.js @@ -1,8 +1,8 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { - var TCPConnection, XbmcApi, config, connection, id, xbmcApi, _ref; + var TCPConnection, XbmcApi, config, connection, id, ref, xbmcApi; - _ref = require('..'), TCPConnection = _ref.TCPConnection, XbmcApi = _ref.XbmcApi; + ref = require('..'), TCPConnection = ref.TCPConnection, XbmcApi = ref.XbmcApi; config = require('./config'); diff --git a/examples/search-movie.js b/examples/search-movie.js index c46b04d..fcde6a1 100755 --- a/examples/search-movie.js +++ b/examples/search-movie.js @@ -1,10 +1,10 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { - var TCPConnection, Table, XbmcApi, config, connection, query, re, table, xbmcApi, _ref; + var TCPConnection, Table, XbmcApi, config, connection, query, re, ref, table, xbmcApi; Table = require('cli-table'); - _ref = require('..'), TCPConnection = _ref.TCPConnection, XbmcApi = _ref.XbmcApi; + ref = require('..'), TCPConnection = ref.TCPConnection, XbmcApi = ref.XbmcApi; config = require('./config'); @@ -34,14 +34,14 @@ table.options.style.compact = true; xbmcApi.on('api:movies', function(movies) { - var movie, _i, _len; - for (_i = 0, _len = movies.length; _i < _len; _i++) { - movie = movies[_i]; + var i, len, movie; + for (i = 0, len = movies.length; i < len; i++) { + movie = movies[i]; if (movie.label.match(re)) { table.push([movie.movieid, movie.label, movie.file]); } } - console.log("" + table.length + " Movies"); + console.log(table.length + " Movies"); console.log(table.toString()); return xbmcApi.disconnect(function() { return process.exit(0); diff --git a/examples/stop.js b/examples/stop.js new file mode 100644 index 0000000..2208ec4 --- /dev/null +++ b/examples/stop.js @@ -0,0 +1,22 @@ +// Generated by CoffeeScript 1.10.0 +(function() { + var TCPConnection, XbmcApi, config, connection, ref, xbmcApi; + + ref = require('..'), TCPConnection = ref.TCPConnection, XbmcApi = ref.XbmcApi; + + config = require('./config'); + + connection = new TCPConnection({ + host: config.connection.host, + port: config.connection.port, + verbose: false + }); + + xbmcApi = new XbmcApi({ + silent: false, + connection: connection + }); + + xbmcApi.player.stop(); + +}).call(this); diff --git a/lib/Handlers.js b/lib/Handlers.js index eeb2f2e..34e0bb4 100644 --- a/lib/Handlers.js +++ b/lib/Handlers.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var Handlers, debug, pubsub; @@ -22,9 +22,9 @@ }; Handlers.players = function(data) { - var dfd, playerId, _ref; + var dfd, playerId, ref; debug('players', data); - playerId = (((_ref = data.result) != null ? _ref[0] : void 0) || data.player || {}).playerid; + playerId = (((ref = data.result) != null ? ref[0] : void 0) || data.player || {}).playerid; if (playerId) { dfd = Handlers.api.send('Player.GetItem', { playerid: playerId diff --git a/lib/Input.js b/lib/Input.js index 9987365..b95cc7b 100644 --- a/lib/Input.js +++ b/lib/Input.js @@ -1,6 +1,6 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { - var Input, debug, pubsub, _fn, _i, _key, _len, _ref; + var Input, _key, debug, fn1, i, len, pubsub, ref; pubsub = require('./PubSub'); @@ -66,8 +66,8 @@ })(); - _ref = Input.inputMethods; - _fn = function() { + ref = Input.inputMethods; + fn1 = function() { var key; key = _key; return Input[key] = function(fn) { @@ -85,9 +85,9 @@ }); }; }; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - _key = _ref[_i]; - _fn(); + for (i = 0, len = ref.length; i < len; i++) { + _key = ref[i]; + fn1(); } module.exports = Input; diff --git a/lib/Media.js b/lib/Media.js index b046304..a7d30bc 100644 --- a/lib/Media.js +++ b/lib/Media.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var Media, debug, pubsub; diff --git a/lib/Notifications.js b/lib/Notifications.js index 7667fb7..045573a 100644 --- a/lib/Notifications.js +++ b/lib/Notifications.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var Notifications, debug, pubsub; diff --git a/lib/Player.js b/lib/Player.js index bdba4dc..924781b 100644 --- a/lib/Player.js +++ b/lib/Player.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var Player, debug, pubsub; @@ -63,19 +63,17 @@ } debug('playPause'); return Player.getActivePlayers(function(data) { - var dfd, playerId, _ref, _ref1; - playerId = ((_ref = data.result) != null ? _ref.playerid : void 0) || ((_ref1 = data.player) != null ? _ref1.playerid : void 0); - dfd = this.api.send('Player.PlayPause', { + var dfd, playerId, ref, ref1; + playerId = ((ref = data.result) != null ? ref[0].playerid : void 0) || ((ref1 = data.player) != null ? ref1.playerid : void 0); + dfd = Player.api.send('Player.PlayPause', { playerid: playerId }); - return dfd.then((function(_this) { - return function(data) { - pubsub.emit('player.playpause', data); - if (fn) { - return fn(data); - } - }; - })(this)); + return dfd.then(function(data) { + pubsub.emit('player.playpause', data); + if (fn) { + return fn(data); + } + }); }); }; @@ -85,19 +83,17 @@ } debug('stop'); return Player.getActivePlayers(function(data) { - var dfd, playerId, _ref, _ref1; - playerId = ((_ref = data.result) != null ? _ref.playerid : void 0) || ((_ref1 = data.player) != null ? _ref1.playerid : void 0); - dfd = this.api.send('Player.Stop', { + var dfd, playerId, ref, ref1; + playerId = ((ref = data.result) != null ? ref[0].playerid : void 0) || ((ref1 = data.player) != null ? ref1.playerid : void 0); + dfd = Player.api.send('Player.Stop', { playerid: playerId }); - return dfd.then((function(_this) { - return function(data) { - pubsub.emit('player.stop', data); - if (fn) { - return fn(data); - } - }; - })(this)); + return dfd.then(function(data) { + pubsub.emit('player.stop', data); + if (fn) { + return fn(data); + } + }); }); }; @@ -120,20 +116,18 @@ speed = forward ? 'increment' : 'decrement'; debug('rewind', speed); return Player.getActivePlayers(function(data) { - var dfd, playerId, _ref, _ref1; - playerId = ((_ref = data.result) != null ? _ref.playerid : void 0) || ((_ref1 = data.player) != null ? _ref1.playerid : void 0); - dfd = this.api.send('Player.SetSpeed', { + var dfd, playerId, ref, ref1; + playerId = ((ref = data.result) != null ? ref[0].playerid : void 0) || ((ref1 = data.player) != null ? ref1.playerid : void 0); + dfd = Player.api.send('Player.SetSpeed', { playerid: playerId, speed: speed }); - return dfd.then((function(_this) { - return function(data) { - pubsub.emit('player.setspeed', data); - if (fn) { - return fn(data); - } - }; - })(this)); + return dfd.then(function(data) { + pubsub.emit('player.setspeed', data); + if (fn) { + return fn(data); + } + }); }); }; diff --git a/lib/PubSub.js b/lib/PubSub.js index 651f647..86301a9 100644 --- a/lib/PubSub.js +++ b/lib/PubSub.js @@ -1,15 +1,15 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var EventEmitter, PubSub, debug, pubsub, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; EventEmitter = require('events').EventEmitter; debug = require('debug')('xbmc:PubSub'); - PubSub = (function(_super) { - __extends(PubSub, _super); + PubSub = (function(superClass) { + extend(PubSub, superClass); function PubSub() { debug('constructor'); diff --git a/lib/TCPConnection.js b/lib/TCPConnection.js index cc79cb3..22665c3 100644 --- a/lib/TCPConnection.js +++ b/lib/TCPConnection.js @@ -1,7 +1,7 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var Connection, clarinet, debug, defer, net, pubsub, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; debug = require('debug')('xbmc:TCPConnection'); @@ -15,37 +15,37 @@ Connection = (function() { function Connection(options) { - var _base, _base1, _base2, _base3, _base4, _base5; + var base, base1, base2, base3, base4, base5; this.options = options != null ? options : {}; - this._receive = __bind(this._receive, this); - this._createParser = __bind(this._createParser, this); - this.onData = __bind(this.onData, this); - this.onClose = __bind(this.onClose, this); - this.onError = __bind(this.onError, this); - this.onOpen = __bind(this.onOpen, this); - this.publish = __bind(this.publish, this); - this.close = __bind(this.close, this); - this.send = __bind(this.send, this); - this.isActive = __bind(this.isActive, this); - this.create = __bind(this.create, this); + this._receive = bind(this._receive, this); + this._createParser = bind(this._createParser, this); + this.onData = bind(this.onData, this); + this.onClose = bind(this.onClose, this); + this.onError = bind(this.onError, this); + this.onOpen = bind(this.onOpen, this); + this.publish = bind(this.publish, this); + this.close = bind(this.close, this); + this.send = bind(this.send, this); + this.isActive = bind(this.isActive, this); + this.create = bind(this.create, this); debug('constructor', this.options); - if ((_base = this.options).port == null) { - _base.port = 9090; + if ((base = this.options).port == null) { + base.port = 9090; } - if ((_base1 = this.options).host == null) { - _base1.host = '127.0.0.1'; + if ((base1 = this.options).host == null) { + base1.host = '127.0.0.1'; } - if ((_base2 = this.options).user == null) { - _base2.user = 'xbmc'; + if ((base2 = this.options).user == null) { + base2.user = 'xbmc'; } - if ((_base3 = this.options).password == null) { - _base3.password = false; + if ((base3 = this.options).password == null) { + base3.password = false; } - if ((_base4 = this.options).verbose == null) { - _base4.verbose = false; + if ((base4 = this.options).verbose == null) { + base4.verbose = false; } - if ((_base5 = this.options).connectNow == null) { - _base5.connectNow = true; + if ((base5 = this.options).connectNow == null) { + base5.connectNow = true; } this._createParser(); this.sendQueue = []; @@ -75,13 +75,13 @@ }; Connection.prototype.isActive = function() { - var _ref; + var ref; debug('isActive'); - return ((_ref = this.socket) != null ? _ref._connecting : void 0) === false; + return ((ref = this.socket) != null ? ref._connecting : void 0) === false; }; Connection.prototype.send = function(data) { - var dfd, _base, _name; + var base, dfd, name; if (data == null) { data = null; } @@ -92,7 +92,7 @@ if (data.id == null) { data.id = Connection.generateId(); } - dfd = (_base = this.deferreds)[_name = data.id] != null ? _base[_name] : _base[_name] = defer(); + dfd = (base = this.deferreds)[name = data.id] != null ? base[name] : base[name] = defer(); if (!this.isActive()) { this.sendQueue.push(data); } else { @@ -105,7 +105,7 @@ }; Connection.prototype.close = function(fn) { - var err; + var err, error; if (fn == null) { fn = null; } @@ -116,8 +116,8 @@ if (fn) { return fn(); } - } catch (_error) { - err = _error; + } catch (error) { + err = error; this.publish('error', err); if (fn) { return fn(err); @@ -140,10 +140,10 @@ this.publish('open'); return setTimeout(((function(_this) { return function() { - var item, _i, _len, _ref; - _ref = _this.sendQueue; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - item = _ref[_i]; + var i, item, len, ref; + ref = _this.sendQueue; + for (i = 0, len = ref.length; i < len; i++) { + item = ref[i]; _this.send(item); } return _this.sendQueue = []; @@ -237,11 +237,11 @@ }; Connection.prototype._receive = function(data) { - var dfd, evt, id, _ref, _ref1; + var dfd, evt, id, ref, ref1; evt = { data: data }; - id = (_ref = evt.data) != null ? _ref.id : void 0; + id = (ref = evt.data) != null ? ref.id : void 0; dfd = this.deferreds[id]; delete this.deferreds[id]; if (evt.data.error) { @@ -251,7 +251,7 @@ } } else { this.publish('data', evt.data); - if ((_ref1 = evt.data.method) != null ? _ref1.indexOf('.On' > 1) : void 0) { + if ((ref1 = evt.data.method) != null ? ref1.indexOf('.On' > 1) : void 0) { this.publish('notification', evt.data); } if (dfd) { diff --git a/lib/XbmcApi.js b/lib/XbmcApi.js index b27e05a..19a8286 100644 --- a/lib/XbmcApi.js +++ b/lib/XbmcApi.js @@ -1,7 +1,7 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { var XbmcApi, debug, defer, pubsub, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; defer = require('node-promise').defer; @@ -10,15 +10,15 @@ pubsub = require('./PubSub'); XbmcApi = (function() { - function XbmcApi(options) { - this.options = options != null ? options : {}; - this.disconnect = __bind(this.disconnect, this); - this.connect = __bind(this.connect, this); - this.message = __bind(this.message, this); - this.send = __bind(this.send, this); - this.initialize = __bind(this.initialize, this); - this.setConnection = __bind(this.setConnection, this); - this.loadModules = __bind(this.loadModules, this); + function XbmcApi(options1) { + this.options = options1 != null ? options1 : {}; + this.disconnect = bind(this.disconnect, this); + this.connect = bind(this.connect, this); + this.message = bind(this.message, this); + this.send = bind(this.send, this); + this.initialize = bind(this.initialize, this); + this.setConnection = bind(this.setConnection, this); + this.loadModules = bind(this.loadModules, this); debug('constructor'); this.queue = []; this.connection = null; @@ -48,15 +48,15 @@ }; XbmcApi.prototype.loadModules = function() { - var module, _i, _len, _ref, _results; + var i, len, module, ref, results; debug('loadModules'); - _ref = ['./Media', './Notifications', './Handlers', './Player', './Input']; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - module = _ref[_i]; - _results.push(require(module).mixin(this)); + ref = ['./Media', './Notifications', './Handlers', './Player', './Input']; + results = []; + for (i = 0, len = ref.length; i < len; i++) { + module = ref[i]; + results.push(require(module).mixin(this)); } - return _results; + return results; }; XbmcApi.prototype.setConnection = function(newConnection) { @@ -152,12 +152,12 @@ }; XbmcApi.prototype.disconnect = function(fn) { - var _ref; + var ref; if (fn == null) { fn = null; } debug('disconnect'); - if ((_ref = this.connection) != null ? _ref.isActive() : void 0) { + if ((ref = this.connection) != null ? ref.isActive() : void 0) { return this.connection.close(fn); } if (fn) { diff --git a/lib/index.js b/lib/index.js index 0bea74e..936719f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,12 +1,12 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.10.0 (function() { - var mod, _i, _len, _ref; + var i, len, mod, ref; module.exports = {}; - _ref = ['XbmcApi', 'TCPConnection', 'Player', 'Input', 'Handlers', 'Media', 'Notifications']; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - mod = _ref[_i]; + ref = ['XbmcApi', 'TCPConnection', 'Player', 'Input', 'Handlers', 'Media', 'Notifications']; + for (i = 0, len = ref.length; i < len; i++) { + mod = ref[i]; module.exports[mod] = require("./" + mod); }