Socket
Socket
Sign inDemoInstall

lastfm

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lastfm - npm Package Compare versions

Comparing version 0.9.2 to 0.9.3

test-app.js

6

History.md
# Changelog
## 0.9.3
* Fix incorrect port during https requests (omnichronous)
* Make port configurable
* Enable extended info in track stream (robbiet480)
* Cope with missing tracks in getRecentTracks response (dancoates, theNailz)
## 0.9.1

@@ -4,0 +10,0 @@ * Updated package information for Debian packaging (andrewrk)

1

lib/lastfm/index.js

@@ -15,2 +15,3 @@ var RecentTracksStream = require("./recenttracks-stream"),

this.useragent = options.useragent || "lastfm-node";
this.port = undefined || options.port;
};

@@ -17,0 +18,0 @@

6

lib/lastfm/lastfm-request.js

@@ -31,5 +31,5 @@ if (global.GENTLY_HIJACK) require = GENTLY_HIJACK.hijack(require);

sendRequest(lastfm.host, lastfm.url, params);
sendRequest(lastfm.host, lastfm.port, lastfm.url, params);
function sendRequest(host, url, params) {
function sendRequest(host, port, url, params) {
var httpVerb = isWriteRequest() ? "POST" : "GET"

@@ -43,3 +43,3 @@ var requestParams = buildRequestParams(params);

host: host,
port: 80,
port: port,
path: url,

@@ -46,0 +46,0 @@ method: httpVerb,

@@ -41,6 +41,7 @@ var LastFmBase = require("./lastfm-base");

function check() {
var request = lastfm.request("user.getrecenttracks", {
user: user,
limit: 1
});
var requestOptions = { user: user, limit: 1 }
if (options.extended) {
requestOptions.extended = 1;
}
var request = lastfm.request("user.getrecenttracks", requestOptions);
request.on("success", handleSuccess);

@@ -60,3 +61,11 @@ request.on("error", bubbleError);

var tracks = data.recenttracks.track;
if (tracks instanceof Array) {
if (!(tracks instanceof Array)) {
tracks = [tracks];
}
if (tracks.length == 0) {
return;
}
if (tracks.length >= 2) {
processNowPlaying(tracks[0]);

@@ -67,3 +76,3 @@ processLastPlay(tracks[1]);

var track = tracks;
var track = tracks[0];
if (track["@attr"] && track["@attr"]["nowplaying"]) {

@@ -70,0 +79,0 @@ processNowPlaying(track);

{
"name": "lastfm",
"description": "Read and write to Last.fm",
"version": "0.9.2",
"version": "0.9.3",
"author": "James Scott <jammus@gmail.com>",

@@ -26,3 +26,3 @@ "contributors": [

"devDependencies": {
"gently": ""
"gently": "^0.10.0"
},

@@ -29,0 +29,0 @@ "main": "./lib/lastfm/index",

@@ -19,2 +19,12 @@ # lastfm-node

## Tests
Tests currently use a very old testing framework found at https://github.com/mynyml/ntest. You can get them running by cloning that repository and doing
$ ln -s /path/to/ntest/lib node_modules/ntest
Then run the tests
$ node tests/
## Documentation

@@ -94,2 +104,6 @@

- *extended*
Includes extended data in each artist, and whether or not the user has loved each track
- *handlers*

@@ -96,0 +110,0 @@

@@ -62,3 +62,3 @@ require("./common.js");

it("doesnt pass through callback parameters", function() {
it("doesn't pass through callback parameters", function() {
gently.expect(lastfm, "request", function(method, params) {

@@ -65,0 +65,0 @@ assert.ok(!params.error);

@@ -17,2 +17,6 @@ require("./common.js");

});
it("has no port configure by default", function() {
assert.equal(undefined, lastfm.port);
});
})();

@@ -29,3 +33,4 @@

secret: "ghijk67890",
host: "test.audioscrobbler.com"
host: "test.audioscrobbler.com",
port: 8080
});

@@ -45,2 +50,6 @@ })

});
it("configures port", function() {
assert.equal(8080, lastfm.port);
});
})();

@@ -149,5 +149,5 @@ require('./common');

it("default to port 80", function() {
it("default port to undefined", function() {
whenMethodIs("any.method");
expectRequestOnPort(80);
expectRequestOnPort(undefined);
});

@@ -383,2 +383,14 @@

});
it("uses configured port and host when supplied", function() {
lastfm = new LastFmNode({
api_key: "key",
secret: "secret",
host: "audioscrobbler.localhost",
port: 8080
});
whenMethodIs("any.method");
expectRequestToHost("audioscrobbler.localhost");
expectRequestOnPort(8080);
});
})();

@@ -174,2 +174,31 @@ require("./common.js");

it("emits nothing when tracks empty", function() {
whenRequestEmits({
recenttracks: { track: [] }
});
expectStreamToEmit(0, function() {
assert.fail('Should not emit any tracks');
});
});
it("emits now playing if array contains single track flagged now playing", function() {
whenRequestEmits({
recenttracks: { track: [FakeTracks.RunToYourGrave_NP] }
});
expectStreamToEmit(function(event, track) {
assert.equal("nowPlaying", event);
assert.equal("Run To Your Grave", track.name);
});
});
it("emits last played when single track received if array", function() {
whenRequestEmits({ recenttracks: { track:
[FakeTracks.LambAndTheLion]
} });
expectStreamToEmit(function(event, track) {
assert.equal("lastPlayed", event);
assert.equal("Lamb and the Lion", track.name);
});
});
it("emits stoppedPlaying track when now playing stops", function() {

@@ -176,0 +205,0 @@ ifRequestHasPreviouslyEmit([

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc