Skip to content

Plex: Add extended recommendations with "Mixes For You" support#3736

Merged
marcelveldt merged 1 commit into
music-assistant:devfrom
ajacobson:plex-extended-recommendations
Jul 19, 2026
Merged

Plex: Add extended recommendations with "Mixes For You" support#3736
marcelveldt merged 1 commit into
music-assistant:devfrom
ajacobson:plex-extended-recommendations

Conversation

@ajacobson

Copy link
Copy Markdown
Contributor

I'm a heavy user of Plexamp and using the Music Assistant Plex integration I noticed that a lot of the default recommendations are not available in Music Assistant. Specifically this adds Mixes For You (personalized mixes Plex generates from your listening history), "On This Day" anniversary releases, and shortcuts to library playlists — matching the hub set the official Plex clients show on their home screens.

Summary

  • Add a configurable "extended recommendations" mode that widens the Plex hubs query to include Mixes For You, library playlists, and On This Day — matching the hub set Plex's own clients surface.
  • Mixes For You are fetched as raw JSON (bypassing plexapi's broken partial-item parser) and exposed as shuffled playlists.
  • A mix: item prefix distinguishes mix playlists from regular ones, following the existing collection: convention.
  • The feature defaults to enabled and can be toggled in advanced config.

Notes

This feature is default-enabled, but the toggle lives in advanced config for anyone who wants the narrower, pre-existing hub set.

Why the raw JSON fetch for mixes?

plexapi can't currently materialize Mixes For You hub items — the <Metadata> type isn't in its PLEXOBJECTS registry, so _buildItem() silently drops them and server.hubs(...) returns an empty hub.

The provider issues one JSON GET against /hubs/sections/<key> for this hub and parses the response directly, routing token refresh through the existing helper. Registering the mix type upstream in plexapi is the right long-term fix but is out of scope here — once that lands, the raw fetch can be replaced with a plain server.hubs() call.

@OzGav

OzGav commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

@anatosun

@anatosun

Copy link
Copy Markdown
Contributor

I will have a look at this PR later this week. Have you had a chance to test the performance of this feature @ajacobson ?

@ajacobson
ajacobson force-pushed the plex-extended-recommendations branch from 82708d4 to 6effda2 Compare April 19, 2026 19:24
@ajacobson

Copy link
Copy Markdown
Contributor Author

Performance impact has been negligible in my testing. The net effect is one additional request (the Mixes For You fetch) plus a slightly wider primary hubs response, both gated by the 3-hour recommendations cache. CONF_HUB_ITEMS_LIMIT is honored for both paths.

I did notice an issue that trying to play a "mix" from "Recently played" after that mix has been rotated out of the Plex hub would lead to playback errors. I just amended the commit with a fix: when a mix is opened, its raw JSON is cached for 90 days (matching DB_TABLE_PLAYLOG retention), so replay works independently of hub state.

Here is what my Discover page looks like with the extended recommendations:
Plex Extended Recommendations

@OzGav

OzGav commented May 2, 2026

Copy link
Copy Markdown
Contributor

@anatosun Any update on this one?

@anatosun

anatosun commented May 3, 2026

Copy link
Copy Markdown
Contributor

It looks good and seems to work on my side.

The only thing that makes me a bit hesitant is the raw JSON request + manual parsing for the Mixes. I'm wondering why plexapi doesn't handle music.mixes items properly. Have you (or anyone) opened an issue upstream about this? It might be worth a quick upstream improvement so we don't have to maintain this workaround long-term.

@OzGav

OzGav commented May 17, 2026

Copy link
Copy Markdown
Contributor

@ajacobson Can you answer the question above?

@ajacobson

Copy link
Copy Markdown
Contributor Author

I agree an upstream plexapi improvement would be the right long-term fix.

I looked into this while building the PR, but the scope was larger than I wanted to take on here. plexapi’s hub parser currently materializes hub items through its registered object factory, and the "Mixes For You" hub returns <Metadata> entries that are not currently registered/handled. Fixing it properly would mean teaching plexapi how to parse those "Mixes For You" entries, including their nested centroid artist/Directory children, so callers can get the correct title, key, and artwork.

@OzGav

OzGav commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

@anatosun What are your thoughts now on this one?

@ajacobson
ajacobson marked this pull request as draft June 7, 2026 02:58
@ajacobson

Copy link
Copy Markdown
Contributor Author

I'll take a look at making the upstream changes to plexapi.

@ajacobson

Copy link
Copy Markdown
Contributor Author

I've opened the upstream plexapi PR: pushingkarmaorg/python-plexapi#1621

It adds the two pieces plexapi was missing for these items:

  • LibrarySection.hubs() now accepts query parameters (e.g. includeMyMixes=1, count=10), matching the signature Library.hubs() already has — so the mixes hub can be requested through the public API instead of a hand-built key.
  • A new Playlist.centroid property exposing the nested centroid artist a "Mix For You" is built around. This was the real gap: mix playlists have no thumb/composite of their own, so their artwork was previously unreachable without touching plexapi internals. The property is guarded so accessing it on partial objects never triggers an auto-reload.

Validated against a live PMS (mixes parse natively as Playlist objects with centroid + artwork, existing hubs() callers unchanged), with tests included — the mixes hub can't be generated by plexapi's CI bootstrap server, so the test replays a captured response.

Once that's merged and released, the manual parsing here collapses to library.hubs(includeMyMixes=1, count=n) + mix.centroid.thumb. Happy to handle that however you prefer — as a small follow-up after this merges (pin bump + swapping the call sites), or by holding this PR until the plexapi release and updating it in place.

@ajacobson
ajacobson force-pushed the plex-extended-recommendations branch from 4966456 to 688044c Compare July 7, 2026 05:04
@ajacobson

Copy link
Copy Markdown
Contributor Author

The raw-JSON workaround is gone as of 688044c — mixes now parse through plexapi's normal fetchItems path on the pinned plexapi (4.18.1), which also drops the second HTTP request per recommendations refresh. The branch is rebased onto current dev (constants/strings restructure, recommendations() rename).

Remaining work, planned as a small follow-up PR rather than here:

  • Upstream pushingkarmaorg/python-plexapi#1621 (merged, not yet released) adds LibrarySection.hubs(**kwargs) and Playlist.centroid. Once a plexapi release ships with it and the pin bumps, the manual hub-key construction and the ._data read in _mix_playlist_fields collapse to public API: hubs(count=..., includeMyMixes=True, ...) and mix.centroid.thumb.

@ajacobson
ajacobson marked this pull request as ready for review July 7, 2026 05:36
@anatosun

anatosun commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Solid work! Thanks for implementing this upstream :)

@MarvinSchenkel

Copy link
Copy Markdown
Contributor

Solid work! Thanks for implementing this upstream :)

@anatosun The code looks good, is this good to merge?

@MarvinSchenkel MarvinSchenkel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @ajacobson , looks good 👍

@marcelveldt
marcelveldt merged commit 859fc6d into music-assistant:dev Jul 19, 2026
12 checks passed
@OzGav

OzGav commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@ajacobson can you also raise a PR against the BETA branch of the docs with any changes needed for the Plex page

@ajacobson

Copy link
Copy Markdown
Contributor Author

Docs PR is up against beta: music-assistant/music-assistant.io#784 — adds an Advanced Settings section covering the Extended recommendations toggle.

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.

5 participants