Exemplo n.º 1
0
        public void Execute(NetImportSyncCommand message)
        {
            //if there are no lists that are enabled for automatic import then dont do anything
            if ((_netImportFactory.GetAvailableProviders()).Where(a => ((NetImportDefinition)a.Definition).EnableAuto).Empty())
            {
                _logger.Info("No lists are enabled for auto-import.");
                return;
            }

            var listedMovies = Fetch(0, true);

            CleanLibrary(listedMovies);

            listedMovies = listedMovies.Where(x => !_movieService.MovieExists(x)).ToList();
            if (listedMovies.Any())
            {
                _logger.Info($"Found {listedMovies.Count()} movies on your auto enabled lists not in your library");
            }


            var importExclusions = new List <string>();

            //var downloadedCount = 0;
            foreach (var movie in listedMovies)
            {
                var mapped = _movieSearch.MapMovieToTmdbMovie(movie);
                if (mapped != null && !_exclusionService.IsMovieExcluded(mapped.TmdbId))
                {
                    //List<DownloadDecision> decisions;
                    mapped.AddOptions = new AddMovieOptions {
                        SearchForMovie = true
                    };
                    _movieService.AddMovie(mapped);

                    //// Search for movie
                    //try
                    //{
                    //    decisions = _nzbSearchService.MovieSearch(mapped.Id, false);
                    //}
                    //catch (Exception ex)
                    //{
                    //    _logger.Error(ex, $"Unable to search in list for movie {mapped.Id}");
                    //    continue;
                    //}

                    //var processed = _processDownloadDecisions.ProcessDecisions(decisions);
                    //downloadedCount += processed.Grabbed.Count;
                }
                else
                {
                    if (mapped != null)
                    {
                        _logger.Info($"{mapped.Title} ({mapped.TitleSlug}) will not be added since it was found on the exclusions list");
                    }
                }
            }

            //_logger.ProgressInfo("Movie search completed. {0} reports downloaded.", downloadedCount);
        }
Exemplo n.º 2
0
        private Response SaveAll()
        {
            var resources = Request.Body.FromJson <List <MovieResource> >();

            var Movies = resources.Select(MovieResource => _movieSearch.MapMovieToTmdbMovie(MovieResource.ToModel())).Where(m => m != null).DistinctBy(m => m.TmdbId).ToList();

            return(_movieService.AddMovies(Movies).ToResource().AsResponse(HttpStatusCode.Accepted));
        }
        private ImportListMovie MapMovieReport(ImportListMovie report)
        {
            var mappedMovie = _movieSearch.MapMovieToTmdbMovie(new Movie {
                Title = report.Title, TmdbId = report.TmdbId, ImdbId = report.ImdbId, Year = report.Year
            });

            var mappedListMovie = new ImportListMovie {
                ListId = report.ListId
            };

            if (mappedMovie != null)
            {
                mappedListMovie.TmdbId           = mappedMovie.TmdbId;
                mappedListMovie.ImdbId           = mappedMovie.ImdbId;
                mappedListMovie.Title            = mappedMovie.Title;
                mappedListMovie.SortTitle        = mappedMovie?.SortTitle;
                mappedListMovie.Year             = mappedMovie.Year;
                mappedListMovie.Overview         = mappedMovie.Overview;
                mappedListMovie.Ratings          = mappedMovie.Ratings;
                mappedListMovie.Studio           = mappedMovie.Studio;
                mappedListMovie.Certification    = mappedMovie.Certification;
                mappedListMovie.Collection       = mappedMovie.Collection;
                mappedListMovie.Status           = mappedMovie.Status;
                mappedListMovie.Images           = mappedMovie.Images;
                mappedListMovie.Website          = mappedMovie.Website;
                mappedListMovie.YouTubeTrailerId = mappedMovie.YouTubeTrailerId;
                mappedListMovie.Translations     = mappedMovie.Translations;
                mappedListMovie.InCinemas        = mappedMovie.InCinemas;
                mappedListMovie.PhysicalRelease  = mappedMovie.PhysicalRelease;
                mappedListMovie.DigitalRelease   = mappedMovie.DigitalRelease;
                mappedListMovie.Genres           = mappedMovie.Genres;
                mappedListMovie.Runtime          = mappedMovie.Runtime;
                mappedListMovie.OriginalTitle    = mappedMovie.OriginalTitle;
            }

            return(mappedListMovie);
        }
Exemplo n.º 4
0
        private Response Search()
        {
            if (Request.Query.Id == 0)
            {
                //Todo error handling
            }

            RootFolder rootFolder = _rootFolderService.Get(Request.Query.Id);

            int page     = Request.Query.page;
            int per_page = Request.Query.per_page;

            int min = (page - 1) * per_page;

            int max = page * per_page;

            var unmapped = rootFolder.UnmappedFolders.OrderBy(f => f.Name).ToList();

            int total_count = unmapped.Count;

            if (Request.Query.total_entries.HasValue)
            {
                total_count = Request.Query.total_entries;
            }

            max = total_count >= max ? max : total_count;

            var paged = unmapped.GetRange(min, max - min);

            var mapped = paged.Select(f =>
            {
                Core.Movies.Movie m = null;

                var mappedMovie = _mappedMovies.Find(f.Name);

                if (mappedMovie != null)
                {
                    return(mappedMovie);
                }

                var parsedTitle    = _parsingService.ParseMinimalPathMovieInfo(f.Name);
                parsedTitle.ImdbId = Parser.ParseImdbId(parsedTitle.SimpleReleaseTitle);
                if (parsedTitle == null)
                {
                    m = new Core.Movies.Movie
                    {
                        Title = f.Name.Replace(".", " ").Replace("-", " "),
                        Path  = f.Path,
                    };
                }
                else
                {
                    m = new Core.Movies.Movie
                    {
                        Title  = parsedTitle.MovieTitle,
                        Year   = parsedTitle.Year,
                        ImdbId = parsedTitle.ImdbId,
                        Path   = f.Path
                    };
                }

                var files = _diskScanService.GetVideoFiles(f.Path);

                var decisions = _importDecisionMaker.GetImportDecisions(files.ToList(), m, true);

                var decision = decisions.Where(d => d.Approved && !d.Rejections.Any()).FirstOrDefault();

                if (decision != null)
                {
                    var local = decision.LocalMovie;

                    m.MovieFile = new MovieFile
                    {
                        Path         = local.Path,
                        Edition      = local.ParsedMovieInfo.Edition,
                        Quality      = local.Quality,
                        MediaInfo    = local.MediaInfo,
                        ReleaseGroup = local.ParsedMovieInfo.ReleaseGroup,
                        RelativePath = f.Path.GetRelativePath(local.Path)
                    };
                }

                mappedMovie = _searchProxy.MapMovieToTmdbMovie(m);

                if (mappedMovie != null)
                {
                    mappedMovie.Monitored = true;

                    _mappedMovies.Set(f.Name, mappedMovie, TimeSpan.FromDays(2));

                    return(mappedMovie);
                }

                return(null);
            });

            return(new PagingResource <MovieResource>
            {
                Page = page,
                PageSize = per_page,
                SortDirection = SortDirection.Ascending,
                SortKey = Request.Query.sort_by,
                TotalRecords = total_count - mapped.Where(m => m == null).Count(),
                Records = MapToResource(mapped.Where(m => m != null)).ToList()
            }.AsResponse());
        }