Navidrome: Last.FM Integration

Created on 21 Jan 2020  路  18Comments  路  Source: deluan/navidrome

  • [ ] scrobble
  • [x] getArtistInfo2
  • [x] getTopSongs
  • [x] getSimilarSongs
  • [ ] getAlbumInfo

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

enhancement

Most helpful comment

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

All 18 comments

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

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

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)?

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. 馃槢

...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?

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

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?

* 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.

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

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 #https://github.com/deluan/navidrome/issues/593#issuecomment-715646271:

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)

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

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

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)

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?

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 :)

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wanieru picture wanieru  路  3Comments

pagdot picture pagdot  路  4Comments

BobWs picture BobWs  路  3Comments

ericgaspar picture ericgaspar  路  4Comments

brianpierson2020 picture brianpierson2020  路  4Comments