newgiin / cloudplayer-scrobbler

Chrome plugin for scrobbling from Google Play (music.google.com)
52 stars 15 forks source link

Scrobbles aren't saving #23

Open eemmeme opened 9 years ago

eemmeme commented 9 years ago

When I visit my last.fm page, I can only see the most recent, "listening now" song, but the previous songs that I've listened to aren't saved as Scrobbles.

ibullock commented 9 years ago

I can confirm this is happening for me as well. Occasionally 1-2 tracks per album will actually save.

newgiin commented 9 years ago

It works fine for me, can you confirm that you only have one Google Music tab open? Scrobbles can be missed if you have multiple music tabs open.

ibullock commented 9 years ago

Confirmed, no other Google Music tabs open. I do have the mini player open most of the time if that helps.

DHNishi commented 9 years ago

I am encountering this issue as well on OS X. I have a single Google Music tab open and I have had this tab open while using the scrobbler. My computer has been restarted several times during the past few days and this has not resolved the issue.

The Listening Now is populated correct but everything else is not, as with @eemmeme. A small fraction of my listened tracks are actually saved as with @ibullock.

newgiin commented 9 years ago

Sorry, I haven't had time to look into this lately.

Are any of you familiar with Javascript? If so, it'd help if you could debug this line (https://github.com/newgiin/cloudplayer-scrobbler/blob/google-music/js/background.js#L63), it sounds like you're never getting past that 'if' condition which checks if the time a song played is greater than 70% of the song length or 7 minutes. Either that or the call to last.fm isn't working.

If you're familiar with the Chrome javascript console, you can inspect that Javascript while a song is playing if you go to chrome://extensions, go down to the extension, and click "Inspect views: background page". I'd be happy to walk you through it if you're interested in playing around with the code.

Otherwise I'll look into this more tonight and add some logging to see what's going on.

DHNishi commented 9 years ago

I tried a short song and the checks succeed. After the first song scrobbled, future songs had the following error occur on every tick: "Last.fm track.updateNowPlaying error: 6" which corresponds to a missing required field from the updateNowPlaying field.

Upon hitting the scrobble threshold on any song after the first, scrobble_song's lastfm_api call triggers a "Last.fm track.scrobble error: 6"

At some point in time, this error stops appearing. I was unable to find the call where it stopped appearing, but I'll try to get the form data for you.


In another song, the time_played threshold failed to pass the _p.song.time * SETTINGS.scrobble_point, despite playing through the whole song. The _p.song.time * SETTINGS.scrobble_point was 191.1, but the song ended with the time_played at 186. I suspect the refresh interval that you're adding by isn't being as accurate as intended and the error adds up enough to go under the 70% threshold.

I've noticed that if the background page dev tools are open, it seems to keep time pretty well. If it is left closed, it quickly falls behind (i.e. 33% too slow).

newgiin commented 9 years ago

I'm guessing the now_playing or scrobble call is not getting an artist or track which are the only two fields required for that method (I believe the error would be different if you were missing a session or API key) per http://www.last.fm/api/show/track.updateNowPlaying. Maybe a silly question, but perhaps your song is missing the artist name? The form data can be inspected on this line in params: https://github.com/newgiin/cloudplayer-scrobbler/blob/google-music/js/lastfm.js#L75

As for the song not hitting the scrobble point, a quickfix could be just to lower the scrobble threshold to 60 or 50%.

DHNishi commented 9 years ago

I'll make a pull request to instead change the time being added to being the time difference since last call, rather than the refresh.

We're not getting a message every 2 seconds exactly, sometimes it is closer to 3-4 seconds, causing the error.

https://github.com/newgiin/cloudplayer-scrobbler/pull/29


You're right on the first count, that song that happened to play just so happened to lack an Artist.

newgiin commented 9 years ago

Yeah that change would probably be better than lowering the scrobble threshold.

newgiin commented 9 years ago

Hey I just pushed out version 1.6.6, can you see if it works now? Thanks!

DHNishi commented 9 years ago

Looks good to me. My songs are scrobbling.

I suspect that with the new system we might have introduced a bug where if you close your laptop during playback and then re-open it a few minutes later, the next port message will be arriving way later than the song has been listened to, causing |time_played| to be set too far ahead because it is assuming that the song was playing the entire time and then causing a potential invalid scrobble.

I haven't tried that scenario yet, but if it occurs we could potentially just count an abnormally long delay between port messages to not be counted.