Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bumped version to 0.0.5a and published.

Signed-off-by: Diwank Singh Tomer <diwank.singh@gmail.com>
  • Loading branch information...
commit e287e507724ee4c88fa3e66dc31e68fc2464187c 1 parent cd33029
@creatorrr authored
View
1  lib/globals.js
@@ -32,6 +32,7 @@
rdio = pick(process.env, 'RDIO_CONSUMER', 'RDIO_SECRET', 'HEROKU_URL');
misc = {
+ DOMAIN: process.env.DOMAIN || process.env.HEROKU_URL,
CALLBACK: 'auth'
};
View
6 lib/index.js
@@ -7,15 +7,15 @@
CALLBACK = require('./globals').CALLBACK;
module.exports = function(robot) {
- var listeners, pages, routes;
+ var listeners, routes;
robot.io = sockets(robot);
- pages = require('./pages');
routes = (require('./routes'))(robot);
listeners = (require('./listeners'))(robot);
robot.respond(/init rdio/i, listeners.init);
robot.respond(/test rdio/i, listeners.test);
robot.router.get('/', routes.home);
- return robot.router.get("/" + CALLBACK, routes.auth);
+ robot.router.get("/" + CALLBACK, routes.auth);
+ return robot.router.get('/player', routes.player);
};
}).call(this);
View
6 lib/listeners.js
@@ -1,17 +1,17 @@
// Generated by CoffeeScript 1.4.0
(function() {
- var CALLBACK, HEROKU_URL, RDIO_CONSUMER, RDIO_SECRET, Rdio, listeners, _ref;
+ var CALLBACK, DOMAIN, RDIO_CONSUMER, RDIO_SECRET, Rdio, listeners, _ref;
Rdio = require('node-rdio');
- _ref = require('./globals'), RDIO_CONSUMER = _ref.RDIO_CONSUMER, RDIO_SECRET = _ref.RDIO_SECRET, HEROKU_URL = _ref.HEROKU_URL, CALLBACK = _ref.CALLBACK;
+ _ref = require('./globals'), RDIO_CONSUMER = _ref.RDIO_CONSUMER, RDIO_SECRET = _ref.RDIO_SECRET, DOMAIN = _ref.DOMAIN, CALLBACK = _ref.CALLBACK;
module.exports = listeners = function(robot) {
return {
init: function(msg) {
var rdio;
rdio = new Rdio([RDIO_CONSUMER, RDIO_SECRET]);
- return rdio.beginAuthentication(HEROKU_URL + CALLBACK, function(error, authUrl) {
+ return rdio.beginAuthentication(DOMAIN + CALLBACK, function(error, authUrl) {
var requestSecret, requestToken;
if (error) {
robot.logger.debug(error);
View
5 lib/pages.js
@@ -54,6 +54,11 @@
};
return setTimeout(redirect, 3000);
});
+ },
+ player: function() {
+ return div(function() {
+ return this.playbackToken;
+ });
}
};
View
43 lib/routes.js
@@ -1,10 +1,12 @@
// Generated by CoffeeScript 1.4.0
(function() {
- var RDIO_CONSUMER, RDIO_SECRET, Rdio, routes, _ref;
+ var DOMAIN, RDIO_CONSUMER, RDIO_SECRET, Rdio, pages, routes, _ref;
Rdio = require('node-rdio');
- _ref = require('./globals'), RDIO_CONSUMER = _ref.RDIO_CONSUMER, RDIO_SECRET = _ref.RDIO_SECRET;
+ pages = require('./pages');
+
+ _ref = require('./globals'), RDIO_CONSUMER = _ref.RDIO_CONSUMER, RDIO_SECRET = _ref.RDIO_SECRET, DOMAIN = _ref.DOMAIN;
module.exports = routes = function(robot) {
return {
@@ -45,6 +47,43 @@
redirect: '/'
}));
});
+ },
+ player: function(req, res) {
+ var accessSecret, accessToken, rdio;
+ res.writeHead(200, {
+ 'Content-Type': 'text/html'
+ });
+ accessToken = robot.brain.get('RdioAccessSecret');
+ accessSecret = robot.brain.get("RdioAccessSecret-" + accessToken);
+ if (!(accessToken && accessSecret)) {
+ return res.end(pages.redirect({
+ message: 'Please authorize rdio first.',
+ redirect: '/'
+ }));
+ }
+ rdio = new Rdio([RDIO_CONSUMER, RDIO_SECRET], [accessToken, accessSecret]);
+ return rdio.call('currentUser', function(error) {
+ if (error) {
+ return res.end(pages.redirect({
+ message: 'Please authorize rdio first.',
+ redirect: '/'
+ }));
+ } else {
+ return rdio.call('getPlaybackToken', {
+ domain: DOMAIN
+ }, function(error, data) {
+ if (error) {
+ return res.end(pages.error({
+ message: "Error: " + error
+ }));
+ } else {
+ return res.end(pages.player({
+ playbackToken: data
+ }));
+ }
+ });
+ }
+ });
}
};
};
View
4 package.json
@@ -1,6 +1,6 @@
{
"name": "hubot-rdio",
- "version": "0.0.4",
+ "version": "0.0.5a",
"description": "Rdio controller for hubot.",
"main": "lib/index.js",
"scripts": {
@@ -25,5 +25,5 @@
"license": "BSD",
"readmeFilename": "README.md",
"devDependencies": {},
- "gitHead": "391ff609194c01b1c432d30f5893b6b2c18865df"
+ "gitHead": "cd33029ea833095db6ee80fc06a9673255a6880e"
}
Please sign in to comment.
Something went wrong with that request. Please try again.