From 39d1fda587cfb3cde338242f9384eb59f981ce7a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 6 May 2017 16:21:08 -0400 Subject: [PATCH] update search --- Emby.Server.Implementations/Library/SearchEngine.cs | 5 +++-- MediaBrowser.Api/SearchService.cs | 8 ++++++++ MediaBrowser.Model/Search/SearchQuery.cs | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs index f640ae2b15..5f88a6c662 100644 --- a/Emby.Server.Implementations/Library/SearchEngine.cs +++ b/Emby.Server.Implementations/Library/SearchEngine.cs @@ -98,7 +98,7 @@ private Task> GetSearchHints(SearchQuery query, User var hints = new List>(); - var excludeItemTypes = new List(); + var excludeItemTypes = query.ExcludeItemTypes.ToList(); var includeItemTypes = (query.IncludeItemTypes ?? new string[] { }).ToList(); excludeItemTypes.Add(typeof(Year).Name); @@ -174,7 +174,8 @@ private Task> GetSearchHints(SearchQuery query, User IsMovie = query.IsMovie, IsNews = query.IsNews, IsSeries = query.IsSeries, - IsSports = query.IsSports + IsSports = query.IsSports, + MediaTypes = query.MediaTypes }); // Add search hints based on item name diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.cs index 3df815cda1..80a703313c 100644 --- a/MediaBrowser.Api/SearchService.cs +++ b/MediaBrowser.Api/SearchService.cs @@ -67,6 +67,12 @@ public class GetSearchHints : IReturn [ApiMember(Name = "IncludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string IncludeItemTypes { get; set; } + [ApiMember(Name = "ExcludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + public string ExcludeItemTypes { get; set; } + + [ApiMember(Name = "MediaTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + public string MediaTypes { get; set; } + public string ParentId { get; set; } [ApiMember(Name = "IsMovie", Description = "Optional filter for movies.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET,POST")] @@ -154,6 +160,8 @@ private async Task GetSearchHintsAsync(GetSearchHints request) StartIndex = request.StartIndex, UserId = request.UserId, IncludeItemTypes = (request.IncludeItemTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), + ExcludeItemTypes = (request.ExcludeItemTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), + MediaTypes = (request.MediaTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), ParentId = request.ParentId, IsKids = request.IsKids, diff --git a/MediaBrowser.Model/Search/SearchQuery.cs b/MediaBrowser.Model/Search/SearchQuery.cs index 897a9db523..0081591ca8 100644 --- a/MediaBrowser.Model/Search/SearchQuery.cs +++ b/MediaBrowser.Model/Search/SearchQuery.cs @@ -33,7 +33,9 @@ public class SearchQuery public bool IncludeStudios { get; set; } public bool IncludeArtists { get; set; } + public string[] MediaTypes { get; set; } public string[] IncludeItemTypes { get; set; } + public string[] ExcludeItemTypes { get; set; } public string ParentId { get; set; } public bool? IsMovie { get; set; } @@ -54,7 +56,9 @@ public SearchQuery() IncludePeople = true; IncludeStudios = true; + MediaTypes = new string[] { }; IncludeItemTypes = new string[] { }; + ExcludeItemTypes = new string[] { }; } } }