瀏覽代碼

Inherit custom rating

Luke Pulverenti 11 年之前
父節點
當前提交
38d88aed58

+ 16 - 2
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -447,9 +447,23 @@ namespace MediaBrowser.Controller.Entities
         }
 
         [IgnoreDataMember]
-        public virtual string CustomRatingForComparison
+        public string CustomRatingForComparison
         {
-            get { return CustomRating; }
+            get
+            {
+                if (!string.IsNullOrEmpty(CustomRating))
+                {
+                    return CustomRating;
+                }
+
+                var parent = Parent;
+                if (parent != null)
+                {
+                    return parent.CustomRatingForComparison;
+                }
+
+                return null;
+            }
         }
 
         /// <summary>

+ 0 - 2
MediaBrowser.Controller/Entities/Folder.cs

@@ -1,11 +1,9 @@
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Progress;
 using MediaBrowser.Controller.Entities.TV;
-using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Localization;
 using MediaBrowser.Controller.Providers;
-using MediaBrowser.Controller.Resolvers;
 using MediaBrowser.Model.Entities;
 using MoreLinq;
 using System;

+ 9 - 12
MediaBrowser.Controller/Entities/TV/Episode.cs

@@ -98,9 +98,11 @@ namespace MediaBrowser.Controller.Entities.TV
         /// <returns>System.String.</returns>
         public override string GetUserDataKey()
         {
-            if (Series != null && ParentIndexNumber.HasValue && IndexNumber.HasValue)
+            var series = Series;
+
+            if (series != null && ParentIndexNumber.HasValue && IndexNumber.HasValue)
             {
-                return Series.GetUserDataKey() + ParentIndexNumber.Value.ToString("000") + IndexNumber.Value.ToString("000");
+                return series.GetUserDataKey() + ParentIndexNumber.Value.ToString("000") + IndexNumber.Value.ToString("000");
             }
 
             return base.GetUserDataKey();
@@ -112,16 +114,11 @@ namespace MediaBrowser.Controller.Entities.TV
         [IgnoreDataMember]
         public override string OfficialRatingForComparison
         {
-            get { return Series != null ? Series.OfficialRatingForComparison : base.OfficialRatingForComparison; }
-        }
-
-        /// <summary>
-        /// Our rating comes from our series
-        /// </summary>
-        [IgnoreDataMember]
-        public override string CustomRatingForComparison
-        {
-            get { return Series != null ? Series.CustomRatingForComparison : base.CustomRatingForComparison; }
+            get
+            {
+                var series = Series;
+                return series != null ? series.OfficialRatingForComparison : base.OfficialRatingForComparison;
+            }
         }
 
         /// <summary>

+ 5 - 10
MediaBrowser.Controller/Entities/TV/Season.cs

@@ -119,16 +119,11 @@ namespace MediaBrowser.Controller.Entities.TV
         [IgnoreDataMember]
         public override string OfficialRatingForComparison
         {
-            get { return Series != null ? Series.OfficialRatingForComparison : base.OfficialRatingForComparison; }
-        }
-
-        /// <summary>
-        /// Our rating comes from our series
-        /// </summary>
-        [IgnoreDataMember]
-        public override string CustomRatingForComparison
-        {
-            get { return Series != null ? Series.CustomRatingForComparison : base.CustomRatingForComparison; }
+            get
+            {
+                var series = Series;
+                return series != null ? series.OfficialRatingForComparison : base.OfficialRatingForComparison;
+            }
         }
 
         /// <summary>

+ 2 - 1
MediaBrowser.Providers/TV/TvdbEpisodeImageProvider.cs

@@ -61,8 +61,9 @@ namespace MediaBrowser.Providers.TV
         public Task<IEnumerable<RemoteImageInfo>> GetAllImages(IHasImages item, CancellationToken cancellationToken)
         {
             var episode = (Episode)item;
+            var series = episode.Series;
 
-            var seriesId = episode.Series != null ? episode.Series.GetProviderId(MetadataProviders.Tvdb) : null;
+            var seriesId = series != null ? series.GetProviderId(MetadataProviders.Tvdb) : null;
 
             if (!string.IsNullOrEmpty(seriesId))
             {