コード例 #1
0
ファイル: MovieImportModule.cs プロジェクト: Animarr/Animarr
        private object Import()
        {
            var resource  = Request.Body.FromJson <List <MovieResource> >();
            var newMovies = resource.ToModel();

            return(_addMovieService.AddMovies(newMovies).ToResource(0));
        }
コード例 #2
0
        private void ProcessReports(ImportListFetchResult listFetchResult)
        {
            listFetchResult.Movies = listFetchResult.Movies.DistinctBy(x =>
            {
                if (x.TmdbId != 0)
                {
                    return(x.TmdbId.ToString());
                }

                if (x.ImdbId.IsNotNullOrWhiteSpace())
                {
                    return(x.ImdbId);
                }

                return(x.Title);
            }).ToList();

            var listedMovies = listFetchResult.Movies.ToList();

            var importExclusions = _exclusionService.GetAllExclusions();
            var dbMovies         = _movieService.AllMovieTmdbIds();
            var moviesToAdd      = new List <Movie>();

            var groupedMovies = listedMovies.GroupBy(x => x.ListId);

            foreach (var list in groupedMovies)
            {
                var importList = _importListFactory.Get(list.Key);

                foreach (var movie in list)
                {
                    if (movie.TmdbId != 0)
                    {
                        ProcessMovieReport(importList, movie, importExclusions, dbMovies, moviesToAdd);
                    }
                }
            }

            if (moviesToAdd.Any())
            {
                _logger.Info($"Adding {moviesToAdd.Count} movies from your auto enabled lists to library");
            }

            _addMovieService.AddMovies(moviesToAdd, true);
        }
コード例 #3
0
        public object Import([FromBody] List <MovieResource> resource)
        {
            var newMovies = resource.ToModel();

            return(_addMovieService.AddMovies(newMovies).ToResource(0));
        }