aquelemiguel / parrot

🦜 A hassle-free, highly performant, self-hosted Discord music bot with YouTube and Spotify support. Powered by yt-dlp.
MIT License
134 stars 43 forks source link

Last.fm support #138

Open aquelemiguel opened 2 years ago

aquelemiguel commented 2 years ago
afonsojramos commented 2 years ago

Depending on how the /lastfm register will work, we will likely need to save some sort of token.

It is not required, but we should take care of #124 before this.

afonsojramos commented 2 years ago

If that's okay, I'd like to start looking into this issue @aquelemiguel.

aquelemiguel commented 2 years ago

@afonsojramos Sure. ☺️

Educorreia932 commented 1 year ago

I don't know if any progress had been made, but I started working on this feature in a separate fork

Currently it's scrobbling the played track for users listening to it and with their Last.fm account registered in the bot Registration is made by providing a temporary token to the bot so that it generates a session key for that user, which is then stored in GuildSettings

I'm not sure how and when to trigger the scrobbling. It should be 30 seconds into a track, so a delayed event would do, but things like pausing/resuming the track or ending the track sooner would have to be taken into account

afonsojramos commented 1 year ago

I'll pass on the torch to you then @Educorreia932!

Why do you say "It should be 30 seconds into a track"? On Spotify it starts tracking as soon as I skip into the song 🤔

Educorreia932 commented 1 year ago

Why do you say "It should be 30 seconds into a track"? On Spotify it starts tracking as soon as I skip into the song thinking

Apparently the conditions to scrobble a track are slightly different. According to Last.fm documentation:

A track should only be scrobbled when the following conditions have been met:

  • 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.)

Although, these are just guidelines, nothing prevents the track from being scrobbled as soon as the track is played.

afonsojramos commented 1 year ago

For an initial implementation we can focus on implementing just the start listening and ignoring the pausing of tracks (assuming that Last.FM finishes the track after its full duration).

Educorreia932 commented 1 year ago

There is a problem. To scrobble a track, both artist and title are required, although I don't know if currently we have that information when playing from YouTube

afonsojramos commented 1 year ago

That is, indeed, the source of the issue with this. Not everything that plays is music, and when it is music, the music might not even exist on Last.FM. So some parsing will need to be made to figure out the artist and match it to the artist on LastFM.