Exemplo n.º 1
0
        public ActionResult <ImdbMovie> Details(int id)
        {
            string    imbdId = _client.GetMovieAsync(id).Result.ImdbId;
            ImdbMovie movie  = _imdb.GetMovieFromIdAsync(imbdId).Result;

            return(movie);
        }
Exemplo n.º 2
0
        public Movie Create(ImdbMovie movieIn)
        {
            var movie = new Movie()
            {
                Title        = movieIn.Title,
                Year         = movieIn.Year,
                Runtime      = movieIn.RunTime,
                Genre        = movieIn.Genre,
                Director     = movieIn.Director,
                Writer       = movieIn.Writer,
                Actors       = movieIn.Actors,
                Plot         = movieIn.Plot,
                Language     = movieIn.Language,
                Awards       = movieIn.Awards,
                Poster       = movieIn.Poster,
                ImdbRating   = movieIn.ImdbRating,
                TomatoRating = movieIn.TomatoRating,
                ImdbId       = movieIn.ImdbId,
                Rated        = movieIn.Rated,
                Production   = movieIn.Production
            };

            _movies.InsertOne(movie);
            return(movie);
        }
Exemplo n.º 3
0
 public static ImdbMovie ImdbScrapeFromId(string imdbId, bool GetExtraInfo = true)
 {
     ImdbMovie mov = new ImdbMovie();
     string imdbUrl = "http://www.imdb.com/title/" + imdbId + "/";
     mov.Status = false;
     ParseIMDbPage(imdbUrl, GetExtraInfo, mov);
     return mov;
 }
