Example #1
0
        private Response SearchByTmdbId()
        {
            int tmdbId = -1;

            if (Int32.TryParse(Request.Query.tmdbId, out tmdbId))
            {
                var result = _movieInfo.GetMovieInfo(tmdbId, null, true);
                return(result.ToResource().AsResponse());
            }

            throw new BadRequestException("Tmdb Id was not valid");
        }
        public object SearchByTmdbId(int tmdbId)
        {
            var availDelay  = _configService.AvailabilityDelay;
            var result      = _movieInfo.GetMovieInfo(tmdbId).Item1;
            var translation = result.Translations.FirstOrDefault(t => t.Language == (Language)_configService.MovieInfoLanguage);

            return(result.ToResource(availDelay, translation));
        }
Example #3
0
        private object SearchByTmdbId()
        {
            int tmdbId = -1;

            if (int.TryParse(Request.Query.tmdbId, out tmdbId))
            {
                var result = _movieInfo.GetMovieInfo(tmdbId).Item1;
                return(result.ToResource());
            }

            throw new BadRequestException("Tmdb Id was not valid");
        }
Example #4
0
        private object SearchByTmdbId()
        {
            int tmdbId = -1;

            if (int.TryParse(Request.Query.tmdbId, out tmdbId))
            {
                var availDelay  = _configService.AvailabilityDelay;
                var result      = _movieInfo.GetMovieInfo(tmdbId).Item1;
                var translation = result.Translations.FirstOrDefault(t => t.Language == (Language)_configService.MovieInfoLanguage);
                return(result.ToResource(availDelay, translation));
            }

            throw new BadRequestException("Tmdb Id was not valid");
        }
Example #5
0
        private Movie AddSkyhookData(Movie newMovie)
        {
            Movie movie;

            try
            {
                movie = _movieInfo.GetMovieInfo(newMovie.TmdbId).Item1;
            }
            catch (MovieNotFoundException)
            {
                _logger.Error("TmdbId {0} was not found, it may have been removed from TMDb. Path: {1}", newMovie.TmdbId, newMovie.Path);

                throw new ValidationException(new List <ValidationFailure>
                {
                    new ValidationFailure("TmdbId", $"A movie with this ID was not found. Path: {newMovie.Path}", newMovie.TmdbId)
                });
            }

            movie.ApplyChanges(newMovie);

            return(movie);
        }
Example #6
0
        private Movie RefreshMovieInfo(int movieId)
        {
            // Get the movie before updating, that way any changes made to the movie after the refresh started,
            // but before this movie was refreshed won't be lost.
            var movie = _movieService.GetMovie(movieId);

            _logger.ProgressInfo("Updating info for {0}", movie.Title);

            Movie         movieInfo;
            List <Credit> credits;

            try
            {
                var tuple = _movieInfo.GetMovieInfo(movie.TmdbId);
                movieInfo = tuple.Item1;
                credits   = tuple.Item2;
            }
            catch (MovieNotFoundException)
            {
                if (movie.Status != MovieStatusType.Deleted)
                {
                    movie.Status = MovieStatusType.Deleted;
                    _movieService.UpdateMovie(movie);
                    _logger.Debug("Movie marked as deleted on TMDb for {0}", movie.Title);
                    _eventAggregator.PublishEvent(new MovieUpdatedEvent(movie));
                }

                throw;
            }

            if (movie.TmdbId != movieInfo.TmdbId)
            {
                _logger.Warn("Movie '{0}' (TMDb: {1}) was replaced with '{2}' (TMDb: {3}), because the original was a duplicate.", movie.Title, movie.TmdbId, movieInfo.Title, movieInfo.TmdbId);
                movie.TmdbId = movieInfo.TmdbId;
            }

            movie.Title         = movieInfo.Title;
            movie.TitleSlug     = movieInfo.TitleSlug;
            movie.ImdbId        = movieInfo.ImdbId;
            movie.Overview      = movieInfo.Overview;
            movie.Status        = movieInfo.Status;
            movie.CleanTitle    = movieInfo.CleanTitle;
            movie.SortTitle     = movieInfo.SortTitle;
            movie.LastInfoSync  = DateTime.UtcNow;
            movie.Runtime       = movieInfo.Runtime;
            movie.Images        = movieInfo.Images;
            movie.Ratings       = movieInfo.Ratings;
            movie.Collection    = movieInfo.Collection;
            movie.Genres        = movieInfo.Genres;
            movie.Certification = movieInfo.Certification;
            movie.InCinemas     = movieInfo.InCinemas;
            movie.Website       = movieInfo.Website;

            movie.Year             = movieInfo.Year;
            movie.SecondaryYear    = movieInfo.SecondaryYear;
            movie.PhysicalRelease  = movieInfo.PhysicalRelease;
            movie.DigitalRelease   = movieInfo.DigitalRelease;
            movie.YouTubeTrailerId = movieInfo.YouTubeTrailerId;
            movie.Studio           = movieInfo.Studio;
            movie.OriginalTitle    = movieInfo.OriginalTitle;
            movie.OriginalLanguage = movieInfo.OriginalLanguage;
            movie.HasPreDBEntry    = movieInfo.HasPreDBEntry;
            movie.Recommendations  = movieInfo.Recommendations;

            try
            {
                movie.Path = new DirectoryInfo(movie.Path).FullName;
                movie.Path = movie.Path.GetActualCasing();
            }
            catch (Exception e)
            {
                _logger.Warn(e, "Couldn't update movie path for " + movie.Path);
            }

            movie.AlternativeTitles = _titleService.UpdateTitles(movieInfo.AlternativeTitles, movie);
            _movieTranslationService.UpdateTranslations(movieInfo.Translations, movie);

            _movieService.UpdateMovie(new List <Movie> {
                movie
            }, true);
            _creditService.UpdateCredits(credits, movie);

            _logger.Debug("Finished movie refresh for {0}", movie.Title);
            _eventAggregator.PublishEvent(new MovieUpdatedEvent(movie));

            return(movie);
        }
