Coder Social home page Coder Social logo

lastfm-node's People

Contributors

andrewrk avatar edwardbetts avatar garrettwilkin avatar jammus avatar maxkueng avatar omnichronous avatar robbiet480 avatar thenailz avatar xhochy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

lastfm-node's Issues

Integrate with Travis for testing

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 :-)

Error with RecentTracksStream where tracks array has only one item

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.

session.authorize silently fails with node-0.4.7

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.

Scrobbles are ignored but Now Playing updates succesfully

What the title says. I've been trying for a while, but I can't make the 'scrobble' method to work as intended.

How to replicate:

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
&timestamp = 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.

Request method never timeouted

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?

LastFMSession#authorise isn't reusable

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.

how do u use this with react ? I got a "TypeError: require is not a function"

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 !

Replace raw track details with reworked object

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"
}

please git tag 0.9.0

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.

LastFmInfo does not handle exceptions thrown by JSON.parse

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

Error code 14 after receiving a new token

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);
        }
    }
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.