Exemplo n.º 4
0
 //Parse IMDb page data
 private static void ParseIMDbPage(string imdbUrl, bool GetExtraInfo, ImdbMovie mov)
 {
     string html = GetUrlData(imdbUrl + "combined");
     mov.Id = match(@"<link rel=""canonical"" href=""http://www.imdb.com/title/(tt\d{7})/combined"" />", html);
     if (!string.IsNullOrEmpty(mov.Id))
     {
         mov.Status = true;
         mov.Title = match(@"<title>(IMDb \- )*(.*?) \(.*?</title>", html, 2);
         mov.OriginalTitle = match(@"title-extra"">(.*?)<", html);
         mov.Year = match(@"<title>.*?\(.*?(\d{4}).*?\).*?</title>", match(@"(<title>.*?</title>)", html));
         mov.Rating = match(@"<b>(\d.\d)/10</b>", html);
         mov.Genres = MatchAll(@"<a.*?>(.*?)</a>", match(@"Genre.?:(.*?)(</div>|See more)", html)).Cast<string>().ToList();
         mov.Plot = match(@"Plot:</h5>.*?<div class=""info-content"">(.*?)(<a|</div)", html);
         //mov.Directors = matchAll(@"<td valign=""top""><a.*?href=""/name/.*?/"">(.*?)</a>", match(@"Directed by</a></h5>(.*?)</table>", html));
         //mov.Writers = matchAll(@"<td valign=""top""><a.*?href=""/name/.*?/"">(.*?)</a>", match(@"Writing credits</a></h5>(.*?)</table>", html));
         //mov.Producers = matchAll(@"<td valign=""top""><a.*?href=""/name/.*?/"">(.*?)</a>", match(@"Produced by</a></h5>(.*?)</table>", html));
         //mov.Musicians = matchAll(@"<td valign=""top""><a.*?href=""/name/.*?/"">(.*?)</a>", match(@"Original Music by</a></h5>(.*?)</table>", html));
         //mov.Cinematographers = matchAll(@"<td valign=""top""><a.*?href=""/name/.*?/"">(.*?)</a>", match(@"Cinematography by</a></h5>(.*?)</table>", html));
         //mov.Editors = matchAll(@"<td valign=""top""><a.*?href=""/name/.*?/"">(.*?)</a>", match(@"Film Editing by</a></h5>(.*?)</table>", html));
         //mov.Cast = matchAll(@"<td class=""nm""><a.*?href=""/name/.*?/"".*?>(.*?)</a>", match(@"<h3>Cast</h3>(.*?)</table>", html));
         //mov.PlotKeywords = matchAll(@"<a.*?>(.*?)</a>", match(@"Plot Keywords:</h5>.*?<div class=""info-content"">(.*?)</div", html));
         //mov.ReleaseDate = match(@"Release Date:</h5>.*?<div class=""info-content"">.*?(\d{1,2} (January|February|March|April|May|June|July|August|September|October|November|December) (19|20)\d{2})", html);
         //mov.Runtime = match(@"Runtime:</h5><div class=""info-content"">(\d{1,4}) min[\s]*.*?</div>", html);
         //mov.Top250 = match(@"Top 250: #(\d{1,3})<", html);
         //mov.Oscars = match(@"Won (\d+) Oscars?\.", html);
         //if (string.IsNullOrEmpty(mov.Oscars) && "Won Oscar.".Equals(match(@"(Won Oscar\.)", html))) mov.Oscars = "1";
         //mov.Awards = match(@"(\d{1,4}) wins", html);
         //mov.Nominations = match(@"(\d{1,4}) nominations", html);
         //mov.Tagline = match(@"Tagline:</h5>.*?<div class=""info-content"">(.*?)(<a|</div)", html);
         //mov.MpaaRating = match(@"MPAA</a>:</h5><div class=""info-content"">Rated (G|PG|PG-13|PG-14|R|NC-17|X) ", html);
         //mov.Votes = match(@">(\d+,?\d*) votes<", html);
         //mov.Languages = matchAll(@"<a.*?>(.*?)</a>", match(@"Language.?:(.*?)(</div>|>.?and )", html));
         //mov.Countries = matchAll(@"<a.*?>(.*?)</a>", match(@"Country:(.*?)(</div>|>.?and )", html));
         mov.Poster = match(@"<div class=""photo"">.*?<a name=""poster"".*?><img.*?src=""(.*?)"".*?</div>", html);
         if (!string.IsNullOrEmpty(mov.Poster) && mov.Poster.IndexOf("media-imdb.com") > 0)
         {
             mov.Poster = Regex.Replace(mov.Poster, @"_V1.*?.jpg", "_V1._SY200.jpg");
             //mov.PosterLarge = Regex.Replace(mov.Poster, @"_V1.*?.jpg", "_V1._SY500.jpg");
             //mov.PosterFull = Regex.Replace(mov.Poster, @"_V1.*?.jpg", "_V1._SY0.jpg");
         }
         else
         {
             mov.Poster = string.Empty;
             //mov.PosterLarge = string.Empty;
             //mov.PosterFull = string.Empty;
         }
         mov.ImdbURL = "http://www.imdb.com/title/" + mov.Id + "/";
         if (GetExtraInfo)
         {
             string plotHtml = GetUrlData(imdbUrl + "plotsummary");
             //mov.Storyline = match(@"<p class=""plotpar"">(.*?)(<i>|</p>)", plotHtml);
             GetReleaseDatesAndAka(mov);
             //mov.MediaImages = getMediaImages(mov);
             //mov.RecommendedTitles = getRecommendedTitles(mov);
         }
     }
 }
Exemplo n.º 5
0
 private void OnGetMovieCallback(ImdbMovie mov, Exception ex)
 {
     IsBusy = false;
     if (ex != null)
     {
         Messenger.Default.Send(ex);
         SelMovie = null;
         return;
     }
     SelMovie = new SingleMovieViewModel(mov);
 }
Exemplo n.º 6
0
        //Constructor
        public static ImdbMovie ImdbScrape(string MovieName, bool GetExtraInfo = true)
        {
            ImdbMovie mov = new ImdbMovie();
            string imdbUrl = GetIMDbUrl(System.Uri.EscapeUriString(MovieName));
            mov.Status = false;
            if (!string.IsNullOrWhiteSpace(imdbUrl))
            {
                ParseIMDbPage(imdbUrl, GetExtraInfo, mov);
            }

            return mov;
        }
