diff options
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs')
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/ItemsService.cs | 31 |
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)) { |
