Beispiel #1
0
        /// <summary>
        /// Get recommendations by page
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public async Task <(IEnumerable <MovieLightJson>, int nbMovies)> Discover(int page)
        {
            var discover = TmdbClient.DiscoverMoviesAsync();
            var result   = await discover.Query(page);

            var movies = new ConcurrentBag <MovieLightJson>();
            await result.Results.ParallelForEachAsync(async movie =>
            {
                var imdbMovie = await TmdbClient.GetMovieAsync(movie.Id);
                if (imdbMovie?.ImdbId == null)
                {
                    return;
                }

                var fetch = await GetMovieLightAsync(imdbMovie.ImdbId);
                if (fetch != null)
                {
                    movies.Add(fetch);
                }
            });

            return(movies, result.TotalResults);
        }