added critic rating interface
This commit is contained in:
parent
885287e631
commit
a4cea5a5d3
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -111,18 +111,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <value>The revenue.</value>
|
||||
public double? Revenue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating.
|
||||
/// </summary>
|
||||
/// <value>The critic rating.</value>
|
||||
public float? CriticRating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating summary.
|
||||
/// </summary>
|
||||
/// <value>The critic rating summary.</value>
|
||||
public string CriticRatingSummary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the trailer URL.
|
||||
/// </summary>
|
||||
|
|
20
MediaBrowser.Controller/Entities/IHasCriticRating.cs
Normal file
20
MediaBrowser.Controller/Entities/IHasCriticRating.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IHasCriticRating
|
||||
/// </summary>
|
||||
public interface IHasCriticRating
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating.
|
||||
/// </summary>
|
||||
/// <value>The critic rating.</value>
|
||||
float? CriticRating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating summary.
|
||||
/// </summary>
|
||||
/// <value>The critic rating summary.</value>
|
||||
string CriticRatingSummary { get; set; }
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
/// <summary>
|
||||
/// Class Movie
|
||||
/// </summary>
|
||||
public class Movie : Video
|
||||
public class Movie : Video, IHasCriticRating
|
||||
{
|
||||
public List<Guid> SpecialFeatureIds { get; set; }
|
||||
|
||||
|
@ -20,6 +20,18 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
SpecialFeatureIds = new List<Guid>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating.
|
||||
/// </summary>
|
||||
/// <value>The critic rating.</value>
|
||||
public float? CriticRating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating summary.
|
||||
/// </summary>
|
||||
/// <value>The critic rating summary.</value>
|
||||
public string CriticRatingSummary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the TMDB collection.
|
||||
/// </summary>
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <summary>
|
||||
/// Class Trailer
|
||||
/// </summary>
|
||||
public class Trailer : Video
|
||||
public class Trailer : Video, IHasCriticRating
|
||||
{
|
||||
public Trailer()
|
||||
{
|
||||
|
@ -15,6 +15,18 @@ namespace MediaBrowser.Controller.Entities
|
|||
Taglines = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating.
|
||||
/// </summary>
|
||||
/// <value>The critic rating.</value>
|
||||
public float? CriticRating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating summary.
|
||||
/// </summary>
|
||||
/// <value>The critic rating summary.</value>
|
||||
public string CriticRatingSummary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is local trailer.
|
||||
/// </summary>
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
<Compile Include="Entities\GameGenre.cs" />
|
||||
<Compile Include="Entities\GameSystem.cs" />
|
||||
<Compile Include="Entities\IByReferenceItem.cs" />
|
||||
<Compile Include="Entities\IHasCriticRating.cs" />
|
||||
<Compile Include="Entities\IItemByName.cs" />
|
||||
<Compile Include="Entities\ILibraryItem.cs" />
|
||||
<Compile Include="Entities\ImageSourceInfo.cs" />
|
||||
|
|
|
@ -143,10 +143,16 @@ namespace MediaBrowser.Controller.Providers
|
|||
case "CriticRating":
|
||||
{
|
||||
var text = reader.ReadElementContentAsString();
|
||||
|
||||
var hasCriticRating = item as IHasCriticRating;
|
||||
|
||||
if (hasCriticRating != null && !string.IsNullOrEmpty(text))
|
||||
{
|
||||
float value;
|
||||
if (float.TryParse(text, NumberStyles.Any, _usCulture, out value))
|
||||
{
|
||||
item.CriticRating = 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;
|
||||
|
|
|
@ -139,6 +139,9 @@ namespace MediaBrowser.Providers.Movies
|
|||
{
|
||||
var result = JsonSerializer.DeserializeFromStream<RootObject>(stream);
|
||||
|
||||
var hasCriticRating = item as IHasCriticRating;
|
||||
if (hasCriticRating != null)
|
||||
{
|
||||
// Seeing some bogus RT data on omdb for series, so filter it out here
|
||||
// RT doesn't even have tv series
|
||||
int tomatoMeter;
|
||||
|
@ -147,14 +150,15 @@ namespace MediaBrowser.Providers.Movies
|
|||
&& int.TryParse(result.tomatoMeter, NumberStyles.Integer, UsCulture, out tomatoMeter)
|
||||
&& tomatoMeter >= 0)
|
||||
{
|
||||
item.CriticRating = tomatoMeter;
|
||||
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))
|
||||
{
|
||||
item.CriticRatingSummary = result.tomatoConsensus;
|
||||
hasCriticRating.CriticRatingSummary = result.tomatoConsensus;
|
||||
}
|
||||
}
|
||||
|
||||
int voteCount;
|
||||
|
|
|
@ -209,14 +209,18 @@ namespace MediaBrowser.Providers.Savers
|
|||
builder.Append("<Type>" + SecurityElement.Escape(item.DisplayMediaType) + "</Type>");
|
||||
}
|
||||
|
||||
if (item.CriticRating.HasValue)
|
||||
var hasCriticRating = item as IHasCriticRating;
|
||||
if (hasCriticRating != null)
|
||||
{
|
||||
builder.Append("<CriticRating>" + SecurityElement.Escape(item.CriticRating.Value.ToString(UsCulture)) + "</CriticRating>");
|
||||
if (hasCriticRating.CriticRating.HasValue)
|
||||
{
|
||||
builder.Append("<CriticRating>" + SecurityElement.Escape(hasCriticRating.CriticRating.Value.ToString(UsCulture)) + "</CriticRating>");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.CriticRatingSummary))
|
||||
if (!string.IsNullOrEmpty(hasCriticRating.CriticRatingSummary))
|
||||
{
|
||||
builder.Append("<CriticRatingSummary><![CDATA[" + item.CriticRatingSummary + "]]></CriticRatingSummary>");
|
||||
builder.Append("<CriticRatingSummary><![CDATA[" + hasCriticRating.CriticRatingSummary + "]]></CriticRatingSummary>");
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.Overview))
|
||||
|
|
|
@ -792,11 +792,15 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
dto.MediaType = item.MediaType;
|
||||
dto.LocationType = item.LocationType;
|
||||
|
||||
dto.CriticRating = item.CriticRating;
|
||||
var hasCriticRating = item as IHasCriticRating;
|
||||
if (hasCriticRating != null)
|
||||
{
|
||||
dto.CriticRating = hasCriticRating.CriticRating;
|
||||
|
||||
if (fields.Contains(ItemFields.CriticRatingSummary))
|
||||
{
|
||||
dto.CriticRatingSummary = item.CriticRatingSummary;
|
||||
dto.CriticRatingSummary = hasCriticRating.CriticRatingSummary;
|
||||
}
|
||||
}
|
||||
|
||||
var localTrailerCount = item.LocalTrailerIds.Count;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user