public void ImdbWithPosterTest() { //Spiderman: tt0145487 //Inception: tt1375666 var scrapper = new ImdbScrapper(_xPathRepository); var movie = scrapper.GetMovie("tt0046912"); }
public void ImdbWithSeriesTest() { //Walking Dead: tt1520211 //Game Of Thrones: tt0944947 var scrapper = new ImdbScrapper(_xPathRepository); var movie = scrapper.GetMovie("tt0944947"); }
public void ImdbNormalLayout() { //Spiderman: tt0468569 //Dial M For Murder (old movie): tt0046912 var scrapper = new ImdbScrapper(_xPathRepository); var movie = scrapper.GetMovie("tt0381838"); }
public Movie Get(string imdbId) { var movie = _movieRepository.GetByImdbId(imdbId); //Get from IMDB website if (movie == null) { var scrapper = new ImdbScrapper(_movieXPathRepository); movie = scrapper.GetMovie(imdbId); } return(movie); }
public void UpdateNotUpdatedMovies() { var scrapper = new ImdbScrapper(_xPathRepository); var toUpdateMovies = _movieRepository.GetAll().Where(x => String.IsNullOrEmpty(x.Poster) && String.IsNullOrEmpty(x.Writers)).OrderBy(x => x.Title).Take(529).ToList(); foreach (var movie in toUpdateMovies) { string xmlDocument; var updatedMovie = scrapper.GetMovie(movie.ImdbId, out xmlDocument); UpdateMovie(movie, updatedMovie); var documentPath = String.Format("{0}/Documents", Environment.CurrentDirectory); var imagePath = String.Format("{0}/Images", Environment.CurrentDirectory); if (!Directory.Exists(imagePath)) { Directory.CreateDirectory(imagePath); } if (!Directory.Exists(documentPath)) { Directory.CreateDirectory(documentPath); } var uploadPath = String.Format("/Resources/images/{0}.jpg", movie.ImdbId); var documentFullPath = String.Format("{0}/{1}.txt", documentPath, movie.ImdbId); var fullPath = String.Format("{0}/{1}.jpg", imagePath, movie.ImdbId); if (!String.IsNullOrEmpty(updatedMovie.Poster)) { using (var client = new WebClient()) { client.DownloadFile(updatedMovie.Poster, fullPath); movie.Poster = uploadPath; } } using (var file = new StreamWriter(documentFullPath)) { file.WriteLine(xmlDocument); } _unitOfWork.Commit(); } }
public ActionResult Search(string key) { Movie movie; key = key.Trim(); if (key.IsIMDB() || key.IsIMDBUrl()) { if (key.IsIMDBUrl()) { key = ImdbHelper.GetImdbId(key); } //search for local record movie = _movieRepository.GetByImdbId(key); if (movie == null) { var scrapper = new ImdbScrapper(_movieXPathRepository); //movie = scrapper.LoadMovieFromFile("C:/GOT.txt"); movie = scrapper.GetMovie(key); } } else { movie = _movieRepository.GetByMovieName(key); if (movie == null) { movie = _movieRepository.GetMovieByAKA(key); } if (movie == null) { movie = new Movie(); TempData["NoSearchResult"] = true; } } ViewBag.Search = key; var viewModel = movie.MapItem <MovieViewModel>(); return(View("Index", viewModel)); }
public ActionResult MovieUpdate(int id) { var viewModel = new MovieViewModel(); if (id > 0) { var movie = _movieRepository.GetById(id); var scrapper = new ImdbScrapper(_movieXPathRepository); var scrappedMovie = scrapper.GetMovie(movie.ImdbId); viewModel = scrappedMovie.MapItem <MovieViewModel>(); viewModel.DateCreated = movie.DateCreated; viewModel.FileName = movie.FileName; viewModel.Location = movie.Location; viewModel.FileSize = movie.FileSize; viewModel.Remarks = movie.Remarks; viewModel.MovieId = movie.MovieId; viewModel.UpdateImage = true; } return(View("Index", viewModel)); }
public void FilipinoMoviesTest() { //Ang tanging ina: tt0368323 var scrapper = new ImdbScrapper(_xPathRepository); var movie = scrapper.GetMovie("tt0368323"); }