Example #7
0
        private void RefreshMovieInfo(Movie movie)
        {
            _logger.ProgressInfo("Updating Info for {0}", movie.Title);

            Movie movieInfo;

            try
            {
                movieInfo = _movieInfo.GetMovieInfo(movie.TmdbId, movie.Profile, movie.HasPreDBEntry);
            }
            catch (MovieNotFoundException)
            {
                _logger.Error("Movie '{0}' (imdbid {1}) was not found, it may have been removed from TheTVDB.", movie.Title, movie.ImdbId);
                return;
            }

            if (movie.TmdbId != movieInfo.TmdbId)
            {
                _logger.Warn("Movie '{0}' (tvdbid {1}) was replaced with '{2}' (tvdbid {3}), because the original was a duplicate.", movie.Title, movie.TmdbId, movieInfo.Title, movieInfo.TmdbId);
                movie.TmdbId = movieInfo.TmdbId;
            }

            movie.Title         = movieInfo.Title;
            movie.TitleSlug     = movieInfo.TitleSlug;
            movie.ImdbId        = movieInfo.ImdbId;
            movie.Overview      = movieInfo.Overview;
            movie.Status        = movieInfo.Status;
            movie.CleanTitle    = movieInfo.CleanTitle;
            movie.SortTitle     = movieInfo.SortTitle;
            movie.LastInfoSync  = DateTime.UtcNow;
            movie.Runtime       = movieInfo.Runtime;
            movie.Images        = movieInfo.Images;
            movie.Ratings       = movieInfo.Ratings;
            movie.Actors        = movieInfo.Actors;
            movie.Genres        = movieInfo.Genres;
            movie.Certification = movieInfo.Certification;
            movie.InCinemas     = movieInfo.InCinemas;
            movie.Website       = movieInfo.Website;
            //movie.AlternativeTitles = movieInfo.AlternativeTitles;
            movie.Year             = movieInfo.Year;
            movie.PhysicalRelease  = movieInfo.PhysicalRelease;
            movie.YouTubeTrailerId = movieInfo.YouTubeTrailerId;
            movie.Studio           = movieInfo.Studio;
            movie.HasPreDBEntry    = movieInfo.HasPreDBEntry;

            try
            {
                movie.Path = new DirectoryInfo(movie.Path).FullName;
                movie.Path = movie.Path.GetActualCasing();
            }
            catch (Exception e)
            {
                _logger.Warn(e, "Couldn't update movie path for " + movie.Path);
            }

            try
            {
                var mappings       = _apiClient.AlternativeTitlesAndYearForMovie(movieInfo.TmdbId);
                var mappingsTitles = mappings.Item1;

                mappingsTitles = mappingsTitles.Where(t => t.IsTrusted()).ToList();

                movieInfo.AlternativeTitles.AddRange(mappingsTitles);

                movie.AlternativeTitles = _titleService.UpdateTitles(movieInfo.AlternativeTitles, movie);

                if (mappings.Item2 != null)
                {
                    movie.SecondaryYear         = mappings.Item2.Year;
                    movie.SecondaryYearSourceId = mappings.Item2.SourceId;
                }
                else
                {
                    movie.SecondaryYear         = null;
                    movie.SecondaryYearSourceId = 0;
                }
            }
            catch (RadarrAPIException ex)
            {
                //Not that wild, could just be a 404.
            }
            catch (Exception ex)
            {
                _logger.Info(ex, "Unable to communicate with Mappings Server.");
            }


            _movieService.UpdateMovie(movie);

            try
            {
                var newTitles = movieInfo.AlternativeTitles.Except(movie.AlternativeTitles);
                //_titleService.AddAltTitles(newTitles.ToList(), movie);
            }
            catch (Exception e)
            {
                _logger.Debug(e, "Failed adding alternative titles.");
                throw;
            }

            _logger.Debug("Finished movie refresh for {0}", movie.Title);
            _eventAggregator.PublishEvent(new MovieUpdatedEvent(movie));
        }