Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrobbles should happen earlier, not at the end of the song being played. #50

Open
csaavedra opened this issue Jun 7, 2023 · 0 comments

Comments

@csaavedra
Copy link

csaavedra commented Jun 7, 2023

There are several bugs with third party apps (like finamp) that cause this plugin to not scrobble tracks, and while checking those I realized one thing that this plugin does not do correctly, and fixing that could incidentally fix those problems. If I understand correctly, the plugin is using the stop event to decide whether to send a scrobble. This is not correct, as scrobbles should happen earlier, not when the track ends/stops playing.

The last.fm specification ( https://www.last.fm/api/scrobbling#when-is-a-scrobble-a-scrobble ) states that a track has to be scrobbled when:

  • The track must be longer than 30 seconds.
  • And the track has been played for at least half its duration, or for 4 minutes (whichever occurs earlier.)

The plugin should schedule a scrobble using a timeout when the track starts, using for the timeout MIN(track.length/2, 4*60). If the track is stopped at any point, cancel the timeout call if it has not happened yet (as this means that it has not played long enough to be submitted).

Doing it like this will prevent any problems with apps reporting stopping time wrongly, as it will be done independently of it.

(fwiw, I implemented a last.fm scrobbler over ten years ago, that's how I did it back then)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant