jammus / lastfm-node Goto Github PK
View Code? Open in Web Editor NEWRead and write to Last.fm with node.js
Home Page: http://return12.tumblr.com/tagged/lastfm-node
License: MIT License
Read and write to Last.fm with node.js
Home Page: http://return12.tumblr.com/tagged/lastfm-node
License: MIT License
SyntaxError: Unexpected end of input
at Object.parse (native)
at /usr/local/lib/node/.npm/lastfm/0.4.3/package/lib/lastfm-node/lastfm-info.js:41:21
at IncomingMessage. (/usr/local/lib/node/.npm/lastfm/0.4.3/package/lib/lastfm-node/response-reader.js:5:37)
at IncomingMessage.emit (events:41:20)
at HTTPParser.onMessageComplete (http:107:23)
at Client.onEnd as onend
at IOWatcher.callback (net:472:28)
at node.js:768:9
User info such as image, etc should be included in session info.
Hi,
I'm building an app with React (still learning).
I've installed your package, but I don't know if I can use it with React ?
I've got this error fired :
TypeError: require is not a function
at lastfm-request.js:3
Here's a part of my code:
import {LASTFM_API,LASTFM_API_SECRET} from "./Constants";
import {LastFmNode} from 'lastfm';
export class Lastfm {
static scrobbleTrack(track): void {
console.log("scrobbleTrack",track);
var lastfm = new LastFmNode({
api_key: LASTFM_API, // sign-up for a key at http://www.last.fm/api
secret: LASTFM_API_SECRET,
useragent: 'appname/vX.X MyApp' // optional. defaults to lastfm-node.
});
}
}
Thanks a lot !
In the plugin settings the host is specified protocol-relative:
lastfm-node/lib/lastfm/index.js
Line 10 in 722b8bf
however the port is hardcoded to be 80
lastfm-node/lib/lastfm/lastfm-request.js
Line 42 in 722b8bf
Because of this, any request made from a HTTPS domain (like Github Pages) tries to use https://
with port 80 and fails.
Simply removing the hardcoded port setting would fix the problem.
LastFM Api is down now and looks like thethis NPM package is never timeout the requests which cause the code to be stuck, any idea which parameters need to provide to the request
(or any other) method to enable the timeout?
I reviewed your tests and its possible integrate with travis for testing different node versions.
For example, a typical .travis.yml
file for setup configuration are:
language: node_js
node_js:
- '0.10'
- 'VERSION_YOU_LIKE'
- '...'
Also indicate in your package.json
in the script zone the script for init the tests:
"scripts": {
"test": "sh test/test.sh"
And activate your account in Travis. Is free :-)
Maybe http://cssgrid.net/ can help.
Session.authorize does not call neither error, nor authorised handlers on my new prefix with node-0.4.7, npm and lastfm-0.6.0.
Switched back to my old prefix with node-0.4.6, npm and lastfm-0.6.0 and my app works fine.
What the title says. I've been trying for a while, but I can't make the 'scrobble' method to work as intended.
Let's say I want to scrobble "Let Me Love You" by "DJ Snake" and capture that data in a variable track
and I have a valid session called mySession
.
To update the Now Playing status I call this when the song starts:
oldDate = Date.now(); lastfm.update('nowplaying', mySession, { track: track } );
And that in turn would post this payload
track = Let Me Love You
&sk = MY_SESSION_KEY
&method = track.updateNowPlaying
&api_key = MY_KEY
&format = json
&artist = DJ Snake
&album = Encore
&api_sig = CALCULATED_SIGNATURE
to http://ws.audioscrobbler.com/2.0
and I successfully get this response in return:
{
"nowplaying":{
"artist":{
"corrected":"0",
"#text":"DJ Snake"
},
"track":{
"corrected":"0",
"#text":"Let Me Love You"
},
"ignoredMessage":{
"code":"0",
"#text":""
},
"albumArtist":{
"corrected":"0",
"#text":""
},
"album":{
"corrected":"0",
"#text":"Encore"
}
}
}
Everything fine there. But then, once the song is over, I call this:
lastfm.update('scrobble', mySession, { track: track, timestamp: oldDate });
which is equivalent to posting this payload to the API endpoint:
track = Let Me Love You
×tamp = 1693943468324
&sk = SAME_SESSION_KEY
&method = track.updateNowPlaying
&api_key = SAME_API_KEY
&format = json
&artist = DJ Snake
&album = Encore
&api_sig = SAME_CALCULATED_SIGNATURE
but the scrobble is not registered, and I get this response:
{
"scrobbles":{
"scrobble":{
"artist":{
"corrected":"0",
"#text":"DJ Snake"
},
"album":{
"corrected":"0",
"#text":"Encore"
},
"track":{
"corrected":"0",
"#text":"Let Me Love You"
},
"ignoredMessage":{
"code":"1",
"#text":""
},
"albumArtist":{
"corrected":"0",
"#text":""
},
"timestamp":"1693943468324"
},
"@attr":{
"ignored":1,
"accepted":0
}
}
}
Honestly I can't figure out why the song is ignored. The API documentation seem to suggest that the song is ignored because of the artist, but that doesn't make sense, in that case track.updateNowPlaying
would ignore it too. I read the payload generated by your library, and everything looks fine, but for some reason, it doesn't work.
Getting such error when using webpack
How can this be fixed?
Rework track object to remove things like #text and @attr. Include raw field to store original data incase preferred.
track: {
name: "name",
artist: { name: "name", mbid: "mbid" },
images: {small: {}, medium: {}, large: {}},
album: { name: "name", mbid: "mbid" },
url: "url",
raw: "raw"
}
For example "Tony's Theme" by Pixies
I wanted to use lastfm.session('USER', 'KEY').authorise('TOKEN')
method to determine whether or not the user has authorised a session. The plan was to invoke the method periodically and deal with the failures and successes. However, every time I invoke the function new handlers are registered and invoked on top of all the others.
I'm not sure if this is specific to scrobbling from Spotify but I'm running into an issue where after having stopped playing for a while recenttracks.track
will be an array with only one item. This breaks the handleSuccess
function as it passes recenttracks.track[1]
to processLastPlay()
which then tries to access the name
property of undefined.
error log:
2016-10-18T00:29:21.429Z - error: TypeError: Cannot read property 'name' of undefined
at processLastPlay (node_modules/lastfm/lib/lastfm/recenttracks-stream.js:98:44)
at EventEmitter.handleSuccess (node_modules/lastfm/lib/lastfm/recenttracks-stream.js:61:9)
at emitOne (events.js:96:13)
at EventEmitter.emit (events.js:188:7)
at IncomingMessage.<anonymous> (node_modules/lastfm/lib/lastfm/lastfm-request.js:123:14)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Tracks object that the code is trying to process:
{ recenttracks:
{ track: [ [Object] ],
'@attr':
{ user: 'username',
page: '1',
perPage: '1',
totalPages: '117650',
total: '117650' } } }
I'll submit a PR in a min to fix this.
Hi,
we are going to include your module in Debian and Ubuntu.
But we have some problem here.. our automatic systems check for tags in github when look for a new release.
It seems you do not provide a tag for version 0.9.0. Could you please make it? and use them in the future?
Thanks in advance.
It looks like duration does not work with updateNowPlaying. Any idea on how I can fix this?
Not sure if I did it right, but I get my token (which does work) after that I tried to update my scrobble and I get Error 14, "Unauthorized token".
lastfm.request("auth.gettoken", {
handlers: {
success: function(data) {
let token = data.token;
let track = {
artist: "TWICE",
track: "TT",
timestamp: + new Date()
}
var sessions = lastfm.session({
token: token,
handlers: {
success: function(session) {
console.log(session)
lastfm.update('nowplaying', session, { track: track } );
lastfm.update('scrobble', session, { track: track, timestamp: + new Date() });
},
error: function(track, err) {
console.log(track, err)
},
retrying: (retry) => {
console.log(retry)
}
}
});
},
error: function(error) {
console.log("Error: " + error.message);
}
}
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.