Allow query parameters in LibrarySection.hubs() and add Playlist.centroid#1621
Open
ajacobson wants to merge 3 commits into
Open
Allow query parameters in LibrarySection.hubs() and add Playlist.centroid#1621ajacobson wants to merge 3 commits into
ajacobson wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends PlexAPI’s library hub querying and adds support for parsing “Mixes For You” music mix playlists by exposing the centroid artist embedded in hubs payloads.
Changes:
- Add
**kwargspassthrough toLibrarySection.hubs()(withincludeStations=1preserved as the default) to support parameters likecountandincludeMyMixes. - Introduce
Playlist.centroidto expose the centroidArtistfor personalized mix playlists (orNonefor regular playlists). - Add tests and a captured hubs payload fixture to validate centroid parsing and to ensure no auto-reload occurs when centroid is absent.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_playlist.py | Adds coverage for Playlist.centroid parsing from hubs payloads and verifies no unintended reload for regular/partial playlists. |
| tests/test_library.py | Adds a regression test validating LibrarySection.hubs(count=...) limits hub item payload sizes. |
| tests/payloads.py | Adds a recorded hubs XML payload representing “Mixes For You” mix + centroid directory structure. |
| plexapi/playlist.py | Implements Playlist.centroid as a cached data property returning the centroid Artist when present. |
| plexapi/library.py | Updates LibrarySection.hubs() to accept query kwargs while keeping prior behavior via default includeStations=1. |
| plexapi/base.py | Adds centroid to the “don’t auto-reload when None” key set to prevent spurious reload attempts for hub-only centroid data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
JonnyWong16
requested changes
Jul 2, 2026
…roid * LibrarySection.hubs() now accepts optional query parameters (e.g. count=10, includeMyMixes=1), matching Library.hubs(); includeStations=1 remains the default and may be overridden. * Add Playlist.centroid returning the nested centroid Artist a personalized 'Mix For You' playlist is built around (its only artwork source), guarded against auto-reload on partial objects.
b2e7aa1 to
6cfa762
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two small additions to support the personalized "Mixes For You" hub in music sections:
LibrarySection.hubs()now accepts optional query parameters (e.g.count=10to limit items per hub, orincludeMyMixes=1to include the "Mixes For You" hub), matching the signatureLibrary.hubs()already has.includeStations=1remains the default viasetdefault, so the request is unchanged for existing callers (includingMusicSection.stations()), and it can now be overridden.New
Playlist.centroidproperty returning the centroidArtista personalized "Mix For You" playlist is built around, orNonefor regular playlists. Mix playlists have nocomposite/thumbof their own — the nested centroid<Directory>is their only artwork source, and there was previously no public way to reach it.'centroid'is added to_DONT_RELOAD_FOR_KEYS: it is legitimatelyNoneon every regular playlist, so without the exemption, accessing it on a partial object would trigger a spurious auto-reload (which can never surface a centroid anyway — it only exists in the hub payload). The mocked test asserts zero reloads.Since the CI bootstrap server cannot generate personalized mixes,
test_Playlist_centroidreplays a hubs response captured from a live PMS (attribute shapes preserved: mixes carry noratingKey, and artwork lives only on the nested centroid<Directory>).Tested against a live PMS: default
hubs()output unchanged across section types,MusicSection.stations()unaffected,count/include flags honored on movie/show/music sections, and 9 real mixes parsing with centroid artist + thumb with no extra requests.Motivation: music-assistant/server#3736, where the downstream Plex provider currently maintains a manual-parsing workaround for these items and the maintainers asked for an upstream fix.
Type of change
Checklist: