aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/UserLibrary/ItemsService.cs
diff options
context:
space:
mode:
authorTechywarrior <techywarrior@gmail.com>2013-04-14 10:39:41 -0700
committerTechywarrior <techywarrior@gmail.com>2013-04-14 10:39:41 -0700
commitc24c0ad784c99bc5869c9b4b532e7c470b90db8f (patch)
treeb518a8106eba949a9966d71ce56ce22140f9bc79 /MediaBrowser.Api/UserLibrary/ItemsService.cs
parent419d85116798bd5e5327c41d711d6cb46d70caeb (diff)
parenta2447f3edcbd8d9d2226634c4dc0e04eea3fa643 (diff)
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs')
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index cd6bd7854..3b8702e7d 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -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;
@@ -125,6 +126,20 @@ namespace MediaBrowser.Api.UserLibrary
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>
/// <returns>IEnumerable{ItemSortBy}.</returns>
@@ -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))
{