Exemplo n.º 7
0
        public ActionResult AddMovieToCollection(string imbdId, string userId, string comment, decimal rating)
        {
            ImdbMovie movie = _imdb.GetMovieFromIdAsync(imbdId).Result;

            if (_movieService.Exists(movie.ImdbId) == false)
            {
                _movieService.Create(movie);
            }

            var movieCollection = _userService.AddMovieToCollection(ObjectId.Parse(userId), movie, comment, rating);

            return(CreatedAtAction("GetMovieCollection", new { id = movieCollection.Id }, movieCollection));
        }
Exemplo n.º 8
0
        public ImdbMovie GetMovie(string url)
        {
            var imdb = new ImdbMovScraped(url);

            if (!imdb.Status)
            {
                throw new Exception("Data could not be scraped!");
            }
            //return (ImdbMovie)imdb;

            var mov = new ImdbMovie
            {
                Awards        = string.IsNullOrWhiteSpace(imdb.Awards) ? (byte)0 : Convert.ToByte(imdb.Awards),
                Countries     = imdb.Countries.Cast <string>().ToList(),
                Directors     = imdb.Directors.Cast <string>().ToList(),
                Genres        = imdb.Genres.Cast <string>().ToList(),
                Id            = imdb.Id,
                ImdbUrl       = imdb.ImdbUrl,
                MediaImages   = imdb.MediaImages.Cast <string>().ToList(),
                MpaaRating    = imdb.MpaaRating,
                Nominations   = string.IsNullOrWhiteSpace(imdb.Nominations) ? (byte)0 : Convert.ToByte(imdb.Nominations),
                OriginalTitle = imdb.OriginalTitle,
                Oscars        = string.IsNullOrWhiteSpace(imdb.Oscars) ? (byte)0 : Convert.ToByte(imdb.Oscars),
                Plot          = imdb.Plot,
                Poster        = imdb.Poster,
                PosterFull    = imdb.PosterFull,
                PosterLarge   = imdb.PosterLarge,
                Rating        = string.IsNullOrWhiteSpace(imdb.Rating) ? 0 : Double.Parse(imdb.Rating, NumberFormatInfo.InvariantInfo),
                ReleaseDate   = string.IsNullOrWhiteSpace(imdb.ReleaseDate) ? (DateTime?)null : Convert.ToDateTime(imdb.ReleaseDate),
                Runtime       = string.IsNullOrWhiteSpace(imdb.Runtime) ? (short)0 : Convert.ToInt16(imdb.Runtime),
                Storyline     = imdb.Storyline,
                Tagline       = imdb.Tagline,
                Title         = string.IsNullOrEmpty(imdb.OriginalTitle) ? imdb.Title : imdb.OriginalTitle,
                Top250        = string.IsNullOrWhiteSpace(imdb.Top250) ? (byte)0 : Convert.ToByte(imdb.Top250),
                Votes         = string.IsNullOrWhiteSpace(imdb.Votes) ? 0 : Convert.ToUInt32(imdb.Votes.Replace(",", "")),
                Writers       = imdb.Writers.Cast <string>().ToList(),
                Year          = string.IsNullOrWhiteSpace(imdb.Year) ? (short)0 : Convert.ToInt16(imdb.Year)
            };

            var actors = (from string star in imdb.Stars
                          select new Star(star)).Cast <Actor>().ToList();

            actors.AddRange(from object cast in imdb.Cast
                            where !imdb.Stars.Contains(cast)
                            select new Actor(cast.ToString()));
            mov.Cast = actors;
            //mov.Cast=(from string cast in imdb.Cast
            //            select new Actor(cast)).ToList();
            return(mov);
        }
