Socket
Socket
Sign inDemoInstall

simple-lastfm

Package Overview
Dependencies
6
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

51

lib/index.js

@@ -359,2 +359,53 @@ var http = require('http');

Lastfm.prototype.getTracks = function(opt) {
// var the_callback = opt.callback;
var page = opt.page ? opt.page : 1;
http.get({
host: 'ws.audioscrobbler.com',
port: 80,
path: '/2.0/?method=user.getartisttracks&page=' + page + '&api_key=' + this.api_key + '&autocorrect=1&user=' + this.username + '&artist=' + encodeURIComponent(opt.artist)
}, function(res) {
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
var parser = new xml2js.Parser();
parser.parseString(body, function(err, result) {
if (typeof opt.callback == 'function') {
opt.callback(result);
}
});
});
});
};
Lastfm.prototype.getAllTracks = function(opt) {
var lastfm = this;
var the_callback = opt.callback;
var tracks = [];
opt.callback = function(result) {
if(result['@'].status == 'failed') {
the_callback({
success: false,
reason: result.error['#']
});
} else {
var numPages = result.artisttracks['@'].totalPages;
for(var i=0;i<result.artisttracks.track.length;i++) {
if(tracks.indexOf(result.artisttracks.track[i].name) < 0)
tracks.push(result.artisttracks.track[i].name);
}
if(result.artisttracks['@'].page < numPages) {
opt.page++;
lastfm.getTracks(opt);
} else {
the_callback({success: true, artist: result.artisttracks['@'].artist, tracks: tracks});
}
}
};
opt.page = 1;
this.getTracks(opt);
};
function now() {

@@ -361,0 +412,0 @@ return new Date().getTime();

2

package.json
{
"name": "simple-lastfm",
"description": "simple last.fm api for node.js",
"version": "1.0.3",
"version": "1.0.4",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc