musikcube icon indicating copy to clipboard operation
musikcube copied to clipboard

Last.fm scrobbling improvement

Open nero-0 opened this issue 4 years ago • 12 comments

The scrobble is sent immediately to last.fm recent tracks after clicking to play a song, even if you don't actually listen to it. It is not shown that the song is scrobbling on last.fm either. It would be great if it show that you are scrobbling now on last.fm while you play some music, as it happens while you do it on Spotify for example.

nero-0 avatar Nov 17 '19 18:11 nero-0

This one matters a lot for Last.fm scrobbling. You can't properly skip tracks without wrong information getting added.

tpurde avatar Jun 26 '21 19:06 tpurde

Thanks for bumping this one. I didn't remember how scrobbling actually worked, so I took a look at the code and found this comment... looks like it was something I had considered before but never implemented.

if (track && this->transport->GetStreamState() == StreamState::Playing) {
    /* TODO: maybe consider folding Scrobble() the `MarkTrackAsPlayed` logic?
    needs a bit more thought */
    lastfm::Scrobble(track);

    /* we consider a track to be played if (1) it enters the playing state and
    it's less than 10 seconds long, or (2) it enters the playing state, and
    remains playing for > 10 seconds */
    const double duration = this->transport->GetDuration();
    if (duration > 0 && duration < 10.0) {
        this->MarkTrackAsPlayed(track->GetId());
    }
    else {
        POST_DELAYED(this, MESSAGE_MARK_TRACK_PLAYED, track->GetId(), 0, 10000LL);
    }
}

In other words, you are absolutely right, we report the track scrobbled immediately when it enters the playing state. I think no matter what we do, there will always be some sort of heuristic to determine whether or not we consider a track to be "played" or not.

I think just migrating the implementation to do what the second comment says (consider it played if the user has listened to it for at least 10 seconds) would be a step in the right direction; it wouldn't be perfect, but it'd certainly eliminate a bunch of false positives.

Maybe instead of 10 seconds, we can consider it played if the user listens to at least 50% of it? But there may be weird cases if the user fast forwards through more than half of it. So maybe 25%? We could also report it as played if as soon as it reaches X seconds from the end... but it also has edge cases with fast forwarding.

Curious if anyone on this thread has other ideas.

clangen avatar Jun 26 '21 21:06 clangen

I think something like 25% would work. 50% would be too far in my honest opinion. For example, when I'm not listening to the whole album, I skip the beginning of Time by Pink Floyd. It would feel bad if that wouldn't count. Also, the "Scrobbling Now" status would be great too!

tpurde avatar Jun 26 '21 21:06 tpurde

Hey, can we get any news on this? @clangen Sorry if I'm disturbing, just makes it hard to listen to music with musikcube and last.fm.

tpurde avatar Jul 04 '21 23:07 tpurde

No real news to share, it's on my short list of things to work on next -- just need to find some time to sit down and do it. Real life and work have been keeping me pretty busy lately. :)

clangen avatar Jul 04 '21 23:07 clangen

Ah, again, sorry if I disturbed you. Good luck with everything!

tpurde avatar Jul 05 '21 11:07 tpurde

Sorry for the delay! This will be fixed in the next release (hopefully soon, as we have some issues across a couple different operating systems that are pending release) https://github.com/clangen/musikcube/commit/3cd6bc165fcd5d07025cd8392fdd3b1270684133

clangen avatar Jul 17 '21 19:07 clangen

No need at all to say sorry! I'll be installing the git version to test it. Thanks for all your work.

tpurde avatar Jul 17 '21 22:07 tpurde

@tpurde I actually just realized it's not going to work properly. I'll try to get a real fix out sometime in the next couple hours. :)

clangen avatar Jul 17 '21 22:07 clangen

OK, it should be fine now :)

clangen avatar Jul 17 '21 22:07 clangen

Thanks, I'll download and compile again. Have a great day!

tpurde avatar Jul 17 '21 22:07 tpurde

I can confirm that it works. Thanks for the update.

Screenshot-20210718022553-1105x725

tpurde avatar Jul 17 '21 23:07 tpurde