Exemplo n.º 9
0
        public ImdbMovie GetMovie(string url)
        {
            var imdb = new ImdbMovScraped(url);
            if (!imdb.Status)
                throw new Exception("Data could not be scraped!");
            //return (ImdbMovie)imdb;

            var mov = new ImdbMovie
            {
                Awards = string.IsNullOrWhiteSpace(imdb.Awards) ? (byte)0 : Convert.ToByte(imdb.Awards),
                Countries = imdb.Countries.Cast<string>().ToList(),
                Directors = imdb.Directors.Cast<string>().ToList(),
                Genres = imdb.Genres.Cast<string>().ToList(),
                Id = imdb.Id,
                ImdbUrl = imdb.ImdbUrl,
                MediaImages = imdb.MediaImages.Cast<string>().ToList(),
                MpaaRating = imdb.MpaaRating,
                Nominations = string.IsNullOrWhiteSpace(imdb.Nominations) ? (byte)0 : Convert.ToByte(imdb.Nominations),
                OriginalTitle = imdb.OriginalTitle,
                Oscars = string.IsNullOrWhiteSpace(imdb.Oscars) ? (byte)0 : Convert.ToByte(imdb.Oscars),
                Plot = imdb.Plot,
                Poster = imdb.Poster,
                PosterFull = imdb.PosterFull,
                PosterLarge = imdb.PosterLarge,
                Rating = string.IsNullOrWhiteSpace(imdb.Rating) ? 0 : Double.Parse(imdb.Rating, NumberFormatInfo.InvariantInfo),
                ReleaseDate = string.IsNullOrWhiteSpace(imdb.ReleaseDate) ? (DateTime?)null : Convert.ToDateTime(imdb.ReleaseDate),
                Runtime = string.IsNullOrWhiteSpace(imdb.Runtime) ? (short)0 : Convert.ToInt16(imdb.Runtime),
                Storyline = imdb.Storyline,
                Tagline = imdb.Tagline,
                Title = string.IsNullOrEmpty(imdb.OriginalTitle) ? imdb.Title : imdb.OriginalTitle,
                Top250 = string.IsNullOrWhiteSpace(imdb.Top250) ? (byte)0 : Convert.ToByte(imdb.Top250),
                Votes = string.IsNullOrWhiteSpace(imdb.Votes) ? 0 : Convert.ToUInt32(imdb.Votes.Replace(",", "")),
                Writers = imdb.Writers.Cast<string>().ToList(),
                Year = string.IsNullOrWhiteSpace(imdb.Year) ? (short)0 : Convert.ToInt16(imdb.Year)
            };

            var actors = (from string star in imdb.Stars
                          select new Star(star)).Cast<Actor>().ToList();

            actors.AddRange(from object cast in imdb.Cast
                            where !imdb.Stars.Contains(cast)
                            select new Actor(cast.ToString()));
            mov.Cast = actors;
            //mov.Cast=(from string cast in imdb.Cast
            //            select new Actor(cast)).ToList();
            return mov;
        }
Exemplo n.º 10
0
        public MovieCollection AddMovieToCollection(ObjectId userId, ImdbMovie movieIn, string comment, decimal rating)
        {
            if (_movieCollections.Find(x => x.UserId == userId && x.MovieId == movieIn.ImdbId).SingleOrDefault() != null)
            {
                throw new Exception("Movie already in collection");
            }
            var movieCollection = new MovieCollection()
            {
                MovieId = movieIn.ImdbId,
                UserId  = userId,
                Rating  = rating,
                Comment = comment
            };

            _movieCollections.InsertOne(movieCollection);
            return(movieCollection);
        }
        /// <summary>
        /// Responsible for persisting process information for a movie uploaded by user.
        /// </summary>
        /// <param name="imdbId">Imdb ID for movie.</param>
        /// <param name="status">Process status.</param>
        /// <param name="statusText">Description of process.</param>
        public void PersistMovieProcessInfo(
            string imdbId,
            string status,
            string statusText)
        {
            if (!movieRepository.CheckMovieExist(imdbId))
            {
                ImdbMovie imdbMovie = new ImdbMovie()
                {
                    ImdbId     = imdbId,
                    Status     = status,
                    StatusText = statusText,
                };

                this.movieRepository.PersistMovie(imdbMovie);
                this.unitOfWork.Complete();
            }
        }
Exemplo n.º 12
0
        // GET: Movies/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var movie = await _context.Movie
                        .SingleOrDefaultAsync(m => m.ID == id);

            if (movie == null)
            {
                return(NotFound());
            }

            ImdbMovie movieRev = this.GetMovieData(movie.Title);


            return(View("details", movieRev));
        }
Exemplo n.º 13
0
 public void InsertMovie(ImdbMovie newMovie, Action <OperationStatus, Exception> userCallback)
 {
 }
Exemplo n.º 14
0
 public void UpdateMovie(ImdbMovie updMovie, Action <OperationStatus, Exception> userCallback)
 {
 }
Exemplo n.º 15
0
 public void DeleteMovie(ImdbMovie delMovie, Action <OperationStatus, Exception> userCallback)
 {
 }
Exemplo n.º 16
0
        public void GetMovie(string name, Action <ImdbMovie, Exception> userCallback)
        {
            var mov = new ImdbMovie
            {
                Id            = "tt1375666",
                Title         = "Inception",
                OriginalTitle = "Inception",
                Year          = 2010,
                Rating        = 8.9,
                Genres        = new List <string> {
                    "Action", "Adventure", "Sci-Fi", "Thriller"
                },
                Directors = new List <string> {
                    "Christopher Nolan"
                },
                Writers = new List <string> {
                    "Christopher Nolan"
                },
                Cast = new List <Actor>
                {
                    new Star("Leonardo DiCaprio"),
                    new Star("Joseph Gordon-Levitt"),
                    new Star("Ellen Page"),
                    new Actor("Tom Hardy"),
                    new Actor("Ken Watanabe"),
                    new Actor("Dileep Rao"),
                    new Actor("Cillian Murphy"),
                    new Actor("Tom Berenger"),
                    new Actor("Marion Cotillard"),
                    new Actor("Pete Postlethwaite"),
                    new Actor("Michael Caine"),
                    new Actor("Lukas Haas"),
                    new Actor("Tai-Li Lee"),
                    new Actor("Claire Geare"),
                    new Actor("Magnus Nolan")
                },
                MpaaRating  = "PG_13",
                ReleaseDate = Convert.ToDateTime("16 July 2010"),
                Plot        = "In a world where technology exists to enter the human mind through dream invasion, a highly skilled thief is given a final chance at redemption which involves executing his toughest job to date: Inception.",
                Poster      = "/img/poster.jpg",
                PosterLarge = "/img/posterlarge.jpg",
                PosterFull  = "/img/posterfull.jpg",
                //Poster = @"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1._SY317_.jpg",
                //PosterFull = @"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1._SY0.jpg",
                //PosterLarge = @"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1._SY500.jpg",
                //PosterSmall = @"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1._SY150.jpg",
                Runtime     = 148,
                Top250      = 9,
                Oscars      = 4,
                Awards      = 69,
                Nominations = 97,
                Storyline   = "Dom Cobb is a skilled thief, the absolute best in the dangerous art of extraction, stealing valuable secrets from deep within the subconscious during the dream state, when the mind is at its most vulnerable. Cobb's rare ability has made him a coveted player in this treacherous new world of corporate espionage, but it has also made him an international fugitive and cost him everything he has ever loved. Now Cobb is being offered a chance at redemption. One last job could give him his life back but only if he can accomplish the impossible-inception. Instead of the perfect heist, Cobb and his team of specialists have to pull off the reverse: their task is not to steal an idea but to plant one. If they succeed, it could be the perfect crime. But no amount of careful planning or expertise can prepare the team for the dangerous enemy that seems to predict their every move. An enemy that only Cobb could have seen coming.",
                Tagline     = "Your mind is the scene of the crime",
                Votes       = 393458,
                ImdbUrl     = "http://www.imdb.com/title/tt1375666/",
                MediaImages = new List <string> {
                    "/img/media01.jpg", "/img/media02.jpg", "/img/media03.jpg", "/img/media04.jpg", "/img/media05.jpg", "/img/media06.jpg", "/img/media07.jpg", "/img/media08.jpg", "/img/media09.jpg"
                }
                //MediaImages = new ObservableCollection<string> { "http://ia.media-imdb.com/images/M/MV5BMjIzNjc5NTMwM15BMl5BanBnXkFtZTcwMjQyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMjI0MTg3MzI0M15BMl5BanBnXkFtZTcwMzQyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMjI1NjM2MDMxMF5BMl5BanBnXkFtZTcwNDQyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTg5MTM1NDk4NF5BMl5BanBnXkFtZTcwNTQyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTc3NTYyMTkyMl5BMl5BanBnXkFtZTcwNjQyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTMyODk0MDUyOF5BMl5BanBnXkFtZTcwNzQyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTU0NTMwNzMxNl5BMl5BanBnXkFtZTcwODQyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTExNDg3NjMyMTBeQTJeQWpwZ15BbWU3MDk0Mjg1NjM@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTYyODA1OTI4OV5BMl5BanBnXkFtZTcwMDUyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTQzMTUzNjc4Nl5BMl5BanBnXkFtZTcwMTUyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMjE2MTI1MjA3MF5BMl5BanBnXkFtZTcwMjUyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTI4MDA0OTY5MF5BMl5BanBnXkFtZTcwMzUyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTA2ODkxOTc5NzZeQTJeQWpwZ15BbWU3MDQ1Mjg1NjM@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMjE5NTk4ODM5NV5BMl5BanBnXkFtZTcwNTUyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTc4MTA5OTU1NF5BMl5BanBnXkFtZTcwNjUyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BNTAzNjQ1NTkwNV5BMl5BanBnXkFtZTcwNzUyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTk0NzMzMDY1OF5BMl5BanBnXkFtZTcwODUyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTk4Njg2NjM5OV5BMl5BanBnXkFtZTcwOTUyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTI4MzEyMjEyM15BMl5BanBnXkFtZTcwMDYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTM3NjQzMzI2MF5BMl5BanBnXkFtZTcwMTYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BNDMzNjk4NDUxNV5BMl5BanBnXkFtZTcwMjYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BNTA3MzU0NjE5MV5BMl5BanBnXkFtZTcwMzYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTI4MDQ3Nzc2Ml5BMl5BanBnXkFtZTcwNDYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMjIxMzE0OTY4Ml5BMl5BanBnXkFtZTcwNTYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMjA1NTUxNzcxNV5BMl5BanBnXkFtZTcwNjYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTMxMzYzMjg0MF5BMl5BanBnXkFtZTcwNzYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTM2MTA4OTA0MV5BMl5BanBnXkFtZTcwODYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMjI3NDk1NTUzNV5BMl5BanBnXkFtZTcwOTYyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMjE1MzA3Njg1MF5BMl5BanBnXkFtZTcwMDcyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BNzYwNjQ5MDkxNF5BMl5BanBnXkFtZTcwMTcyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTg4ODA0NjE1MF5BMl5BanBnXkFtZTcwMjcyODU2Mw@@._V1._SY500.jpg", "http://ia.media-imdb.com/images/M/MV5BMTM1NzQyMTE4OF5BMl5BanBnXkFtZTcwMzcyODU2Mw@@._V1._SY500.jpg" }
            };

            userCallback(mov, null);
        }
