Skip to content

plexupdate: Add interactive plex.tv authentication and general plugin rewrite - #6978

Merged
snejus merged 5 commits into
masterfrom
plexupdate_refactor
Sep 4, 2026
Merged

snejus merged 5 commits into
masterfrom
plexupdate_refactor

Conversation

@semohr

@semohr semohr commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Rewrite the plexupdate plugin around Plex's PIN authentication flow. beet plexupdate --auth opens a browser, authenticates with Plex, and stores the token and generated client identifier in plex_token.json next to the beets configuration.

  • Add PlexSession for token persistence, PIN polling, and authenticated server requests.
  • Use Plex's JSON API to find the music library section.
  • Refresh the library once after modifying commands.
  • Clearly report missing sections and 401 responses.
  • Deprecate the manual token option in favor of interactive authentication.
  • Update documentation, tests, and changelog.

Motivation

plexupdate could easily break after Plex deployments or instances were updated, and manually obtaining a token isn't particularly straightforward... This rewrite makes recovery simple: if authentication breaks, users can just run the documented beet plexupdate --auth command.

  • Documentation
  • Changelog
  • Tests

Copilot AI lite review requested due to automatic review settings September 2, 2026 18:42
@semohr
semohr requested review from a team and snejus as code owners September 2, 2026 18:42
@github-actions github-actions Bot added the plexupdate plexupdate plugin label Sep 2, 2026

This comment was marked as outdated.

@codecov

codecov Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.67153% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.92%. Comparing base (63b69fa) to head (8859bb7).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/plexupdate.py 84.67% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6978      +/-   ##
==========================================
+ Coverage   76.86%   76.92%   +0.06%     
==========================================
  Files         163      163              
  Lines       21625    21724      +99     
  Branches     3343     3349       +6     
==========================================
+ Hits        16621    16711      +90     
- Misses       4189     4201      +12     
+ Partials      815      812       -3     
Files with missing lines Coverage Δ
beetsplug/plexupdate.py 84.45% <84.67%> (+17.11%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@semohr
semohr force-pushed the plexupdate_refactor branch from a492544 to 5d2cdea Compare September 2, 2026 18:55
@semohr
semohr requested a lite review from Copilot September 2, 2026 20:38

@snejus snejus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mostly looks good, just a couple of comments

Comment thread test/plugins/test_plexupdate.py Resolved
Comment thread test/plugins/test_plexupdate.py Resolved
Comment thread beetsplug/plexupdate.py Resolved
Comment thread beetsplug/plexupdate.py Resolved
Comment thread beetsplug/plexupdate.py Resolved
Comment thread beetsplug/plexupdate.py Resolved
Comment thread beetsplug/plexupdate.py Resolved
Comment thread beetsplug/plexupdate.py Resolved
Comment thread beetsplug/plexupdate.py Resolved

This comment was marked as outdated.

@semohr
semohr force-pushed the plexupdate_refactor branch 2 times, most recently from b402856 to a5ada8f Compare September 2, 2026 21:45
@semohr
semohr requested a balanced review from Copilot September 2, 2026 21:45

This comment was marked as spam.

@semohr
semohr force-pushed the plexupdate_refactor branch from a5ada8f to 1149c1a Compare September 2, 2026 21:47
@semohr
semohr requested a balanced review from Copilot September 3, 2026 09:41

This comment was marked as spam.

@semohr
semohr requested review from snejus and a lite review from Copilot September 3, 2026 09:41

This comment was marked as outdated.

Rewrite the plugin around Plex' PIN authentication flow: running
`beet plexupdate --auth` opens a browser window and stores the
obtained token together with a generated client identifier in a
token file (`plex_token.json`) next to the beets configuration.

- add a PlexSession (based on TimeoutAndRetrySession) that handles
  token persistence, plex.tv PIN polling, and attaching the token to
  local server requests
- look up the music library section through the JSON API instead of
  parsing XML
- refresh the Plex library once, at the end of commands that changed
  the library; report missing sections and 401 responses clearly
  instead of failing silently
- deprecate the manual `token` configuration option in favor of the
  interactive login
Cover the plex.tv PIN authentication flow, token persistence, and
the library refresh requests with mocked HTTP responses.
Rewrite the plugin documentation in the current style with dedicated
sections on authentication, usage, and configuration, and mark the
manual `token` option as deprecated. Add a changelog entry for the
new `beet plexupdate --auth` command.

@snejus snejus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lovely!

@snejus
snejus merged commit 91dbec1 into master Sep 4, 2026
23 checks passed
@snejus
snejus deleted the plexupdate_refactor branch September 4, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plexupdate plexupdate plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants