Skip to content

feat(ratings): Rotten Tomatoes scores via MDBList + on-view backfill on all client surfaces - #266

Closed
Pukabyte wants to merge 7 commits into
Silo-Server:mainfrom
Pukabyte:feat/rotten-tomatoes-ratings
Closed

Pukabyte wants to merge 7 commits into
Silo-Server:mainfrom
Pukabyte:feat/rotten-tomatoes-ratings

Conversation

@Pukabyte

@Pukabyte Pukabyte commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Rotten Tomatoes scores were not reaching clients:

  1. Wrong MDBList endpoint. RatingsByIMDB requested https://api.mdblist.com/?apikey=…&i=<imdb>, which returns MDBList's homepage index (params ignored, no ratings array). Every lookup parsed an empty list, so RTCritic was always nil — 0 of ~195k movies/series ever received an RT score, and the on-view backfill silently negative-cached each item with no error log.
  2. CriticRating blanked out. Mapping Jellyfin CriticRating solely from the (always-nil) RT score removed the previously-shown TMDB value, so clients displayed no critic rating at all.
  3. Jellyfin surface never triggered backfill. The on-view backfill was wired only into the native /catalog/items/{id} handler, so opening a title in a Jellyfin/Emby client never populated RT.

Changes

  • fix(mdblist) — point RatingsByIMDB at the legacy lookup host https://mdblist.com/api/?i=, which returns the full ratings array with the tomatoes/tomatoesaudience source names the parser expects. (The REST host renames the audience source to popcorn, so it is deliberately not used.) A dedicated ratingsBaseURL keeps discovery on api.mdblist.com.
  • Restore TMDB fallback — Jellyfin CriticRating prefers the RT critic score when present, else falls back to RatingTMDB, so ratings show immediately and RT overrides as it backfills.
  • feat(jellycompat) — extract the on-view backfiller into internal/rtbackfill (single implementation, one shared in-flight/negative cache) and trigger it from the Jellyfin item-detail handler as well; carry imdb_id through upstreamItemDetail so the handler has the key.
  • Earlier commits in the branch add the MDBList ratings source, the metadata-refresh enrichment, and the native on-view backfill.

Testing

  • go build ./..., go vet, and package tests pass: internal/mdblist, internal/rtbackfill, internal/jellycompat, internal/api/handlers.
  • Verified end-to-end against a live MDBList key and a running server: opening a movie enqueues a backfill that fetches → parses → persists (movie-tmdb-687163 → rating_rt_critic=94, rating_rt_audience=95, matching RT). Confirmed the old endpoint returned only the homepage index.

Risks / follow-up

  • The in-app backfill is best-effort and rate-limited by MDBList (~1k/day) — suitable for dynamic single-item fills, not bulk library backfill. A bulk fill is better done out-of-band (e.g. a self-hosted Overseerr/Jellyseerr, keyed by TMDB id); not included here.
  • The rtbackfill in-flight/negative caches are in-memory and cleared on restart.

Scope

No existing Rotten Tomatoes / ratings capability issue was found to link — please advise the correct Part of #NNN epic to reference.

AI use

Implemented with assistance from Claude Code (Opus 4.8). All changes reviewed, built, and verified against a live instance before submission.

Summary by CodeRabbit

  • New Features

    • Rotten Tomatoes ratings are now pulled in automatically for movies and series when available.
    • Jellyfin item details and lists now show Rotten Tomatoes critic scores where present, with a fallback to other ratings when needed.
  • Bug Fixes

    • Improved metadata refresh behavior so missing Rotten Tomatoes ratings can be filled in after viewing an item.
    • Rating data is now carried through more consistently across item details and library listings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e837c79f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/rtbackfill/backfill.go Outdated
defer cancel()

foundRT := false
defer func() { b.release(contentID, foundRT) }()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retry after transient RT backfill failures

