From 35f755cce38b892293233556bf748c57f38a2170 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 3 Sep 2013 10:26:54 -0400 Subject: [PATCH] fixes #511 - Get Imdb rating for tv series using Omdb --- .../Movies/OpenMovieDatabaseProvider.cs | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs index 326e112a85..c4a3318913 100644 --- a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs +++ b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs @@ -149,13 +149,25 @@ namespace MediaBrowser.Providers.Movies { var result = JsonSerializer.DeserializeFromStream(stream); - int tomatoMeter; - - if (!string.IsNullOrEmpty(result.tomatoMeter) - && int.TryParse(result.tomatoMeter, NumberStyles.Integer, UsCulture, out tomatoMeter) - && tomatoMeter >= 0) + // Seeing some bogus RT data on omdb for series, so filter it out here + // RT doesn't even have tv series + if (!(item is Series)) { - item.CriticRating = tomatoMeter; + int tomatoMeter; + + if (!string.IsNullOrEmpty(result.tomatoMeter) + && int.TryParse(result.tomatoMeter, NumberStyles.Integer, UsCulture, out tomatoMeter) + && tomatoMeter >= 0) + { + item.CriticRating = tomatoMeter; + } + + if (!string.IsNullOrEmpty(result.tomatoConsensus) + && !string.Equals(result.tomatoConsensus, "n/a", StringComparison.OrdinalIgnoreCase) + && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase)) + { + item.CriticRatingSummary = result.tomatoConsensus; + } } int voteCount; @@ -175,13 +187,6 @@ namespace MediaBrowser.Providers.Movies { item.CommunityRating = imdbRating; } - - if (!string.IsNullOrEmpty(result.tomatoConsensus) - && !string.Equals(result.tomatoConsensus, "n/a", StringComparison.OrdinalIgnoreCase) - && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase)) - { - item.CriticRatingSummary = result.tomatoConsensus; - } } data.LastRefreshStatus = ProviderRefreshStatus.Success;