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

Last.FM Integration #18

Closed
5 tasks done
deluan opened this issue Jan 21, 2020 · 23 comments · Fixed by #2061
Closed
5 tasks done

Last.FM Integration #18

deluan opened this issue Jan 21, 2020 · 23 comments · Fixed by #2061

Comments

@deluan
Copy link
Member

deluan commented Jan 21, 2020

  • scrobble
  • getArtistInfo2
  • getTopSongs
  • getSimilarSongs
  • getAlbumInfo

There should be a way to disable the integration, for those users concerned with privacy.

@tcurdt
Copy link
Contributor

tcurdt commented May 16, 2020

...and it would be great to have the URL configurable so one could use a self hosted service.

@arg274
Copy link
Contributor

arg274 commented Jul 11, 2020

  • Following the discussion on Discord, ND should use the albumArtist param in its scrobbling as opposed to the implementation in other *sonic servers. Both Track.scrobble and Track.updateNowPlaying in the last.fm API allow the param to be included. The default behaviour of last.fm is to assume that the artist and the album artist are the same when it's omitted and that's a pretty easy way to mess the datasets up if compilations are played and scrobbled.
    If a 20-track compilation album (w/ 'Various Artists' as the album artist) with 20 different artists is played for example, the album will get split across all the individual artists. So instead of last.fm displaying 20 plays for one album (provided that the album has been played once), it will create 20 albums with the same name but with different album artists, with each album having a single play. There will not be a single album with 'Various Artists' as the album artist. Most of the third-party last.fm scrobblers get this behaviour wrong, and the messy (and incorrect) data is the price to pay. It's something that doesn't get noticed due to how the last.fm UX chooses to show its data. For example, if a compilation-exclusive track is scrobbled, and if last.fm has all the prerequisites present in their DB to recognise the track, clicking on the track name from the 'Scrobbles/Recent Scrobbles' sections will bring up the track page, where the album might have 'Various Artists' as the album artist under the 'From the Album' section. Here's the catch. That section only represents data from the track in general and does not represent the data you've scrobbled. To get to the album page of the album that one has actually scrobbled, the small cover art next to each scrobble needs to be clicked. And if the album page that follows cites the track artist as the album artist for the entire album, that's where the trouble begins.
  • last.fm has a terrible reputation of being down. Scrobbling needs to be cached and robust enough to make sure that duplicate scrobbles don't take place if stuff from the backlog are scrobbled.
  • A lot of the options (Airsonic web UI being one) don't follow the scrobble standards set up by last.fm and the ND web UI needs to make sure that the same doesn't happen. The standards for a scrobble to be valid are 50% of the track or 4-minute playback of the track, whichever comes first. It's not scrobble instantly after a track is clicked on or scrobble in hard mode only when the track is played 100% without any pauses. The standard has a balance. Bad scrobbling implementations don't account for these standards and that is exactly why they're bad.

@deluan
Copy link
Member Author

deluan commented Jul 11, 2020

Currently Navidrome UI send a "submit" scrobble when it has played 90% of the song:
https://github.com/deluan/navidrome/blob/865bad155043cc3b672b4ebc2764187aa1b3e842/ui/src/audioplayer/Player.js#L115
Just the server side is not implemented yet.

I'm ok with changing this to a standard if there is one. Can you post a reference to where you found such standard?

What are your thoughts about similar services (Ex: ListenBrainz)?

@arg274
Copy link
Contributor

arg274 commented Jul 11, 2020

Can you post a reference to where you found such standard?

https://www.last.fm/api/scrobbling#when-is-a-scrobble-a-scrobble
50% is the minimum, which is the default for most of the official implementations like their own scrobblers or the Spotify integration.

What are your thoughts about similar services (Ex: ListenBrainz)?

Listenbrainz is still severely lacking in most areas. It's still in Beta, so I'll give it that. Its 'Import from last.fm' seems to be problematic, so additional support for it wouldn't be bad and a lot of the newer apps seem to have support for it. I don't think that it should be the only option or that it can substitute last.fm for the moment being, however. I don't know of a single person who uses libre.fm, though. 😛

@deluan
Copy link
Member Author

deluan commented Aug 27, 2020

...and it would be great to have the URL configurable so one could use a self hosted service.

@tcurdt (or anyone else): Is there a self-hosted service compatible with Last.FM API v2?

@tcurdt
Copy link
Contributor

tcurdt commented Aug 27, 2020

...and it would be great to have the URL configurable so one could use a self hosted service.

@tcurdt (or anyone else): Is there a self-hosted service compatible with Last.FM API v2?

I am not aware of one - but with a configurable URL at least one could build one to get the scrobbles :)

I am not really using Last.FM anymore.
I would be mostly interested in a webhook style notification to connect it to e.g. Zapier or whatever.

@deluan
Copy link
Member Author

deluan commented Sep 2, 2020

I would be mostly interested in a webhook style notification to connect it to e.g. Zapier or whatever.

That's a nice feature to have! No rush, but can you please open a new issue describing what hooks/events/info you'd like to see in such feature?

@tcurdt tcurdt mentioned this issue Sep 2, 2020
@spezifisch
Copy link

spezifisch commented Sep 25, 2020

* A lot of the options (Airsonic web UI being one) don't follow the scrobble standards set up by last.fm and the ND web UI needs to make sure that the same doesn't happen. The standards for a scrobble to be valid are 50% of the track or 4-minute playback of the track, whichever comes first. It's not _scrobble instantly after a track is clicked on_ or _scrobble in hard mode only when the track is played 100% without any pauses_. The standard has a balance. Bad scrobbling implementations don't account for these standards and that is exactly why they're _bad_.