When RatingsByIMDB returns a transient error (429/network) or UpdateMetadata fails, this deferred release still runs with foundRT == false; release treats that exactly like a successful “no RT score” lookup and negative-caches the title for 24 hours. In those failure cases the next item view cannot retry the backfill until the TTL expires, so only successful lookups with no RT data should populate the negative cache.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — fixed in 49ba11a. run() now negative-caches only when a successful lookup genuinely returns no RT score; transient failures (RatingsByIMDB error like 429/network, or UpdateMetadata error) release without caching, so the next item view retries instead of being skipped for the 24h TTL. Added tests TestRTBackfillFetchErrorDoesNotNegativeCache and TestRTBackfillPersistErrorDoesNotNegativeCache covering both paths.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Quick104, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f9b957f4-1913-4392-9050-e2f929f97ffb

📥 Commits

Reviewing files that changed from the base of the PR and between 5eaec62 and 83623de.

📒 Files selected for processing (3)
  • cmd/silo/main.go
  • internal/api/handlers/items.go
  • internal/api/router.go
📝 Walkthrough

Walkthrough

The PR adds MDBList Rotten Tomatoes rating lookup, wires shared ratings/backfill dependencies through startup and routers, enriches metadata refreshes with RT scores, and propagates RT critic ratings through Jellyfin compatibility mappings and item-detail handling.

Changes

Rotten Tomatoes ratings flow

Layer / File(s) Summary
MDBList ratings lookup
internal/mdblist/...
Adds a separate ratings endpoint, a TitleRatings response type, and RatingsByIMDB with tests for success, nulls, configuration, and rate limiting.
Metadata refresh enrichment
internal/metadata/service.go
Adds an injectable ratings fetcher and a persist-path enrichment step that fills RT critic and audience scores from MDBList when IMDb IDs are present.
Native backfill wiring
cmd/silo/main.go, internal/api/router.go, internal/api/handlers/items.go
Creates and threads a shared RT backfiller through startup and router dependencies, then enqueues lazy backfills during item-detail refreshes for movies and series missing RT critic ratings.
Jellyfin RT propagation
internal/jellycompat/...
Carries the shared backfiller into compat routing, adds RT critic fields to upstream types and mappings, and uses RT critic scores when resolving CriticRating.

Estimated code review effort: 4 (Complex) | ~60 minutes

Suggested labels: v1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: Rotten Tomatoes scores via MDBList with shared on-view backfill across client surfaces.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Pukabyte
Pukabyte force-pushed the feat/rotten-tomatoes-ratings branch from 49ba11a to 5eaec62 Compare July 5, 2026 22:58
@coderabbitai coderabbitai Bot added the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Jul 5, 2026

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
cmd/silo/main.go (1)

1826-1839: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

RT backfill/ratings-fetcher wiring is gated on an unrelated dependency (UserStoreProvider).

metadataService.SetRatingsFetcher(...) and deps.RTBackfiller = rtbackfill.New(...) only run inside if deps.UserStoreProvider != nil, a block whose actual purpose is wiring up user-collection sync. If UserStoreProvider is nil (e.g. a deployment mode where needsUserDB is false, or user store init fails) but DB/metadataService are available, both the metadata-refresh RT enrichment and the on-view RT backfiller silently never get created — with no log/warning that the RT feature is disabled. Neither feature has any actual dependency on the user store.

Consider hoisting the SetRatingsFetcher/RTBackfiller construction out of the UserStoreProvider conditional (e.g. gate solely on deps.MDBListClient != nil and metadataService != nil), so the feature's availability tracks its real dependencies.