Exemplo n.º 17
0
 /// <summary>
 /// <inheritdoc />
 /// </summary>
 public void PersistMovie(ImdbMovie movieToBePersisted)
 {
     this.movieAppDbContext.ImdbMovies.Add(movieToBePersisted);
 }
Exemplo n.º 18
0
        public static DbCommand CreateCommandForCreateMovie(DbConnection dbConnection, DbTransaction dbTransaction, ImdbMovie imdbMovie)
        {
            var dbCommand = dbConnection.CreateCommand();

            dbCommand.CommandText = "dbo.CreateMovie";
            dbCommand.CommandType = CommandType.StoredProcedure;
            dbCommand.Transaction = dbTransaction;
            AddReturnValueParameter(dbCommand);
            AddCommandParameter(dbCommand, "@Title", ParameterDirection.Input, DbType.String, imdbMovie.Title);
            AddCommandParameter(dbCommand, "@Genre", ParameterDirection.Input, DbType.String, imdbMovie.Genre);
            AddCommandParameter(dbCommand, "@Year", ParameterDirection.Input, DbType.Int32, imdbMovie.Year);
            AddCommandParameter(dbCommand, "@ImageUrl", ParameterDirection.Input, DbType.String, imdbMovie.ImageUrl);
            return(dbCommand);
        }
