public void AddBackdrop(Movie m, MovieModel movie) { if (m.Images != null && m.Images.Backdrops != null && m.Images.Backdrops.Any()) { IOrderedEnumerable <ImageData> imageDatas = m.Images.Backdrops.OrderByDescending(i => i.VoteAverage); Guid posterId = AddImage(imageDatas.First()); movie.Backdrop = GlassExtensions.GetImage(posterId, movie.Title); } }
private void AddImages(Movie movie, MovieModel importedMovie) { ExecuteWithExceptionHandling(() => { _movieManager.AddPoster(movie, importedMovie); _movieManager.AddBackdrop(movie, importedMovie); } , string.Format("An error occurred while creating images for movie {0} with id {1}", movie.Title, movie.Id.ToString())); }
public void AddGenres(Movie movie, MovieModel importedMovie) { List <GenreModel> genres = GetGenres(movie); if (genres.Any()) { importedMovie.Genres = genres.AsItemIDs(); } }
public void Add(Movie m) { if (m == null) { return; } MovieModel movie = Mapper.Map <MovieModel>(m); movie.Save(_moviesRootFolder, _masterService); }
private void ImportMovies() { _maxItemCount = 1000; DateTime now = DateTime.Now; DateTime startYear = new DateTime(now.Year - 2, now.Month, now.Day); SearchContainer <SearchMovie> movies = _movieManager.Discover(startYear); int resultCount = movies.TotalResults; if (_maxItemCount > resultCount) { _maxItemCount = resultCount; } int totalPageCount = _maxItemCount / RebootConstants.PageSize; for (int i = 0; i < totalPageCount;) { foreach (var m in movies.Results) { string title = "Unknown"; string id = Guid.Empty.ToString(); try { Movie movie = _movieManager.Get(m.Id); title = movie.Title; id = movie.Id.ToString(); if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(title) || IDTableExtesions.HasIDTableEntry <MovieModel>(id)) { continue; } MovieModel importedMovie = _movieManager.GetMappedMovie(movie); AddGenres(movie, importedMovie); AddLanguageToMovie(movie, importedMovie); AddCrew(movie, importedMovie); AddCast(movie, importedMovie); AddImages(movie, importedMovie); AddTrailers(movie, importedMovie); AddProductionCompanies(movie, importedMovie); //Finally Add the movie to the database _movieManager.Save(importedMovie); } catch (Exception ex) { Log.Error(string.Format("An error occurred while creating movie {0} with id {1}", title, id), ex, title); } } i++; movies = _movieManager.Discover(startYear, i); } }
public void AddProductionCompany(List <ProductionCompany> c, MovieModel movie) { List <Guid> companies = new List <Guid>(); foreach (IProductionCompany comp in c.Select(Mapper.Map <ProductionCompanyModel>)) { comp.Save(_prodCompaniesRootFolder, _masterService); if (comp.Id != Guid.Empty) { companies.Add(comp.Id); } } if (companies.Any()) { movie.ProductionCompanies = companies; } }
public void AddTrailers(Trailers t, MovieModel movie) { List <Guid> trailers = new List <Guid>(); foreach (TrailerModel trailer in t.Youtube.Select(Mapper.Map <TrailerModel>)) { trailer.ExternalId = t.Id.ToString(); trailer.Save(_trailersRootFolder, _masterService); if (trailer.Id != Guid.Empty) { trailers.Add(trailer.Id); } } if (trailers.Any()) { movie.Trailers = trailers; } }
public void AddProductionCompany(Movie m, MovieModel movie) { AddProductionCompany(m.ProductionCompanies, movie); }
public void AddTrailers(Movie m, MovieModel movie) { AddTrailers(m.Trailers, movie); }
public void Save(MovieModel movie) { movie.Save(_moviesRootFolder, _masterService); }
private void AddGenres(Movie movie, MovieModel importedMovie) { ExecuteWithExceptionHandling(() => _movieManager.AddGenres(movie, importedMovie) , string.Format("An error occurred while creating Genres for movie {0} with id {1}", movie.Title, movie.Id.ToString())); }