♻️ Proposed restructuring
-		if deps.UserStoreProvider != nil {
-			userSync := usercollections.NewService(deps.UserStoreProvider, collItemRepo, libraryItemRepo, nil, slog.Default())
-			userSync.TMDBCollections = collectionService.TMDBCollections
-			// Trakt fetchers are wired in router.go (they need settingsRepo);
-			// router.go propagates them onto userSync once configured.
-			userCollectionScheduler = usercollections.NewScheduler(deps.DB, userSync, slog.Default())
-			deps.UserCollectionSync = userSync
-			deps.UserCollectionScheduler = userCollectionScheduler
-			deps.MDBListClient = mdblist.NewClient(cfg.MDBListAPIKey, nil)
-			mdblistForReload := deps.MDBListClient
-			configWatcher.OnChange(func(_, updated *config.Config) {
-				mdblistForReload.SetAPIKey(updated.MDBListAPIKey)
-			})
-			// Feed Rotten Tomatoes scores from MDBList into metadata refreshes.
-			if metadataService != nil {
-				metadataService.SetRatingsFetcher(deps.MDBListClient)
-			}
-			// One shared on-view RT backfiller for both the native item detail
-			// handler and the Jellyfin compat surface (single in-flight/negative
-			// cache).
-			deps.RTBackfiller = rtbackfill.New(deps.MDBListClient, catalog.NewItemRepository(deps.DB))
-		}
+		deps.MDBListClient = mdblist.NewClient(cfg.MDBListAPIKey, nil)
+		mdblistForReload := deps.MDBListClient
+		configWatcher.OnChange(func(_, updated *config.Config) {
+			mdblistForReload.SetAPIKey(updated.MDBListAPIKey)
+		})
+		// Feed Rotten Tomatoes scores from MDBList into metadata refreshes.
+		if metadataService != nil {
+			metadataService.SetRatingsFetcher(deps.MDBListClient)
+		}
+		// One shared on-view RT backfiller for both the native item detail
+		// handler and the Jellyfin compat surface (single in-flight/negative
+		// cache).
+		deps.RTBackfiller = rtbackfill.New(deps.MDBListClient, catalog.NewItemRepository(deps.DB))
+		if deps.UserStoreProvider != nil {
+			userSync := usercollections.NewService(deps.UserStoreProvider, collItemRepo, libraryItemRepo, nil, slog.Default())
+			userSync.TMDBCollections = collectionService.TMDBCollections
+			userCollectionScheduler = usercollections.NewScheduler(deps.DB, userSync, slog.Default())
+			deps.UserCollectionSync = userSync
+			deps.UserCollectionScheduler = userCollectionScheduler
+		}
🤖 Prompt for 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.

In `@cmd/silo/main.go` around lines 1826 - 1839, The RT ratings/backfill setup is
incorrectly tied to the UserStoreProvider branch, so
metadataService.SetRatingsFetcher and deps.RTBackfiller can be skipped even when
their real dependencies are available. Move the MDBList/RT wiring out of the
UserStoreProvider-specific block in cmd/silo/main.go and gate it only on
deps.MDBListClient and metadataService (and the DB-backed repository for
rtbackfill.New), using the existing symbols metadataService.SetRatingsFetcher,
rtbackfill.New, and deps.RTBackfiller so the feature initializes whenever it
should.
🤖 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.

Nitpick comments:
In `@cmd/silo/main.go`:
- Around line 1826-1839: The RT ratings/backfill setup is incorrectly tied to
the UserStoreProvider branch, so metadataService.SetRatingsFetcher and
deps.RTBackfiller can be skipped even when their real dependencies are
available. Move the MDBList/RT wiring out of the UserStoreProvider-specific
block in cmd/silo/main.go and gate it only on deps.MDBListClient and
metadataService (and the DB-backed repository for rtbackfill.New), using the
existing symbols metadataService.SetRatingsFetcher, rtbackfill.New, and
deps.RTBackfiller so the feature initializes whenever it should.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 00f1e8e2-da44-41da-83fa-fa2811ee7ce0

📥 Commits

Reviewing files that changed from the base of the PR and between 1e837c7 and 5eaec62.

📒 Files selected for processing (13)
  • cmd/silo/main.go
  • internal/api/handlers/items.go
  • internal/api/router.go
  • internal/jellycompat/content_direct.go
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/mapping.go
  • internal/jellycompat/router.go
  • internal/jellycompat/server.go
  • internal/jellycompat/upstream_types.go
  • internal/mdblist/discovery.go
  • internal/mdblist/ratings.go
  • internal/mdblist/ratings_test.go
  • internal/metadata/service.go
💤 Files with no reviewable changes (10)
  • internal/jellycompat/router.go
  • internal/jellycompat/server.go
  • internal/jellycompat/upstream_types.go
  • internal/mdblist/ratings.go
  • internal/mdblist/ratings_test.go
  • internal/jellycompat/content_direct.go
  • internal/mdblist/discovery.go
  • internal/jellycompat/mapping.go
  • internal/jellycompat/handlers_items.go
  • internal/metadata/service.go