Exemplo n.º 19
0
 public SingleMovieViewModel(ImdbMovie singleMovie)
 {
     SingleMovie = singleMovie;
     SingleMovie.PropertyChanged += (s, e) => { IsDirty = true; };
 }
Exemplo n.º 20
0
        //Get all release dates and aka-s
        private static void GetReleaseDatesAndAka(ImdbMovie mov)
        {
            Dictionary<string, string> release = new Dictionary<string, string>();
            string releasehtml = GetUrlData("http://www.imdb.com/title/" + mov.Id + "/releaseinfo");
            foreach (string r in MatchAll(@"<tr class="".*?"">(.*?)</tr>", match(@"<table id=""release_dates"" class=""subpage_data spFirst"">\n*?(.*?)</table>", releasehtml)))
            {
                Match rd = new Regex(@"<td>(.*?)</td>\n*?.*?<td class=.*?>(.*?)</td>", RegexOptions.Multiline).Match(r);
                release[StripHTML(rd.Groups[1].Value.Trim())] = StripHTML(rd.Groups[2].Value.Trim());
            }
            //mov.ReleaseDates = release;

            Dictionary<string, string> aka = new Dictionary<string, string>();
            ArrayList list = MatchAll(@".*?<tr class="".*?"">(.*?)</tr>", match(@"<table id=""akas"" class=.*?>\n*?(.*?)</table>", releasehtml));
            foreach (string r in list)
            {
                Match rd = new Regex(@"\n*?.*?<td>(.*?)</td>\n*?.*?<td>(.*?)</td>", RegexOptions.Multiline).Match(r);
                aka[StripHTML(rd.Groups[1].Value.Trim())] = StripHTML(rd.Groups[2].Value.Trim());
            }
            mov.Aka = aka;



        }
Exemplo n.º 21
0
 //Get all media images
 private static ArrayList GetMediaImages(ImdbMovie mov)
 {
     ArrayList list = new ArrayList();
     string mediaurl = "http://www.imdb.com/title/" + mov.Id + "/mediaindex";
     string mediahtml = GetUrlData(mediaurl);
     int pagecount = MatchAll(@"<a href=""\?page=(.*?)"">", match(@"<span style=""padding: 0 1em;"">(.*?)</span>", mediahtml)).Count;
     for (int p = 1; p <= pagecount + 1; p++)
     {
         mediahtml = GetUrlData(mediaurl + "?page=" + p);
         foreach (Match m in new Regex(@"src=""(.*?)""", RegexOptions.Multiline).Matches(match(@"<div class=""thumb_list"" style=""font-size: 0px;"">(.*?)</div>", mediahtml)))
         {
             String image = m.Groups[1].Value;
             list.Add(Regex.Replace(image, @"_V1\..*?.jpg", "_V1._SY0.jpg"));
         }
     }
     return list;
 }
Exemplo n.º 22
0
 public void DeleteMovie(ImdbMovie delMovie, Action <OperationStatus, Exception> userCallback)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 23
