From 1fb24df504fbb8e9208de13250cb09e5971f753f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 18 Mar 2015 12:40:16 -0400 Subject: add query by PersonId --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs') diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index bdaad49e6..4d222c9bb 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -39,6 +39,9 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "Person", Description = "Optional. If specified, results will be filtered to include only those containing the specified person.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string Person { get; set; } + [ApiMember(Name = "PersonIds", Description = "Optional. If specified, results will be filtered to include only those containing the specified person.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string PersonIds { get; set; } + /// /// If the Person filter is used, this can also be used to restrict to a specific person type /// @@ -244,6 +247,11 @@ namespace MediaBrowser.Api.UserLibrary return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } + public string[] GetPersonIds() + { + return (PersonIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + } + public VideoType[] GetVideoTypes() { var val = VideoTypes; @@ -477,6 +485,7 @@ namespace MediaBrowser.Api.UserLibrary Studios = request.GetStudios(), StudioIds = request.GetStudioIds(), Person = request.Person, + PersonIds = request.GetPersonIds(), PersonTypes = request.GetPersonTypes(), Years = request.GetYears(), ImageTypes = request.GetImageTypes().ToArray(), @@ -968,6 +977,13 @@ namespace MediaBrowser.Api.UserLibrary // Apply year filter var years = request.GetYears(); if (years.Length > 0 && !(i.ProductionYear.HasValue && years.Contains(i.ProductionYear.Value))) + { + return false; + } + + // Apply person filter + var personIds = request.GetPersonIds(); + if (personIds.Length > 0 && !(personIds.Any(v => i.People.Select(p => p.Name).Contains(v, StringComparer.OrdinalIgnoreCase)))) { return false; } -- cgit v1.2.3