Skip to content

Add Last.fm Recommendations music provider#3020

Open
OzGav wants to merge 1 commit intodevfrom
claude/debug-album-resolution-hooa2
Open

Add Last.fm Recommendations music provider#3020
OzGav wants to merge 1 commit intodevfrom
claude/debug-album-resolution-hooa2

Conversation

@OzGav
Copy link
Contributor

@OzGav OzGav commented Jan 26, 2026

A new music provider that generates recommendation folders using the Last.fm API. Recommendations are resolved to playable items via streaming providers (Spotify, etc).

Recommendation Rows

The provider generates up to 9 recommendation folders, each configurable via toggle:

Personalized (based on user's MA library play counts)

  • Discover Similar Artists: Top 5 most-played artists → 3 similar each → dedupe → first 10
  • Discover Similar Tracks: Top 5 most-played tracks → 3 similar each → dedupe → first 10

Global Charts (Last.fm worldwide data)

  • Global Top Artists: Request 15 → resolve → dedupe → first 10
  • Global Top Tracks: Request 15 → resolve → dedupe → first 10

Genre-based (requires Last.fm username)

  • Discover {Genre} Artists: User's top tag → 30 artists → filter library → top 3 + random 12 → resolve → first 10
  • Discover {Genre} Albums: User's top tag → 30 albums → filter library → top 3 + random 12 → resolve → first 10
  • Discover {Genre} Tracks: User's top tag → 30 tracks → filter library → top 3 + random 12 → resolve → first 10

Geographic (configurable country)

  • Top Artists in {Country}: Request 15 → resolve → dedupe → first 10
  • Top Tracks in {Country}: Request 15 → resolve → dedupe → first 10

Resolution Pipeline

  1. Last.fm API returns artist/track/album names with optional MusicBrainz IDs (MBIDs)
  2. For tracks: MBID → MusicBrainz API → ISRC lookup
  3. Search streaming providers by ISRC (preferred) or name+artist fallback
  4. Results cached at two levels: in-memory (session) and persistent (90 days)

Key Features

  • All recommendation rows are disabled by default (user enables what they want)
  • Configurable refresh interval (default 6 hours)
  • 15-second startup delay to allow streaming providers to load first
  • Genre rows use "top 3 + random sample" strategy with daily seed for variety
  • Library items filtered from genre recommendations to surface new music
  • Clear cache button in settings for manual refresh
  • Config changes take effect immediately on provider reload

@OzGav OzGav marked this pull request as draft January 26, 2026 16:34
@OzGav OzGav marked this pull request as ready for review January 26, 2026 16:35

return (
ConfigEntry(
key="api_key",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is an api key required ?
we can also check if we can get an API key for our application, maybe through sponsorship etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you do but they are easy to get individually

@@ -0,0 +1,11 @@
{
"type": "music",
"domain": "lastfm_recommendations",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I like the fact that we now have 2 lastfm providers.
We could potentially make this one the main provider and have the scrobbler depend on it or simply combine the 2 functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at that but the recommendations feature is only available for music providers whereas the scrobbler is currently a plugin. Also you need your own API key and session key to scrobble but only an API key to pull info. So it gets a bit messy?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok that is clear.
in that case I'm leaning towards making this a metadata provider and add support for recommendations from metadata modules to the core models because this is more a metadata provider than a music provider as it doesnt provide music on its own. Then suddenly also having similar tracks for filesystem items comes into reach meaning you can have radio mode for filesystem tracks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that it is unusual to call this a music providers. Let me know what direction to head in

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give me a few days so I can overthink the best approach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked Claude to come up with a proposal for a local radio mode and this is the result. Seems good to me? https://github.com/music-assistant/server/blob/claude/plan-lastfm-recommendations-lZsFl/RADIO_MODE_LOCAL_PLAN.md

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but with one comment is that its all contained in the provider alone and we just add the get_similar_tracks etc. to the metadata model so we can utlize this for any metadata provider - for example one day I like to add an AI one

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcelveldt is it confirmed to be as a metadata provider? I'm currently working on adding local file support to https://github.com/NeptuneHub/AudioMuse-AI with the plan to then use that as a radio feature for MA local files. I was looking at OzGrav's work for inspiration in how to implement it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes let's do this as metadata provider but we need a few small adjustments in core. I'll try to do so tomorrow or Tuesday but ping me if I forget

@OzGav OzGav force-pushed the claude/debug-album-resolution-hooa2 branch from 3208e61 to 39c8072 Compare January 26, 2026 17:10
A new music provider that generates recommendation folders using the Last.fm API.
Recommendations are resolved to playable items via streaming providers (Spotify, etc).

## Recommendation Rows

The provider generates up to 9 recommendation folders, each configurable via toggle:

### Personalized (based on user's MA library play counts)
- **Discover Similar Artists**: Top 5 most-played artists → 3 similar each → dedupe → first 10
- **Discover Similar Tracks**: Top 5 most-played tracks → 3 similar each → dedupe → first 10

### Global Charts (Last.fm worldwide data)
- **Global Top Artists**: Request 15 → resolve → dedupe → first 10
- **Global Top Tracks**: Request 15 → resolve → dedupe → first 10

### Genre-based (requires Last.fm username)
- **Discover {Genre} Artists**: User's top tag → 30 artists → filter library → top 3 + random 12 → resolve → first 10
- **Discover {Genre} Albums**: User's top tag → 30 albums → filter library → top 3 + random 12 → resolve → first 10
- **Discover {Genre} Tracks**: User's top tag → 30 tracks → filter library → top 3 + random 12 → resolve → first 10

### Geographic (configurable country)
- **Top Artists in {Country}**: Request 15 → resolve → dedupe → first 10
- **Top Tracks in {Country}**: Request 15 → resolve → dedupe → first 10

## Resolution Pipeline

1. Last.fm API returns artist/track/album names with optional MusicBrainz IDs (MBIDs)
2. For tracks: MBID → MusicBrainz API → ISRC lookup
3. Search streaming providers by ISRC (preferred) or name+artist fallback
4. Results cached at two levels: in-memory (session) and persistent (90 days)

## Key Features

- All recommendation rows are disabled by default (user enables what they want)
- Configurable refresh interval (default 6 hours)
- 15-second startup delay to allow streaming providers to load first
- Genre rows use "top 3 + random sample" strategy with daily seed for variety
- Library items filtered from genre recommendations to surface new music
- Clear cache button in settings for manual refresh
- Config changes take effect immediately on provider reload
@OzGav OzGav force-pushed the claude/debug-album-resolution-hooa2 branch from 39c8072 to 301d2fa Compare January 26, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants