Beispiel #1
0
        public async Task <object> Get(GetMovieRecommendations request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var dtoOptions = GetDtoOptions(_authContext, request);

            dtoOptions.Fields = request.GetItemFields().ToList();

            var result = GetRecommendationCategories(user, request.ParentId, request.CategoryLimit, request.ItemLimit, dtoOptions);

            return(ToOptimizedResult(result));
        }
Beispiel #2
0
        public async Task <object> Get(GetMovieRecommendations request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var query = new InternalItemsQuery(user)
            {
                IncludeItemTypes = new[] { typeof(Movie).Name }
            };
            var parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId };
            var movies    = _libraryManager.GetItems(query, parentIds);

            movies = _libraryManager.ReplaceVideosWithPrimaryVersions(movies);

            var listEligibleForCategories = new List <BaseItem>();
            var listEligibleForSuggestion = new List <BaseItem>();

            var list = movies.ToList();

            listEligibleForCategories.AddRange(list);
            listEligibleForSuggestion.AddRange(list);

            if (user.Configuration.IncludeTrailersInSuggestions)
            {
                var trailerResult = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery
                {
                    ContentTypes = new[] { ChannelMediaContentType.MovieExtra },
                    ExtraTypes   = new[] { ExtraType.Trailer },
                    UserId       = user.Id.ToString("N")
                }, CancellationToken.None).ConfigureAwait(false);

                listEligibleForSuggestion.AddRange(trailerResult.Items);
            }

            listEligibleForCategories = listEligibleForCategories
                                        .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
                                        .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase)
                                        .ToList();

            listEligibleForSuggestion = listEligibleForSuggestion
                                        .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
                                        .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase)
                                        .ToList();

            var dtoOptions = GetDtoOptions(request);

            dtoOptions.Fields = request.GetItemFields().ToList();

            var result = GetRecommendationCategories(user, listEligibleForCategories, listEligibleForSuggestion, request.CategoryLimit, request.ItemLimit, dtoOptions);

            return(ToOptimizedResult(result));
        }
Beispiel #3
0
        public async Task <object> Get(GetMovieRecommendations request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var query = new InternalItemsQuery(user)
            {
                IncludeItemTypes = new[] { typeof(Movie).Name }
            };

            if (user.Configuration.IncludeTrailersInSuggestions)
            {
                var includeList = query.IncludeItemTypes.ToList();
                includeList.Add(typeof(Trailer).Name);
                query.IncludeItemTypes = includeList.ToArray();
            }

            var parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId };
            var movies    = _libraryManager.GetItemList(query, parentIds);

            movies = _libraryManager.ReplaceVideosWithPrimaryVersions(movies);

            var listEligibleForCategories = new List <BaseItem>();
            var listEligibleForSuggestion = new List <BaseItem>();

            var list = movies.ToList();

            listEligibleForCategories.AddRange(list);
            listEligibleForSuggestion.AddRange(list);

            listEligibleForCategories = listEligibleForCategories
                                        // Exclude trailers from the suggestion categories
                                        .Where(i => i is Movie)
                                        .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
                                        .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase)
                                        .ToList();

            listEligibleForSuggestion = listEligibleForSuggestion
                                        .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
                                        .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase)
                                        .ToList();

            var dtoOptions = GetDtoOptions(request);

            dtoOptions.Fields = request.GetItemFields().ToList();

            var result = GetRecommendationCategories(user, listEligibleForCategories, listEligibleForSuggestion, request.CategoryLimit, request.ItemLimit, dtoOptions);

            return(ToOptimizedResult(result));
        }
        public object Get(GetMovieRecommendations request)
        {
            var user = _userManager.GetUserById(request.UserId.Value);

            var movies = GetAllLibraryItems(request.UserId, _userManager, _libraryManager, request.ParentId)
                .OfType<Movie>();

            movies = _libraryManager.ReplaceVideosWithPrimaryVersions(movies).Cast<Movie>();

            var result = GetRecommendationCategories(user, movies.ToList(), request.CategoryLimit, request.ItemLimit, request.GetItemFields().ToList());

            return ToOptimizedResult(result);
        }
Beispiel #5
0
        public object Get(GetMovieRecommendations request)
        {
            var user = _userManager.GetUserById(request.UserId.Value);

            var movies = user.RootFolder.GetRecursiveChildren(user).OfType <Movie>().ToList();

            var result = GetRecommendationCategories(user, movies, request.CategoryLimit, request.ItemLimit, request.GetItemFields().ToList());

            return(ToOptimizedResult(result));
        }