added min/max official rating
This commit is contained in:
parent
7f1fdbf223
commit
587d3c1908
|
@ -2,6 +2,7 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
|
@ -124,6 +125,20 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
[ApiMember(Name = "AirDays", Description = "Optional filter by Series Air Days. Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string AirDays { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the min offical rating.
|
||||
/// </summary>
|
||||
/// <value>The min offical rating.</value>
|
||||
[ApiMember(Name = "MinOfficalRating", Description = "Optional filter by minimum official rating (PG, PG-13, TV-MA, etc).", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string MinOfficalRating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the max offical rating.
|
||||
/// </summary>
|
||||
/// <value>The max offical rating.</value>
|
||||
[ApiMember(Name = "MaxOfficalRating", Description = "Optional filter by maximum official rating (PG, PG-13, TV-MA, etc).", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string MaxOfficalRating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the order by.
|
||||
/// </summary>
|
||||
|
@ -357,6 +372,22 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||
internal static IEnumerable<BaseItem> ApplyAdditionalFilters(GetItems request, IEnumerable<BaseItem> items)
|
||||
{
|
||||
// Min official rating
|
||||
if (!string.IsNullOrEmpty(request.MinOfficalRating))
|
||||
{
|
||||
var level = Ratings.Level(request.MinOfficalRating);
|
||||
|
||||
items = items.Where(i => Ratings.Level(i.CustomRating ?? i.OfficialRating) >= level);
|
||||
}
|
||||
|
||||
// Max official rating
|
||||
if (!string.IsNullOrEmpty(request.MaxOfficalRating))
|
||||
{
|
||||
var level = Ratings.Level(request.MaxOfficalRating);
|
||||
|
||||
items = items.Where(i => Ratings.Level(i.CustomRating ?? i.OfficialRating) <= level);
|
||||
}
|
||||
|
||||
// Exclude item types
|
||||
if (!string.IsNullOrEmpty(request.ExcludeItemTypes))
|
||||
{
|
||||
|
|
|
@ -157,5 +157,17 @@ namespace MediaBrowser.Model.Querying
|
|||
/// </summary>
|
||||
/// <value>The ids.</value>
|
||||
public string[] Ids { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the min official rating.
|
||||
/// </summary>
|
||||
/// <value>The min official rating.</value>
|
||||
public string MinOfficialRating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the max official rating.
|
||||
/// </summary>
|
||||
/// <value>The max official rating.</value>
|
||||
public string MaxOfficialRating { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common.Internal</id>
|
||||
<version>3.0.75</version>
|
||||
<version>3.0.76</version>
|
||||
<title>MediaBrowser.Common.Internal</title>
|
||||
<authors>Luke</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common</id>
|
||||
<version>3.0.75</version>
|
||||
<version>3.0.76</version>
|
||||
<title>MediaBrowser.Common</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Server.Core</id>
|
||||
<version>3.0.75</version>
|
||||
<version>3.0.76</version>
|
||||
<title>Media Browser.Server.Core</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
||||
<copyright>Copyright © Media Browser 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.75" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.76" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
|
Loading…
Reference in New Issue
Block a user