浏览代码

get movie ratings from imdb via omdb

Luke Pulverenti 12 年之前
父节点
当前提交
6b84095add

+ 7 - 0
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>

+ 3 - 0
MediaBrowser.Providers/Movies/MovieDbProvider.cs

@@ -679,11 +679,14 @@ namespace MediaBrowser.Providers.Movies
 
                 float 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 -ebr
                 if (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 match
                 if (movieData.releases != null && movieData.releases.countries != null)
                 {

+ 19 - 1
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.Movies
                     item.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))

+ 1 - 8
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.TV
                 throw new ArgumentNullException("httpClient");
             }
             HttpClient = httpClient;
-            _providerManager = providerManager;
             _zipClient = zipClient;
             Current = this;
         }