feat: add webhook/non-polling based Plex media processing#3174
feat: add webhook/non-polling based Plex media processing#3174mmgoodnow wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughAdds a ChangesPlex Recently Added Processing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/lib/scanners/plex/index.ts`:
- Around line 184-186: The processRatingKey method awaits processItem(metadata)
but processItem internally catches and suppresses errors, causing failures to be
silently ignored and allowing the webhook to return success status even when
processing fails. Remove the error suppression in the processItem method so that
errors are properly thrown and propagated up through processRatingKey to the
webhook handler, allowing proper error handling, retries, and alerts at the
caller level. If processItem catches errors intentionally for other code paths,
instead modify processRatingKey to detect and re-throw any processing failures
so the webhook path can receive accurate success or failure status.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f7b51668-03ba-43dc-b13c-b1405d1a5b12
📒 Files selected for processing (6)
docs/using-seerr/plex/index.mdseerr-api.ymlserver/api/plexapi.tsserver/lib/scanners/plex/index.tsserver/routes/index.tsserver/routes/plex.ts
gauthier-th
left a comment
There was a problem hiding this comment.
I don't understand the point of this PR.
You can already achieve this through the Seerr REST API: https://docs.seerr.dev/api/invoke-a-specific-job/
With the plex-recently-added-scan job.
Description
I started tracking metrics on how long it takes from the moment a show or movie is requested to the moment the user is notified it's available on Plex. One of the slowest parts of the pipeline is polling lag from Seerr polling Plex for new releases. This PR adds a new endpoint, allowing Plex/Tautulli/anyone to notify Seerr when new content is added via webhook.
Right now I have it set up so Tautulli pushes to Seerr. Tautulli holds a WebSocket connection to Plex so it already gets instant notifications. It is set up to wait ~15 seconds after seeing one episode, to wait for other episodes to settle, then it will send the HTTP request to Seerr.
In the future we could consider Seerr maintaining a similar WebSocket connection to Plex, which would mean everyone gets the benefit and no one has to configure Tautulli for it. I chose to implement the webhook method in this PR, which also lays groundwork for the WebSocket method if we were to want that in the future.
AI Disclosure: I used OpenAI Codex for the code in this PR. I have reviewed the code manually, and I have tested manually. All writing, other than the diff, is my own.
How Has This Been Tested?
I have been running it on my home instance. It cuts down time-to-email from ~3 minutes to 16 seconds, pretty consistently. You can see in the screenshot below. (15 of the 16 seconds is due to an intentional import delay in Tautulli, so it does not live in Seerr.)
Since this is net new code we don't have to worry about it causing bugs in other existing stuff.
Screenshots
I have a Grafana dashboard showing software-induced latency in my requested media pipeline. The red bars are what we're interested in, which answers the question: after something is available on Plex, how long until they receive the email notification that it's available?
At the top of this screenshot you can see downloads from before I added the webhook push. They routinely have latency of 2-5 minutes, because of the 5 minute polling interval.
Towards the bottom you can see downloads from after I added the webhook push.

Checklist:
pnpm buildpnpm i18n:extractNo translation keys were added.Summary by CodeRabbit
Release Notes
New Features
Documentation