The Free Software Media System - Server Backend & API
get movie ratings from imdb via omdb
Luke Pulverenti6b84095adda4
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex 94fcd250ee..dff0203b9e 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -575,6 +575,13 @@ namespace MediaBrowser.Controller.Entities/// </summary>/// <value>The community rating.</value>public float? CommunityRating { get; set; }++ /// <summary>+ /// Gets or sets the community rating vote count.+ /// </summary>+ /// <value>The community rating vote count.</value>+ public int VoteCount { get; set; }+/// <summary>/// Gets or sets the run time ticks./// </summary>diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.csindex 64259c4242..0763c63bb8 100644--- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs+++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs@@ -679,11 +679,14 @@ namespace MediaBrowser.Providers.Moviesfloat rating;string voteAvg = movieData.vote_average.ToString(CultureInfo.InvariantCulture);+//tmdb appears to have unified their numbers to always report "7.3" regardless of country// so I removed the culture-specific processing here because it was not working for other countries -ebrif (float.TryParse(voteAvg, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out rating))movie.CommunityRating = rating;+ movie.VoteCount = movieData.vote_count;+//release date and certification are retrieved based on configured country and we fall back on US if not there and to minimun release date if still no matchif (movieData.releases != null && movieData.releases.countries != null){diff --git a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.csindex 6cbc8bcdf2..0d701aff83 100644--- a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs+++ b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs@@ -15,7 +15,7 @@ namespace MediaBrowser.Providers.Movies{public class OpenMovieDatabaseProvider : BaseMetadataProvider{- private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(2, 2);+ private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);/// <summary>/// Gets the json serializer.@@ -157,6 +157,24 @@ namespace MediaBrowser.Providers.Moviesitem.CriticRating = tomatoMeter;}+ int voteCount;++ if (!string.IsNullOrEmpty(result.imdbVotes)+ && int.TryParse(result.imdbVotes, NumberStyles.Integer, UsCulture, out voteCount)+ && voteCount >= 0)+ {+ item.VoteCount = voteCount;+ }++ float imdbRating;++ if (!string.IsNullOrEmpty(result.imdbRating)+ && float.TryParse(result.imdbRating, NumberStyles.Number, UsCulture, out imdbRating)+ && imdbRating >= 0)+ {+ 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))diff --git a/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Providers/TV/RemoteSeriesProvider.csindex 3d86ebb7e1..92efdeb395 100644--- a/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs+++ b/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs@@ -27,11 +27,6 @@ namespace MediaBrowser.Providers.TV/// </summary>class RemoteSeriesProvider : BaseMetadataProvider, IDisposable{- /// <summary>- /// The _provider manager- /// </summary>- private readonly IProviderManager _providerManager;-/// <summary>/// The tv db/// </summary>@@ -60,10 +55,9 @@ namespace MediaBrowser.Providers.TV/// <param name="httpClient">The HTTP client.</param>/// <param name="logManager">The log manager.</param>/// <param name="configurationManager">The configuration manager.</param>- /// <param name="providerManager">The provider manager.</param>/// <param name="zipClient">The zip client.</param>/// <exception cref="System.ArgumentNullException">httpClient</exception>- public RemoteSeriesProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IZipClient zipClient)+ public RemoteSeriesProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IZipClient zipClient): base(logManager, configurationManager){if (httpClient == null)@@ -71,7 +65,6 @@ namespace MediaBrowser.Providers.TVthrow new ArgumentNullException("httpClient");}HttpClient = httpClient;- _providerManager = providerManager;_zipClient = zipClient;Current = this;}