0
 //Get Recommended Titles
 private static ArrayList GetRecommendedTitles(ImdbMovie mov)
 {
     ArrayList list = new ArrayList();
     string recUrl = "http://www.imdb.com/widget/recommendations/_ajax/get_more_recs?specs=p13nsims%3A" + mov.Id;
     string json = GetUrlData(recUrl);
     list = MatchAll(@"title=\\""(.*?)\\""", json);
     HashSet<String> set = new HashSet<string>();
     foreach (String rec in list) set.Add(rec);
     return new ArrayList(set.ToList());
 }
Exemplo n.º 24
0
 public void InsertMovie(ImdbMovie newMovie, Action <OperationStatus, Exception> userCallback)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 25
0
        protected override async Task RunCommandAsync(ParseImdbMovieCommand command)
        {
            //INJECT HTTP CLIENT
            var basePath = "https://www.imdb.com/title/" + command.FilmId;

            using (var httpClient = new HttpClient())
            {
                var pageAsString = await httpClient.GetStringAsync(basePath);

                var doc = new HtmlDocument();
                doc.LoadHtml(pageAsString);

                var schemaScript = doc.DocumentNode.Descendants("script").
                                   Where(n => n.Attributes.FirstOrDefault(a => a.Value == "application/ld+json") != null)
                                   ?.FirstOrDefault();


                if (schemaScript != null)
                {
                    var movieModel = JsonConvert.DeserializeObject <ImdbMovieDto>(schemaScript.InnerText);

                    var existedMovie = _dbContext.ImdbMovie.FirstOrDefault(p => p.Url == movieModel.Url);

                    if (existedMovie != null)
                    {
                        return;
                    }

                    var actorsDb = new List <Actor>();

                    if (movieModel.Actor != null)
                    {
                        foreach (var actor in movieModel.Actor)
                        {
                            var existedActor = _dbContext.Actor.SingleOrDefault(a => a.Url == actor.Url);
                            if (existedActor == null)
                            {
                                var currentActor = new Actor(actor.Url, actor.Name);
                                _dbContext.Actor.Add(currentActor);
                                actorsDb.Add(currentActor);
                            }
                        }
                        _dbContext.SaveChanges();
                    }


                    var genresDb = new List <Genre>();

                    if (movieModel.Genre != null)
                    {
                        foreach (var genre in movieModel.Genre)
                        {
                            var existedGenre = _dbContext.Genre.FirstOrDefault(a => a.Name == genre);
                            if (existedGenre == null)
                            {
                                var currentGenre = new Genre(genre);
                                _dbContext.Genre.Add(currentGenre);
                                genresDb.Add(currentGenre);
                            }
                        }
                        _dbContext.SaveChanges();
                    }


                    var directoresDb = new List <Director>();

                    if (movieModel.Director != null)
                    {
                        foreach (var director in movieModel.Director)
                        {
                            var existedDirector = _dbContext.Director.
                                                  FirstOrDefault(a => a.Url == director.Url);
                            if (existedDirector == null)
                            {
                                var currentDirector = new Director(director.Url, director.Name);
                                _dbContext.Director.Add(currentDirector);
                                directoresDb.Add(currentDirector);
                            }
                        }
                        _dbContext.SaveChanges();
                    }


                    var creatorsDb = new List <Creator>();
                    if (movieModel.Creator != null)
                    {
                        foreach (var creator in movieModel.Creator)
                        {
                            var existedCreator = _dbContext.Creator.FirstOrDefault(a => a.Url == creator.Url);
                            if (existedCreator == null)
                            {
                                var currentCreator = new Creator(creator.Url);
                                _dbContext.Creator.Add(currentCreator);
                                creatorsDb.Add(currentCreator);
                            }
                        }
                        _dbContext.SaveChanges();
                    }

                    _dbContext.ImdbMovie.Add(ImdbMovie.CreateImdbMovie(movieModel, actorsDb, genresDb,
                                                                       directoresDb, creatorsDb));
                    await _dbContext.SaveChangesAsync();
                }
            }
        }