Update Plex Functionality#146
Open
DannyTheHeretic wants to merge 3 commits into
Open
Conversation
Author
|
also, if you want to test it, i have a build on my ghcr, |
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.
Add Plex user switching via shared server tokens
What changed
1. Implemented
SwitchUser()using Plexshared_serversendpointhttps://plex.tv/api/servers/{machineId}/shared_serversPlexSharedServers/PlexSharedUserstructs to match Plex’s actual response format.PlexSharedServers/PlexSharedUserstructs to match Plex’s actual XML response format.2. Replaced incorrect JSON-based assumptions with XML parsing
/shared_servers3. Improved user resolution logic
usernameemailnameuserID4. Introduced isolated per-user Plex client context
SwitchUser()returns a new Plex client instanceX-Plex-Tokenis correctly scoped per user session5. Added hub-based search resolution for library items
/hubs/search) parsing and normalizationPlexSearchformat for downstream processingKey improvements:
Hub -> Metadata) into a unified search modelratingKey/keyfor playlist operations6. Ensured correct token source for user impersonation
accessTokenfrom/shared_serversWhy this change was necessary
1. Plex uses server-scoped access tokens, not global login tokens
Previously, tokens were incorrectly assumed to be interchangeable between:
However Plex enforces strict separation:
accessToken) → required for user-scoped mutations (playlists, edits, etc.)Without correct switching, Plex returns:
401 Unauthorizedon/playlistsand similar endpoints2.
/shared_serversis the only valid source of per-user server tokensProvides:
Other endpoints do not provide usable per-user server tokens.
3. Hub search is required for reliable media resolution
Plex search APIs are inconsistent across libraries and media types. Using
/hubs/searchensures:This is required for reliably mapping:
ratingKey/keyResult
After these changes: