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.Budget = request.Budget;
|
||||||
item.Revenue = request.Revenue;
|
item.Revenue = request.Revenue;
|
||||||
|
|
||||||
item.CriticRating = request.CriticRating;
|
var hasCriticRating = item as IHasCriticRating;
|
||||||
item.CriticRatingSummary = request.CriticRatingSummary;
|
if (hasCriticRating != null)
|
||||||
|
{
|
||||||
|
hasCriticRating.CriticRating = request.CriticRating;
|
||||||
|
hasCriticRating.CriticRatingSummary = request.CriticRatingSummary;
|
||||||
|
}
|
||||||
|
|
||||||
item.DisplayMediaType = request.DisplayMediaType;
|
item.DisplayMediaType = request.DisplayMediaType;
|
||||||
item.CommunityRating = request.CommunityRating;
|
item.CommunityRating = request.CommunityRating;
|
||||||
|
|
|
@ -581,7 +581,17 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
{
|
{
|
||||||
var val = request.MinCriticRating.Value;
|
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
|
// Artists
|
||||||
|
|
|
@ -111,18 +111,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// <value>The revenue.</value>
|
/// <value>The revenue.</value>
|
||||||
public double? Revenue { get; set; }
|
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>
|
/// <summary>
|
||||||
/// Gets or sets the trailer URL.
|
/// Gets or sets the trailer URL.
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Class Movie
|
/// Class Movie
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Movie : Video
|
public class Movie : Video, IHasCriticRating
|
||||||
{
|
{
|
||||||
public List<Guid> SpecialFeatureIds { get; set; }
|
public List<Guid> SpecialFeatureIds { get; set; }
|
||||||
|
|
||||||
|
@ -20,6 +20,18 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||||
SpecialFeatureIds = new List<Guid>();
|
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>
|
/// <summary>
|
||||||
/// Gets or sets the name of the TMDB collection.
|
/// Gets or sets the name of the TMDB collection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class Trailer
|
/// Class Trailer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Trailer : Video
|
public class Trailer : Video, IHasCriticRating
|
||||||
{
|
{
|
||||||
public Trailer()
|
public Trailer()
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,18 @@ namespace MediaBrowser.Controller.Entities
|
||||||
Taglines = new List<string>();
|
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>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this instance is local trailer.
|
/// Gets a value indicating whether this instance is local trailer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -89,6 +89,7 @@
|
||||||
<Compile Include="Entities\GameGenre.cs" />
|
<Compile Include="Entities\GameGenre.cs" />
|
||||||
<Compile Include="Entities\GameSystem.cs" />
|
<Compile Include="Entities\GameSystem.cs" />
|
||||||
<Compile Include="Entities\IByReferenceItem.cs" />
|
<Compile Include="Entities\IByReferenceItem.cs" />
|
||||||
|
<Compile Include="Entities\IHasCriticRating.cs" />
|
||||||
<Compile Include="Entities\IItemByName.cs" />
|
<Compile Include="Entities\IItemByName.cs" />
|
||||||
<Compile Include="Entities\ILibraryItem.cs" />
|
<Compile Include="Entities\ILibraryItem.cs" />
|
||||||
<Compile Include="Entities\ImageSourceInfo.cs" />
|
<Compile Include="Entities\ImageSourceInfo.cs" />
|
||||||
|
|
|
@ -143,10 +143,16 @@ namespace MediaBrowser.Controller.Providers
|
||||||
case "CriticRating":
|
case "CriticRating":
|
||||||
{
|
{
|
||||||
var text = reader.ReadElementContentAsString();
|
var text = reader.ReadElementContentAsString();
|
||||||
|
|
||||||
|
var hasCriticRating = item as IHasCriticRating;
|
||||||
|
|
||||||
|
if (hasCriticRating != null && !string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
float value;
|
float value;
|
||||||
if (float.TryParse(text, NumberStyles.Any, _usCulture, out value))
|
if (float.TryParse(text, NumberStyles.Any, _usCulture, out value))
|
||||||
{
|
{
|
||||||
item.CriticRating = value;
|
hasCriticRating.CriticRating = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -207,7 +213,12 @@ namespace MediaBrowser.Controller.Providers
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(val))
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
{
|
{
|
||||||
item.CriticRatingSummary = val;
|
var hasCriticRating = item as IHasCriticRating;
|
||||||
|
|
||||||
|
if (hasCriticRating != null)
|
||||||
|
{
|
||||||
|
hasCriticRating.CriticRatingSummary = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -139,6 +139,9 @@ namespace MediaBrowser.Providers.Movies
|
||||||
{
|
{
|
||||||
var result = JsonSerializer.DeserializeFromStream<RootObject>(stream);
|
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
|
// Seeing some bogus RT data on omdb for series, so filter it out here
|
||||||
// RT doesn't even have tv series
|
// RT doesn't even have tv series
|
||||||
int tomatoMeter;
|
int tomatoMeter;
|
||||||
|
@ -147,14 +150,15 @@ namespace MediaBrowser.Providers.Movies
|
||||||
&& int.TryParse(result.tomatoMeter, NumberStyles.Integer, UsCulture, out tomatoMeter)
|
&& int.TryParse(result.tomatoMeter, NumberStyles.Integer, UsCulture, out tomatoMeter)
|
||||||
&& tomatoMeter >= 0)
|
&& tomatoMeter >= 0)
|
||||||
{
|
{
|
||||||
item.CriticRating = tomatoMeter;
|
hasCriticRating.CriticRating = tomatoMeter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.tomatoConsensus)
|
if (!string.IsNullOrEmpty(result.tomatoConsensus)
|
||||||
&& !string.Equals(result.tomatoConsensus, "n/a", StringComparison.OrdinalIgnoreCase)
|
&& !string.Equals(result.tomatoConsensus, "n/a", StringComparison.OrdinalIgnoreCase)
|
||||||
&& !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase))
|
&& !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
item.CriticRatingSummary = result.tomatoConsensus;
|
hasCriticRating.CriticRatingSummary = result.tomatoConsensus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int voteCount;
|
int voteCount;
|
||||||
|
|
|
@ -209,14 +209,18 @@ namespace MediaBrowser.Providers.Savers
|
||||||
builder.Append("<Type>" + SecurityElement.Escape(item.DisplayMediaType) + "</Type>");
|
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))
|
if (!string.IsNullOrEmpty(item.Overview))
|
||||||
|
|
|
@ -792,11 +792,15 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
dto.MediaType = item.MediaType;
|
dto.MediaType = item.MediaType;
|
||||||
dto.LocationType = item.LocationType;
|
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))
|
if (fields.Contains(ItemFields.CriticRatingSummary))
|
||||||
{
|
{
|
||||||
dto.CriticRatingSummary = item.CriticRatingSummary;
|
dto.CriticRatingSummary = hasCriticRating.CriticRatingSummary;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var localTrailerCount = item.LocalTrailerIds.Count;
|
var localTrailerCount = item.LocalTrailerIds.Count;
|
||||||
|
|
|
@ -22,7 +22,9 @@ namespace MediaBrowser.Server.Implementations.Sorting
|
||||||
|
|
||||||
private float GetValue(BaseItem x)
|
private float GetValue(BaseItem x)
|
||||||
{
|
{
|
||||||
return x.CriticRating ?? 0;
|
var hasCriticRating = x as IHasCriticRating;
|
||||||
|
|
||||||
|
return hasCriticRating == null ? 0 : hasCriticRating.CriticRating ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user