Pukabyte and others added 7 commits July 10, 2026 13:29
Add mdblist.RatingsByIMDB to fetch the RT tomatometer/audience score by
IMDb id, and enrich metadata refreshes with it via a nil-safe
RatingsFetcher injected into the metadata service. Best-effort: lookup
failures are logged and never fail a refresh, and a plugin-provided RT
score is not clobbered. Fills the previously-scaffolded rating_rt_critic
/ rating_rt_audience columns that had no populating source.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Jellyfin's CriticRating field is a 0-100 tomato-scored value; it was
being fed from TMDB's 0-10 community score. Source it from the real RT
tomatometer (RatingRTCritic) instead, threading the field through the
upstreamListItem/upstreamItemDetail structs and their constructors.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
When a movie or series detail is opened without an RT score, enqueue an
async MDBList lookup that upserts rating_rt_critic/audience, so the value
appears on the next load. In-flight dedupe and a 24h negative cache keep
it from hammering MDBList for titles it has no RT for. Only spends API
calls on titles users actually open.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…fallback

RatingsByIMDB hit https://api.mdblist.com/?apikey=&i=<imdb>, which returns
MDBList's homepage index (params ignored, no ratings array). Every lookup
therefore parsed an empty ratings list, so RTCritic was always nil: 0 of
~195k movies/series ever got a Rotten Tomatoes score, and the on-view
backfill silently negative-cached each item with no error log.

Point RatingsByIMDB at the legacy lookup host https://mdblist.com/api/?i=,
which returns the full ratings array with the "tomatoes"/"tomatoesaudience"
source names the parser already expects (the REST host renames audience to
"popcorn", so it is deliberately not used). Added a dedicated ratingsBaseURL
field so discovery keeps using api.mdblist.com.

Also restore the pre-branch behavior for Jellyfin CriticRating: prefer the RT
critic score when present, else fall back to RatingTMDB. Without this,
mapping CriticRating solely from the (until-now always-nil) RT score blanked
out ratings for every title in Jellyfin clients.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ller

The on-view Rotten Tomatoes backfill was only wired into the native catalog
item-detail handler, so opening a title in a Jellyfin/Emby client never
populated RT scores. Extract the backfiller into internal/rtbackfill (single
implementation, no duplicated logic) and share one instance — with one
in-flight/negative cache — between the native surface and jellycompat.

- internal/rtbackfill: new package holding the Backfiller moved out of
  api/handlers (exported New/Enqueue; Fetcher/Updater interfaces).
- jellycompat: carry imdb_id through upstreamItemDetail so the handler has the
  key; enqueue a backfill from HandleItem for RT-less movies/series.
- Build the shared backfiller once in main and inject via both api and
  jellycompat Dependencies.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…al/rtbackfill

The on-view backfiller moved to internal/rtbackfill (shared by the native and
jellycompat surfaces); these files were the pre-extraction copy left behind in
the cherry-pick. Removing the dead duplicate.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ient errors

Per Codex review: run() released with foundRT=false on both transient failures
(RatingsByIMDB error, UpdateMetadata error) and genuine no-RT results, so a
429/network/DB blip negative-cached the title for 24h and blocked retry on the
next view. Negative-cache only when a successful lookup returns no RT score;
errors now leave the item retryable. Adds tests for both error paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

Copy link
Copy Markdown
Contributor

Thanks for the work on this. We reviewed the exact head 83623def9f8eebfd9f8a7dd3b9defd5ba9b1c1a1.

This branch combines several independently reviewable concerns—MDBList title-rating transport, metadata-refresh enrichment, native on-view backfill, and Jellyfin compatibility behavior—while Silo follows a one-concern-per-PR policy. The branch is also substantially behind main and currently conflicts.

The review surfaced useful requirements around credential-safe errors, MDBList quota control, rating locks and stale-write fencing, independent critic/audience handling, and Jellyfin rating scales. We have preserved that work in focused issues: #692, #693, #694, #695, and #696.

Closing this PR in favor of those scoped issues and fresh PRs. This is not a rejection of the feature; it is a request to land it in smaller, independently verifiable pieces. Thank you for establishing the original implementation and live-validation context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1.0 Silo v1 scope - auto-adds to the Silo v1 project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants