simple-lastfm icon indicating copy to clipboard operation
simple-lastfm copied to clipboard

Fix getSessionKey

Open martindale opened this issue 13 years ago • 2 comments

The format that LastFM was returning did not appear to be handled correctly, so I went ahead and inspected the format and modified index.js to reflect where the keys were.

martindale avatar Dec 01 '12 17:12 martindale

Hi there!

I'm trying to get the scrobbling running for plast.fm and plug.dj. So I used the code provided to this package:

...Some Plug.dj-Code before...

var Lastfm = require('simple-lastfm'); var lastfm = new Lastfm({ api_key: 'xxx', api_secret: 'xxx', username: 'xxx', password: 'xxx' });

...some more Plug.dj-Code...

console.log('New song: ' + JSON.stringify(data));

lastfm.getSessionKey(function(result) { console.log("session key = " + result.session_key);

if(result.success) { console.log("session key = success");

bot.chat("@" + bot.getDJs()[0].username + " is playing: :sound: " + bot.getMedia().author + " - " + bot.getMedia().title + "");

console.log(data);

lastfm.scrobbleNowPlayingTrack({ artist: bot.getMedia().author, track: bot.getMedia().title, callback: function(result) { console.log("in callback, finished: ", result); } }); console.log("scrobbled");

So the terminal outputs first the session-key, then my console.log-entry for "session key success" gets displays, and the console.log(data) as well. Inside the chat-window the now playing artist and tracktitle are displayed.

But I don't get any scrobble to lastfm submitted, nor the console.log (scrobbled), which should be outputted after the successfull scrobble is missing. So the problem must be at

callback: function(result)

I guess.

I also tried the "Fix handshake problem" by martindale. When I ran the script using this fix i did get the following output:

{ '@': { status: 'ok' }, session: { name: 'xxxCORRECT NAME

So I guess everything should be fine? But I returned to the original.js, because using it with the fix didn't provide me any output in the terminal after:

console.log('New song: ' + JSON.stringify(data));

Any tip on getting this to work?

70hundert avatar Jan 30 '14 11:01 70hundert

is this PR still useful ?

Shuunen avatar Jun 07 '17 13:06 Shuunen