Beispiel #1
0
        /// <summary>
        /// Gets the search hints async.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>Task{IEnumerable{SearchHintResult}}.</returns>
        private SearchHintResult GetSearchHintsAsync(GetSearchHints request)
        {
            var result = _searchEngine.GetSearchHints(new SearchQuery
            {
                Limit            = request.Limit,
                SearchTerm       = request.SearchTerm,
                IncludeArtists   = request.IncludeArtists,
                IncludeGenres    = request.IncludeGenres,
                IncludeMedia     = request.IncludeMedia,
                IncludePeople    = request.IncludePeople,
                IncludeStudios   = request.IncludeStudios,
                StartIndex       = request.StartIndex,
                UserId           = request.UserId,
                IncludeItemTypes = ApiEntryPoint.Split(request.IncludeItemTypes, ',', true),
                ExcludeItemTypes = ApiEntryPoint.Split(request.ExcludeItemTypes, ',', true),
                MediaTypes       = ApiEntryPoint.Split(request.MediaTypes, ',', true),
                ParentId         = request.ParentId,

                IsKids   = request.IsKids,
                IsMovie  = request.IsMovie,
                IsNews   = request.IsNews,
                IsSeries = request.IsSeries,
                IsSports = request.IsSports
            });

            return(new SearchHintResult
            {
                TotalRecordCount = result.TotalRecordCount,

                SearchHints = result.Items.Select(GetSearchHintResult).ToArray()
            });
        }
Beispiel #2
0
        /// <summary>
        /// Gets the search hints async.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>Task{IEnumerable{SearchHintResult}}.</returns>
        private async Task <SearchHintResult> GetSearchHintsAsync(GetSearchHints request)
        {
            var inputItems = GetAllLibraryItems(request.UserId, _userManager, _libraryManager);

            var results = await _searchEngine.GetSearchHints(inputItems, request.SearchTerm).ConfigureAwait(false);

            var searchResultArray = results.ToList();

            IEnumerable <SearchHintInfo> returnResults = searchResultArray;

            if (request.StartIndex.HasValue)
            {
                returnResults = returnResults.Skip(request.StartIndex.Value);
            }

            if (request.Limit.HasValue)
            {
                returnResults = returnResults.Take(request.Limit.Value);
            }

            return(new SearchHintResult
            {
                TotalRecordCount = searchResultArray.Count,

                SearchHints = returnResults.Select(GetSearchHintResult).ToArray()
            });
        }
Beispiel #3
0
        /// <summary>
        /// Gets the search hints async.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>Task{IEnumerable{SearchHintResult}}.</returns>
        private async Task <SearchHintResult> GetSearchHintsAsync(GetSearchHints request)
        {
            var result = await _searchEngine.GetSearchHints(new SearchQuery
            {
                Limit            = request.Limit,
                SearchTerm       = request.SearchTerm,
                IncludeArtists   = request.IncludeArtists,
                IncludeGenres    = request.IncludeGenres,
                IncludeMedia     = request.IncludeMedia,
                IncludePeople    = request.IncludePeople,
                IncludeStudios   = request.IncludeStudios,
                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,
                IsMovie  = request.IsMovie,
                IsNews   = request.IsNews,
                IsSeries = request.IsSeries,
                IsSports = request.IsSports
            }).ConfigureAwait(false);

            return(new SearchHintResult
            {
                TotalRecordCount = result.TotalRecordCount,

                SearchHints = result.Items.Select(GetSearchHintResult).ToArray()
            });
        }
        /// <summary>
        /// Gets the search hints async.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>Task{IEnumerable{SearchHintResult}}.</returns>
        private async Task <SearchHintResult> GetSearchHintsAsync(GetSearchHints request)
        {
            var result = await _searchEngine.GetSearchHints(new SearchQuery
            {
                Limit          = request.Limit,
                SearchTerm     = request.SearchTerm,
                IncludeArtists = request.IncludeArtists,
                IncludeGenres  = request.IncludeGenres,
                IncludeMedia   = request.IncludeMedia,
                IncludePeople  = request.IncludePeople,
                IncludeStudios = request.IncludeStudios,
                StartIndex     = request.StartIndex,
                UserId         = request.UserId
            }).ConfigureAwait(false);

            return(new SearchHintResult
            {
                TotalRecordCount = result.TotalRecordCount,

                SearchHints = result.Items.Select(GetSearchHintResult).ToArray()
            });
        }
Beispiel #5
0
        /// <summary>
        /// Gets the search hints async.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>Task{IEnumerable{SearchHintResult}}.</returns>
        private async Task <SearchHintResult> GetSearchHintsAsync(GetSearchHints request)
        {
            IEnumerable <BaseItem> inputItems;

            if (request.UserId.HasValue)
            {
                var user = _userManager.GetUserById(request.UserId.Value);

                inputItems = user.RootFolder.GetRecursiveChildren(user);
            }
            else
            {
                inputItems = _libraryManager.RootFolder.RecursiveChildren;
            }

            var results = await _searchEngine.GetSearchHints(inputItems, request.SearchTerm).ConfigureAwait(false);

            var searchResultArray = results.ToArray();

            IEnumerable <SearchHintInfo> returnResults = searchResultArray;

            if (request.StartIndex.HasValue)
            {
                returnResults = returnResults.Skip(request.StartIndex.Value);
            }

            if (request.Limit.HasValue)
            {
                returnResults = returnResults.Take(request.Limit.Value);
            }

            return(new SearchHintResult
            {
                TotalRecordCount = searchResultArray.Length,

                SearchHints = returnResults.Select(GetSearchHintResult).ToArray()
            });
        }
Beispiel #6
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetSearchHints request)
        {
            var result = GetSearchHintsAsync(request).Result;

            return(ToOptimizedSerializedResultUsingCache(result));
        }
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public async Task <object> Get(GetSearchHints request)
        {
            var result = await GetSearchHintsAsync(request).ConfigureAwait(false);

            return(ToOptimizedSerializedResultUsingCache(result));
        }
Beispiel #8
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetSearchHints request)
        {
            var result = GetSearchHintsAsync(request);

            return(ToOptimizedResult(result));
        }