private async Task UpdateFromMovie(string path, FullMovie movie)
        {
            await SetFullMovieSynopsis(movie);
            await SetRating(movie);
            await UpdateInformationMetadata(path, movie);

            await _imagesService.Update(path, movie);
        }
        /// <summary>
        /// Updates the images of the movie located at the specified path.
        /// </summary>
        /// <param name="path">The movie path.</param>
        /// <param name="movie">The movie metadata.</param>
        public async Task Update(string path, FullMovie movie)
        {
            string posterPath = MovieHelper.GetMoviePosterPath(path);
            await UpdateImageIfNeeded(posterPath, movie.PosterPath);

            string fanartPath = MovieHelper.GetMovieFanartPath(path);
            await UpdateImageIfNeeded(fanartPath, movie.BackdropPath);
        }
        private async Task UpdateInformationMetadata(string path, FullMovie movie)
        {
            MovieMetadata metadata = MapFullMovieToMetadata(movie);

            await UpdateActorsMetadata(path, metadata);

            metadata.FileInformation = _fileInformationService.GetVideoFileInformation(path);
            await Save(path, metadata);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the movie metadata.
        /// </summary>
        /// <param name="movieId">The movie identifier.</param>
        /// <returns></returns>
        public async Task <FullMovie> GetMovieMetadata(string movieId)
        {
            string    url       = string.Format("3/movie/{0}?api_key={1}", movieId, MovieHelper.ThemoviedbApiKey);
            FullMovie fullMovie = await _restApiService.Get <FullMovie>(url);

            await FixImagesUrl(fullMovie);

            return(fullMovie);
        }
        /// <summary>
        /// Updates the images of the movie located at the specified path.
        /// </summary>
        /// <param name="path">The movie path.</param>
        /// <param name="movie">The movie metadata.</param>
        public async Task Update(string path, FullMovie movie)
        {
            string posterPath = MovieHelper.GetMoviePosterPath(path);

            await UpdateImageIfNeeded(posterPath, movie.PosterPath);

            string fanartPath = MovieHelper.GetMovieFanartPath(path);

            await UpdateImageIfNeeded(fanartPath, movie.BackdropPath);
        }
        /// <summary>
        /// Updates the movie located at the specified path.
        /// </summary>
        /// <param name="path">The movie file path.</param>
        /// <exception cref="MovieNotFoundException">No movie found</exception>
        public async Task Update(string path)
        {
            FullMovie movie = await FindFullMovie(path);

            if (string.IsNullOrEmpty(movie.ImdbId))
            {
                throw new MovieNotFoundException("No movie found for " + path);
            }
            await UpdateFromMovie(path, movie);
        }
Beispiel #7
0
 private async Task FixImagesUrl(FullMovie fullMovie)
 {
     if (!string.IsNullOrEmpty(fullMovie.BackdropPath))
     {
         fullMovie.BackdropPath = await GetImageBasePath() + "original" + fullMovie.BackdropPath;
     }
     if (!string.IsNullOrEmpty(fullMovie.PosterPath))
     {
         fullMovie.PosterPath = await GetImageBasePath() + "original" + fullMovie.PosterPath;
     }
 }
        private async Task <FullMovie> FindFullMovie(string path)
        {
            string movieId = await GetMovieId(path);

            FullMovie fullMovie = await _metadataUpdater.GetMovieMetadata(movieId);

            if (fullMovie == null)
            {
                throw new MovieNotFoundException(path);
            }
            return(fullMovie);
        }
Beispiel #9
0
        private async Task UpdateMoviePoster(bool fileExists, bool imageIsFound)
        {
            // Arrange
            _fileSystemService.FileExists(PosterPath)
            .Returns(Task.FromResult(fileExists));
            FullMovie movie = new FullMovie();

            if (imageIsFound)
            {
                movie.PosterPath = ImageUrl;
            }

            // Act
            await _service.Update(MoviePath, movie);
        }
        private async Task SetFullMovieSynopsis(FullMovie movie)
        {
            MovieSynopsis synopsis = await _synopsisService.GetSynopsis(movie.ImdbId);

            if (string.IsNullOrEmpty(movie.Tagline))
            {
                movie.Tagline = synopsis.Tagline;
            }
            if (!string.IsNullOrEmpty(synopsis.Outline))
            {
                movie.Overview = synopsis.Outline;
            }
            if (!string.IsNullOrEmpty(synopsis.Plot))
            {
                movie.Plot = synopsis.Plot;
            }
        }
        private MovieMetadata MapFullMovieToMetadata(FullMovie movie)
        {
            MovieMetadata metadata = new MovieMetadata();

            metadata.Certification    = movie.Certification;
            metadata.Genres           = movie.Genres.Select(genre => genre.Name).ToList();
            metadata.Id               = movie.ImdbId;
            metadata.OriginalTitle    = movie.OriginalTitle;
            metadata.Outline          = movie.Overview;
            metadata.Plot             = movie.Plot;
            metadata.Rating           = movie.VoteAverage;
            metadata.RuntimeInMinutes = movie.Runtime;
            metadata.Tagline          = movie.Tagline;
            metadata.Title            = movie.Title;
            metadata.PlayCount        = 0;

            if (movie.BelongsToCollection != null)
            {
                metadata.SetName = movie.BelongsToCollection.Name;
            }

            if (movie.ReleaseDate.HasValue)
            {
                metadata.Premiered = movie.ReleaseDate;
                metadata.Year      = movie.ReleaseDate.Value.Year;
            }

            Reference productionCompany = movie.ProductionCompanies.FirstOrDefault();

            if (productionCompany != null)
            {
                metadata.Studio = productionCompany.Name;
            }

            Reference productionCountry = movie.ProductionCountries.FirstOrDefault();

            if (productionCountry != null)
            {
                metadata.Country = productionCountry.Name;
            }

            return(metadata);
        }
 private async Task SetRating(FullMovie movie)
 {
     movie.Certification = await _metadataUpdater.FindCertification(movie.ImdbId);
 }
 private async Task FixImagesUrl(FullMovie fullMovie)
 {
     if (!string.IsNullOrEmpty(fullMovie.BackdropPath))
     {
         fullMovie.BackdropPath = await GetImageBasePath() + "original" + fullMovie.BackdropPath;
     }
     if (!string.IsNullOrEmpty(fullMovie.PosterPath))
     {
         fullMovie.PosterPath = await GetImageBasePath() + "original" + fullMovie.PosterPath;
     }
 }
 private async Task SetRating(FullMovie movie)
 {
     movie.Certification = await _metadataUpdater.FindCertification(movie.ImdbId);
 }
 private async Task UpdateFromMovie(string path, FullMovie movie)
 {
     await SetFullMovieSynopsis(movie);
     await SetRating(movie);
     await UpdateInformationMetadata(path, movie);
     await _imagesService.Update(path, movie);
 }
 private async Task SetFullMovieSynopsis(FullMovie movie)
 {
     MovieSynopsis synopsis = await _synopsisService.GetSynopsis(movie.ImdbId);
     if (string.IsNullOrEmpty(movie.Tagline))
     {
         movie.Tagline = synopsis.Tagline;
     }
     if (!string.IsNullOrEmpty(synopsis.Outline))
     {
         movie.Overview = synopsis.Outline;
     }
     if (!string.IsNullOrEmpty(synopsis.Plot))
     {
         movie.Plot = synopsis.Plot;
     }
 }
        private MovieMetadata MapFullMovieToMetadata(FullMovie movie)
        {
            MovieMetadata metadata = new MovieMetadata();
            metadata.Certification = movie.Certification;
            metadata.Genres = movie.Genres.Select(genre => genre.Name).ToList();
            metadata.Id = movie.ImdbId;
            metadata.OriginalTitle = movie.OriginalTitle;
            metadata.Outline = movie.Overview;
            metadata.Plot = movie.Plot;
            metadata.Rating = movie.VoteAverage;
            metadata.RuntimeInMinutes = movie.Runtime;
            metadata.Tagline = movie.Tagline;
            metadata.Title = movie.Title;
            metadata.PlayCount = 0;

            if (movie.BelongsToCollection != null)
            {
                metadata.SetName = movie.BelongsToCollection.Name;
            }

            if (movie.ReleaseDate.HasValue)
            {
                metadata.Premiered = movie.ReleaseDate;
                metadata.Year = movie.ReleaseDate.Value.Year;
            }

            Reference productionCompany = movie.ProductionCompanies.FirstOrDefault();
            if (productionCompany != null)
            {
                metadata.Studio = productionCompany.Name;
            }

            Reference productionCountry = movie.ProductionCountries.FirstOrDefault();
            if (productionCountry != null)
            {
                metadata.Country = productionCountry.Name;
            }

            return metadata;
        }
        private async Task UpdateMoviePoster(bool fileExists, bool imageIsFound)
        {
            // Arrange
            _fileSystemService.FileExists(PosterPath)
                .Returns(Task.FromResult(fileExists));
            FullMovie movie = new FullMovie();
            if (imageIsFound)
            {
                movie.PosterPath = ImageUrl;
            }

            // Act
            await _service.Update(MoviePath, movie);
        }
 private async Task UpdateInformationMetadata(string path, FullMovie movie)
 {
     MovieMetadata metadata = MapFullMovieToMetadata(movie);
     await UpdateActorsMetadata(path, metadata);
     metadata.FileInformation = _fileInformationService.GetVideoFileInformation(path);
     await Save(path, metadata);
 }