Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'release/v0.8.1'

  • Loading branch information...
commit 9a4db272e87c0445d22a4b46b828511f972fe531 2 parents b94f77c + cef0cfa
@jammus authored
View
1  .gitignore
@@ -0,0 +1 @@
+config.js
View
4 History.md
@@ -1,5 +1,9 @@
# Changelog
+## 0.8.1
+* Automatically set album parameter from track details when available.
+* Experimental REPL.
+
## 0.8.0
### Breaking changes
View
4 config.example.js
@@ -0,0 +1,4 @@
+module.exports = {
+ api_key: '',
+ secret: ''
+};
View
44 lastfm-repl.js
@@ -0,0 +1,44 @@
+var LastFmNode = require('./lib/lastfm').LastFmNode,
+ repl = require('repl'),
+ config = require('./config'),
+ _ = require('underscore');
+
+var echoHandler = function() {
+ _(arguments).each(function(arg) {
+ console.log(arg);
+ });
+};
+
+var errorHandler = function(error) {
+ console.log('Error: ' + error.message);
+};
+
+var quietHandler = function() { };
+
+var _echoHandlers = {
+ error: errorHandler,
+ success: echoHandler,
+ lastPlayed: echoHandler,
+ nowPlaying: echoHandler,
+ scrobbled: echoHandler,
+ stoppedPlaying: echoHandler
+};
+
+var _quietHandlers = {
+ error: errorHandler,
+ success: quietHandler,
+ lastPlayed: quietHandler,
+ nowPlaying: quietHandler,
+ scrobbled: quietHandler,
+ stoppedPlaying: quietHandler
+}
+
+var lastfm = new LastFmNode({
+ api_key: config.api_key,
+ secret: config.secret
+});
+
+var context = repl.start().context;
+context.lastfm = lastfm;
+context._echoHandlers = _echoHandlers;
+context._quietHandlers = _quietHandlers;
View
3  lib/lastfm/lastfm-request.js
@@ -59,6 +59,9 @@ var LastFmRequest = module.exports = function(lastfm, method, params) {
requestParams.artist = params.track.artist["#text"];
requestParams.track = params.track.name;
requestParams.mbid = params.track.mbid;
+ if (params.track.album) {
+ requestParams.album = requestParams.album || params.track.album["#text"];
+ }
}
if (requiresSignature()) {
requestParams.api_sig = createSignature(requestParams, lastfm.secret);
View
3  tests/common.js
@@ -1,5 +1,4 @@
var path = require("path");
-require.paths.unshift(path.dirname(__dirname)+'/lib');
global.Gently = require("gently");
global.GENTLY_HIJACK = new Gently();
global.assert = require("assert");
@@ -8,7 +7,7 @@ global.it = ntest.it;
global.describe = ntest.describe;
global.before = ntest.before;
global.after = ntest.after;
-global.LastFmNode = require("lastfm").LastFmNode;
+global.LastFmNode = require("../lib/lastfm").LastFmNode;
global.FakeData = require("./TestData.js").FakeData;
global.FakeTracks = require("./TestData.js").FakeTracks;
if (process.setMaxListeners) {
View
2  tests/lastfm-base-test.js
@@ -1,5 +1,5 @@
require('./common');
-var LastFmBase = require("lastfm/lastfm-base");
+var LastFmBase = require("../lib/lastfm/lastfm-base");
(function() {
describe("LastFmBase");
View
4 tests/lastfm-info-test.js
@@ -1,6 +1,6 @@
require("./common.js");
-var LastFmInfo = require("lastfm/lastfm-info");
-var LastFmRequest = require("lastfm/lastfm-request");
+var LastFmInfo = require("../lib/lastfm/lastfm-info");
+var LastFmRequest = require("../lib/lastfm/lastfm-request");
var fakes = require("./fakes");
(function() {
View
2  tests/lastfm-info-track-test.js
@@ -1,6 +1,6 @@
require("./common.js");
-var LastFmInfo = require("lastfm/lastfm-info")
+var LastFmInfo = require("../lib/lastfm/lastfm-info")
, fakes = require("./fakes");
(function() {
View
25 tests/lastfm-read-test.js
@@ -201,6 +201,31 @@ var LastFmRequest = fakes.LastFmRequest;
expectDataPair("mbid", "1234567890");
});
+ it("converts track object album details to separate parameters", function() {
+ whenMethodIs("any.method");
+ andParamsAre({
+ track: {
+ artist: { "#text": "The Mae Shi" },
+ name: "Run To Your Grave",
+ album: { "#text": "HLLLYH" }
+ }
+ });
+ expectDataPair("album", "HLLLYH");
+ });
+
+ it("does not overwrite explicitly set album parameters", function() {
+ whenMethodIs("any.method");
+ andParamsAre({
+ track: {
+ artist: { "#text": "The Mae Shi" },
+ name: "Run To Your Grave",
+ album: { "#text": "HLLLYH" }
+ },
+ album: "Run To Your Grave"
+ });
+ expectDataPair("album", "Run To Your Grave");
+ });
+
it("doesn't include mbid if one isn't supplied", function() {
whenMethodIs("any.method");
andParamsAre({
View
4 tests/lastfm-recenttracks-stream-test.js
@@ -1,8 +1,8 @@
require("./common.js");
var _ = require("underscore")
- , RecentTracksStream = require("lastfm/recenttracks-stream")
- , LastFmRequest = require("lastfm/lastfm-request")
+ , RecentTracksStream = require("../lib/lastfm/recenttracks-stream")
+ , LastFmRequest = require("../lib/lastfm/lastfm-request")
, fakes = require("./fakes");
(function() {
View
2  tests/lastfm-request-test.js
@@ -1,6 +1,6 @@
require("./common");
var _ = require("underscore"),
- LastFmRequest = require("lastfm/lastfm-request"),
+ LastFmRequest = require("../lib/lastfm/lastfm-request"),
fakes = require("./fakes");
(function() {
View
2  tests/lastfm-session-test.js
@@ -1,5 +1,5 @@
require('./common.js');
-var LastFmSession = require('lastfm/lastfm-session');
+var LastFmSession = require('../lib/lastfm/lastfm-session');
var fakes = require("./fakes");
(function() {
View
4 tests/lastfm-update-test.js
@@ -1,6 +1,6 @@
require('./common.js');
-var LastFmSession = require('lastfm/lastfm-session');
-var LastFmUpdate = require('lastfm/lastfm-update');
+var LastFmSession = require('../lib/lastfm/lastfm-session');
+var LastFmUpdate = require('../lib/lastfm/lastfm-update');
var fakes = require("./fakes");
(function() {
View
2  tests/tests.sh
@@ -12,3 +12,5 @@ nvm use v0.4.7
node ./index.js
nvm use v0.4.8
node ./index.js
+nvm use v0.6.2
+node ./index.js
Please sign in to comment.
Something went wrong with that request. Please try again.