From db880cd4f0a3ff6e650d944ef1d90648f25d4453 Mon Sep 17 00:00:00 2001 From: mattsigal Date: Tue, 9 Jun 2026 00:07:29 -0700 Subject: [PATCH] Fix RT Audience rating source mismatch - Map rtAudience (legacy web) and tomatoes_audience (client) to popcorn when fetching from MDBList API. - Return ratings with the tomatoes_audience source key to match the client's expected key. - Update the server config page configuration list to use tomatoes_audience and dynamically map any existing rtAudience configurations to tomatoes_audience during load. - Normalize rtAudience settings in the resolved user settings profiles in memory. --- backend/Api/MdbListController.cs | 11 +++++++++-- backend/Pages/configPage.html | 3 ++- backend/Services/MoonfinSettingsService.cs | 11 +++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/backend/Api/MdbListController.cs b/backend/Api/MdbListController.cs index 58de374..2910d0d 100644 --- a/backend/Api/MdbListController.cs +++ b/backend/Api/MdbListController.cs @@ -158,12 +158,19 @@ private static List FilterAndOrderRatings(List all var result = new List(); foreach (var source in sources) { - if (ratingsBySource.TryGetValue(source, out var rating)) + var lookupSource = source; + if (string.Equals(source, "rtAudience", StringComparison.OrdinalIgnoreCase) || + string.Equals(source, "tomatoes_audience", StringComparison.OrdinalIgnoreCase)) + { + lookupSource = "popcorn"; + } + + if (ratingsBySource.TryGetValue(lookupSource, out var rating)) { // Clone the rating object to prevent mutating the cached instance in memory var ratingClone = new MdbListRating { - Source = rating.Source, + Source = source, Value = rating.Value, Score = rating.Score, Votes = rating.Votes, diff --git a/backend/Pages/configPage.html b/backend/Pages/configPage.html index f299ab2..367cbd0 100644 --- a/backend/Pages/configPage.html +++ b/backend/Pages/configPage.html @@ -1017,7 +1017,7 @@

Web Plugin Status

var RATING_SOURCES = [ { id: 'tomatoes', label: 'Rotten Tomatoes' }, - { id: 'rtAudience', label: 'RT Audience Score' }, + { id: 'tomatoes_audience', label: 'RT Audience Score' }, { id: 'imdb', label: 'IMDb' }, { id: 'tmdb', label: 'TMDB' }, { id: 'metacritic', label: 'Metacritic' }, @@ -1044,6 +1044,7 @@

Web Plugin Status

var ordered = []; if (selectedIds && selectedIds.length > 0) { selectedIds.forEach(function(id) { + if (id === 'rtAudience') id = 'tomatoes_audience'; var src = RATING_SOURCES.find(function(s) { return s.id === id; }); if (src) { ordered.push({ id: src.id, label: src.label, checked: true }); selectedSet[id] = true; } }); diff --git a/backend/Services/MoonfinSettingsService.cs b/backend/Services/MoonfinSettingsService.cs index f949be5..380e6a5 100644 --- a/backend/Services/MoonfinSettingsService.cs +++ b/backend/Services/MoonfinSettingsService.cs @@ -117,6 +117,17 @@ public MoonfinSettingsProfile ResolveProfile(MoonfinUserSettings settings, strin } } + if (resolved.MdblistRatingSources != null) + { + for (var i = 0; i < resolved.MdblistRatingSources.Count; i++) + { + if (string.Equals(resolved.MdblistRatingSources[i], "rtAudience", StringComparison.OrdinalIgnoreCase)) + { + resolved.MdblistRatingSources[i] = "tomatoes_audience"; + } + } + } + return resolved; }