I have encountered the same problem implementing Subsonic API scrobble calls in Strawberry. The underlying problem seems to me that Subsonic's API doesn't specify when the scrobble method should be called and they don't seem to care to adhere to the scrobbling specs.

Maybe it should be the client's (in ND's context the web-ui's) responsibility to call it at an appropriate time, considering (1) that they can do it more easily, and (2) all other Subsonic servers that I know of just proxy the request through to Last.FM without delay or queue management. As you pointed out, there would be quite a few considerations on the server side to handle this well.

I don't know if you raised this point on Discord, but one big problem with the current implementation in clients like Airsonic and Ultrasonic is: They only call /rest/scrobble at the song start. It seems you cannot know if the user then stopped the track before reaching 50% or 4 minutes.

Anyway most clients already have their own scrobbling queue management with correct scobbling timing. So I would propose it's cleanest to plug in the /rest/scrobble call there. That way the Last.FM/ListenBrainz API specs are fulfilled and the scrobbling timestamps are correct if clients submit the time parameter with the song start timestamp. Strawberry does it this way.

Can you post a reference to where you found such standard?

https://www.last.fm/api/scrobbling#when-is-a-scrobble-a-scrobble
50% is the minimum, which is the default for most of the official implementations like their own scrobblers or the Spotify integration.

ListenBrainz specifies pretty much the same btw, see https://listenbrainz.readthedocs.io/en/production/dev/api/#reference.

@SteveDinn
Copy link

I'm having trouble getting scrobbling to Last FM working. I have the configuration in a YAML file, and the log isn't showing that it can't find the LastFM API key/secret like it would it those values were absent. I see a "scrobbling" log entry, but nothing ever makes it to Last FM.

time="2020-10-30T01:51:16Z" level=info msg="Now Playing" artist="Green Day" title="Platypus (I Hate You)" user=steve

Maybe I've just screwed up the format of the config file? I would think that it would tell me it couldn't find the Last FM config values if that were the case though.

My config (navidrome.yml):

ScanInterval: 1m
LogLevel: info
BaseUrl: ""
LastFM:
  ApiKey: [redacted]
  Secret: [redacted]
  Language: en

@deluan
Copy link
Member Author

deluan commented Oct 30, 2020

Hey @SteveDinn , currently Navidrome only uses Last.FM for getting artist metadata, it does not submit played tracks yet. "Scrobbling" in this case refers to the Subsonic API endpoint name (it is confusing, I know) but as I said in ##593 (comment):

Currently Navidrome uses this only to register the play, and does not send the scrobble to Last.FM, even if Last.FM is configured. Scrobbling to Last.FM is coming in a future release (sooner than later)

@SteveDinn
Copy link

I need to read more closely. I must be tired :) Thanks again.

@SteveDinn
Copy link

Where does this metadata from LastFM show itself in Navidrome? I am still not convinced I have the configuration correct.

@deluan
Copy link
Member Author

deluan commented Nov 2, 2020

Last.FM (and Spotify) integration are currently only used for the getArtistInfo Subsonic API call, they are not currently used by the Web UI. To see it in action you'll need a Subsonic client that uses this call (Ex: DSub, play:Sub, MusicStash)

@elementalest
Copy link

I just started using Navidrome. So far I'm liking it much more than Airsonic, but currently it lacks Last.fm scrobbling. So its great to see it being worked on here and from the looks of it maybe ready for the next release!

One feature that would be nice is to use Last.fm (or spotify) to sync your track played count. Or at least on initial setup perform an import.

It would also be nice to use Last.fm/Spotify on a per user basis. From what I can tell its currently one API/Account for all users?

@deluan
Copy link
Member Author

deluan commented Nov 13, 2020

Scrobbling is coming, but not for the next release, I still have to refactor the current code to allow different integrations (offline, MusicBrainz, Libre.FM, etc...)

Importing from Last.FM could be done with a script. Unfortunately I don't have the time to write such script, but should be straightforward if you know a bit of Python: you could modify this code that imports from one server to another using the Subsonic API: https://github.com/peguerosdc/subimporter

The API keys are used for retrieving info only. For scrobbling, each user will have to grant permission for Navidrome to send the scrobbles to their account. This will be an option in the UI. So yes, it will be per user :)

@elementalest
Copy link

Ah, I see. Thanks for pointing me to that script and thanks for your work!

@archedraft
Copy link

When Navidrome uses Last.FM for getting artist metadata, does it also get the top rated song info as well?

@deluan
Copy link
Member Author

deluan commented Jan 10, 2021

@archedraft Not at the same time, but yes, Subsonic API getTopSongs is implemented and uses Last.FM's artist.getTopTracks

@AMoonRabbit
Copy link

I ditched Last.FM last year and solely use Listenbrainz for scrobbling so it would be good to see that added.

@darthdubu
Copy link

Just wanted to let people who are waiting for some sort of scrobbling know that Web Scrobbler just added support for Navidrome per my request (yay!). Web scrobbler supports Last.fm, Listenbrainz, Libre.fm, and Maloja!
web-scrobbler/web-scrobbler@5e62c92

@BobWs
Copy link

BobWs commented Feb 23, 2021

Will getTopSongs be implemented in the webUI? And if so will you implement the ability to create playlists from the results of getTopSong? That’s one of the features I miss most from Subsonic. For now I’m very happy with your app. Thanks for all your hard work.

@deluan
Copy link
Member Author

deluan commented Mar 5, 2021

@BobWs Yes it will. Yes, you'll be able to save the current play queue as a playlist

@github-actions
Copy link

github-actions bot commented Mar 7, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants