diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-03-13 14:45:03 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-03-13 14:45:03 -0400 |
| commit | 1735300bcf13a34728984f295d1b62a872e8e579 (patch) | |
| tree | 7b35694c3aa0a44489d9d607b53656bf35a3cfa9 /MediaBrowser.Api/UserLibrary/ItemsService.cs | |
| parent | 9606a1c26786eb8f2fe8d5ee3525f17a70aca6e2 (diff) | |
query for content by studio id
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs')
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/ItemsService.cs | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 256ae3625..b188d701f 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -53,6 +53,9 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "Studios", Description = "Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Studios { get; set; } + [ApiMember(Name = "StudioIds", Description = "Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + public string StudioIds { get; set; } + /// <summary> /// Gets or sets the studios. /// </summary> @@ -231,6 +234,11 @@ namespace MediaBrowser.Api.UserLibrary return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } + public string[] GetStudioIds() + { + return (StudioIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + } + public string[] GetPersonTypes() { return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); @@ -467,6 +475,7 @@ namespace MediaBrowser.Api.UserLibrary OfficialRatings = request.GetOfficialRatings(), Genres = request.GetGenres(), Studios = request.GetStudios(), + StudioIds = request.GetStudioIds(), Person = request.Person, PersonTypes = request.GetPersonTypes(), Years = request.GetYears(), @@ -945,6 +954,17 @@ namespace MediaBrowser.Api.UserLibrary return false; } + // Apply studio filter + var studioIds = request.GetStudioIds(); + if (studioIds.Length > 0 && !studioIds.Any(id => + { + var studioItem = libraryManager.GetItemById(id); + return studioItem != null && i.Studios.Contains(studioItem.Name, StringComparer.OrdinalIgnoreCase); + })) + { + return false; + } + // Apply year filter var years = request.GetYears(); if (years.Length > 0 && !(i.ProductionYear.HasValue && years.Contains(i.ProductionYear.Value))) @@ -1019,14 +1039,8 @@ namespace MediaBrowser.Api.UserLibrary if (!(audio != null && artistIds.Any(id => { - try - { - return audio.HasAnyArtist(libraryManager.GetItemById(id).Name); - } - catch (Exception ex) - { - return false; - } + var artistItem = libraryManager.GetItemById(id); + return artistItem != null && audio.HasAnyArtist(artistItem.Name); }))) { return false; |
