diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs
index ace8c4a6e0..6e1dbc08b9 100644
--- a/MediaBrowser.Api/ItemUpdateService.cs
+++ b/MediaBrowser.Api/ItemUpdateService.cs
@@ -219,8 +219,12 @@ namespace MediaBrowser.Api
item.Budget = request.Budget;
item.Revenue = request.Revenue;
- item.CriticRating = request.CriticRating;
- item.CriticRatingSummary = request.CriticRatingSummary;
+ var hasCriticRating = item as IHasCriticRating;
+ if (hasCriticRating != null)
+ {
+ hasCriticRating.CriticRating = request.CriticRating;
+ hasCriticRating.CriticRatingSummary = request.CriticRatingSummary;
+ }
item.DisplayMediaType = request.DisplayMediaType;
item.CommunityRating = request.CommunityRating;
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index 29a894b1c8..9547cc0a4e 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -581,7 +581,17 @@ namespace MediaBrowser.Api.UserLibrary
{
var val = request.MinCriticRating.Value;
- items = items.Where(i => i.CriticRating.HasValue && i.CriticRating >= val);
+ items = items.Where(i =>
+ {
+ var hasCriticRating = i as IHasCriticRating;
+
+ if (hasCriticRating != null)
+ {
+ return hasCriticRating.CriticRating.HasValue && hasCriticRating.CriticRating >= val;
+ }
+
+ return false;
+ });
}
// Artists
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 839fe34ffe..f8b2fad230 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -111,18 +111,6 @@ namespace MediaBrowser.Controller.Entities
/// The revenue.
public double? Revenue { get; set; }
- ///
- /// Gets or sets the critic rating.
- ///
- /// The critic rating.
- public float? CriticRating { get; set; }
-
- ///
- /// Gets or sets the critic rating summary.
- ///
- /// The critic rating summary.
- public string CriticRatingSummary { get; set; }
-
///
/// Gets or sets the trailer URL.
///
diff --git a/MediaBrowser.Controller/Entities/IHasCriticRating.cs b/MediaBrowser.Controller/Entities/IHasCriticRating.cs
new file mode 100644
index 0000000000..d2b93759d8
--- /dev/null
+++ b/MediaBrowser.Controller/Entities/IHasCriticRating.cs
@@ -0,0 +1,20 @@
+namespace MediaBrowser.Controller.Entities
+{
+ ///
+ /// Interface IHasCriticRating
+ ///
+ public interface IHasCriticRating
+ {
+ ///
+ /// Gets or sets the critic rating.
+ ///
+ /// The critic rating.
+ float? CriticRating { get; set; }
+
+ ///
+ /// Gets or sets the critic rating summary.
+ ///
+ /// The critic rating summary.
+ string CriticRatingSummary { get; set; }
+ }
+}
diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs
index 516ee9a8ae..54ad9c1c97 100644
--- a/MediaBrowser.Controller/Entities/Movies/Movie.cs
+++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs
@@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Entities.Movies
///
/// Class Movie
///
- public class Movie : Video
+ public class Movie : Video, IHasCriticRating
{
public List SpecialFeatureIds { get; set; }
@@ -20,6 +20,18 @@ namespace MediaBrowser.Controller.Entities.Movies
SpecialFeatureIds = new List();
}
+ ///
+ /// Gets or sets the critic rating.
+ ///
+ /// The critic rating.
+ public float? CriticRating { get; set; }
+
+ ///
+ /// Gets or sets the critic rating summary.
+ ///
+ /// The critic rating summary.
+ public string CriticRatingSummary { get; set; }
+
///
/// Gets or sets the name of the TMDB collection.
///
diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs
index e7d47f7ec7..c9fe471b3c 100644
--- a/MediaBrowser.Controller/Entities/Trailer.cs
+++ b/MediaBrowser.Controller/Entities/Trailer.cs
@@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Entities
///
/// Class Trailer
///
- public class Trailer : Video
+ public class Trailer : Video, IHasCriticRating
{
public Trailer()
{
@@ -15,6 +15,18 @@ namespace MediaBrowser.Controller.Entities
Taglines = new List();
}
+ ///
+ /// Gets or sets the critic rating.
+ ///
+ /// The critic rating.
+ public float? CriticRating { get; set; }
+
+ ///
+ /// Gets or sets the critic rating summary.
+ ///
+ /// The critic rating summary.
+ public string CriticRatingSummary { get; set; }
+
///
/// Gets a value indicating whether this instance is local trailer.
///
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 978d56bd4e..94ff5d3054 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -89,6 +89,7 @@
+
diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs
index e9bb7f66d9..9fdbbf3b7e 100644
--- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs
+++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs
@@ -143,10 +143,16 @@ namespace MediaBrowser.Controller.Providers
case "CriticRating":
{
var text = reader.ReadElementContentAsString();
- float value;
- if (float.TryParse(text, NumberStyles.Any, _usCulture, out value))
+
+ var hasCriticRating = item as IHasCriticRating;
+
+ if (hasCriticRating != null && !string.IsNullOrEmpty(text))
{
- item.CriticRating = value;
+ float value;
+ if (float.TryParse(text, NumberStyles.Any, _usCulture, out value))
+ {
+ hasCriticRating.CriticRating = value;
+ }
}
break;
@@ -207,7 +213,12 @@ namespace MediaBrowser.Controller.Providers
if (!string.IsNullOrWhiteSpace(val))
{
- item.CriticRatingSummary = val;
+ var hasCriticRating = item as IHasCriticRating;
+
+ if (hasCriticRating != null)
+ {
+ hasCriticRating.CriticRatingSummary = val;
+ }
}
break;
diff --git a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs
index a6fdbdcef7..6550396e51 100644
--- a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs
+++ b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs
@@ -139,22 +139,26 @@ namespace MediaBrowser.Providers.Movies
{
var result = JsonSerializer.DeserializeFromStream(stream);
- // Seeing some bogus RT data on omdb for series, so filter it out here
- // RT doesn't even have tv series
- 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))
+ var hasCriticRating = item as IHasCriticRating;
+ if (hasCriticRating != null)
{
- item.CriticRatingSummary = result.tomatoConsensus;
+ // Seeing some bogus RT data on omdb for series, so filter it out here
+ // RT doesn't even have tv series
+ int tomatoMeter;
+
+ if (!string.IsNullOrEmpty(result.tomatoMeter)
+ && int.TryParse(result.tomatoMeter, NumberStyles.Integer, UsCulture, out tomatoMeter)
+ && tomatoMeter >= 0)
+ {
+ hasCriticRating.CriticRating = tomatoMeter;
+ }
+
+ if (!string.IsNullOrEmpty(result.tomatoConsensus)
+ && !string.Equals(result.tomatoConsensus, "n/a", StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase))
+ {
+ hasCriticRating.CriticRatingSummary = result.tomatoConsensus;
+ }
}
int voteCount;
diff --git a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs
index d9e0fb6e2f..69276e0b8e 100644
--- a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs
+++ b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs
@@ -209,14 +209,18 @@ namespace MediaBrowser.Providers.Savers
builder.Append("" + SecurityElement.Escape(item.DisplayMediaType) + "");
}
- if (item.CriticRating.HasValue)
+ var hasCriticRating = item as IHasCriticRating;
+ if (hasCriticRating != null)
{
- builder.Append("" + SecurityElement.Escape(item.CriticRating.Value.ToString(UsCulture)) + "");
- }
+ if (hasCriticRating.CriticRating.HasValue)
+ {
+ builder.Append("" + SecurityElement.Escape(hasCriticRating.CriticRating.Value.ToString(UsCulture)) + "");
+ }
- if (!string.IsNullOrEmpty(item.CriticRatingSummary))
- {
- builder.Append("");
+ if (!string.IsNullOrEmpty(hasCriticRating.CriticRatingSummary))
+ {
+ builder.Append("");
+ }
}
if (!string.IsNullOrEmpty(item.Overview))
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
index 19e19f8ea4..0104196e01 100644
--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs
+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
@@ -792,11 +792,15 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.MediaType = item.MediaType;
dto.LocationType = item.LocationType;
- dto.CriticRating = item.CriticRating;
-
- if (fields.Contains(ItemFields.CriticRatingSummary))
+ var hasCriticRating = item as IHasCriticRating;
+ if (hasCriticRating != null)
{
- dto.CriticRatingSummary = item.CriticRatingSummary;
+ dto.CriticRating = hasCriticRating.CriticRating;
+
+ if (fields.Contains(ItemFields.CriticRatingSummary))
+ {
+ dto.CriticRatingSummary = hasCriticRating.CriticRatingSummary;
+ }
}
var localTrailerCount = item.LocalTrailerIds.Count;
diff --git a/MediaBrowser.Server.Implementations/Sorting/CriticRatingComparer.cs b/MediaBrowser.Server.Implementations/Sorting/CriticRatingComparer.cs
index 9484130cbc..d01f7ed1b3 100644
--- a/MediaBrowser.Server.Implementations/Sorting/CriticRatingComparer.cs
+++ b/MediaBrowser.Server.Implementations/Sorting/CriticRatingComparer.cs
@@ -22,7 +22,9 @@ namespace MediaBrowser.Server.Implementations.Sorting
private float GetValue(BaseItem x)
{
- return x.CriticRating ?? 0;
+ var hasCriticRating = x as IHasCriticRating;
+
+ return hasCriticRating == null ? 0 : hasCriticRating.CriticRating ?? 0;
}
///