Beispiel #1
0
        // This code is to get Movies from THE Movie Database (http://www.themoviedb.org)
        public static MovieModel getSingleFromTMDB(string title)
        {
            // Year
            int year = DateTime.Now.Year;

            MovieModel expectedMovie = new MovieModel();
            TMDbClient client = new TMDbClient("34c356b1eb1a362f5a3b958a9e94a113");
            SearchContainer<SearchMovie> results = client.SearchMovie(title);

            if(results.Results.Count> 0)
            {
                try
                {
                    int id = results.Results[0].Id;
                    Movie movie = client.GetMovie(id);
                    if (movie.OriginalLanguage.Equals("hi")) return null;
                    List<Genre> genres = movie.Genres;
                    var credits = client.GetMovieCredits(id);
                    List<string> credit = getStringFromCrewList(credits);

                    expectedMovie.Title = title;
                    expectedMovie.Year = movie.ReleaseDate.Value.Year.ToString();
                    expectedMovie.Released = movie.ReleaseDate.Value.Date.ToString();
                    expectedMovie.Runtime = movie.Runtime.ToString() + " Minutes";
                    expectedMovie.Genre = getStringFromGenereList(movie.Genres);

                    expectedMovie.Actors = credit[0].ToString();

                    expectedMovie.Director = credit[1].ToString();

                    expectedMovie.Writer = credit[2].ToString();

                    expectedMovie.Plot = movie.Overview;
                    expectedMovie.Language = movie.OriginalLanguage;
                    if(movie.ProductionCountries.Count>0) expectedMovie.Country = movie.ProductionCountries[0].Name;
                    expectedMovie.Poster = Constants.POSTER_LINK_HOST_PATH + movie.PosterPath;
                    expectedMovie.imdbRating = movie.VoteAverage.ToString();
                    expectedMovie.imdbVotes = movie.VoteCount.ToString();
                    expectedMovie.imdbID = movie.ImdbId.ToString();
                    expectedMovie.Showtype = "2D";
                    return expectedMovie;
                }
                catch (Exception e)
                {
                    return null;
                }
            }
            else return null;
        }
Beispiel #2
0
        // This code is to get from my created database
        public static MovieModel getFromCineplexUrl(string title, string movieUrl)
        {
            string htmlPage = "";
            using (var client = new WebClient())
            {
                Uri url = new Uri(movieUrl, UriKind.Absolute);
                htmlPage = client.DownloadString(url);
            }
            MovieModel movie = new MovieModel();

            movie.Title = title;
            movie.Poster = PatternHelper.getPosterUrlFromCineplex(htmlPage);
            movie.Plot = PatternHelper.getPlotFromCineplex(htmlPage);
            movie.Director = PatternHelper.getDirectorFromCineplex(htmlPage);
            movie.Genre = PatternHelper.getGenreFromCineplex(htmlPage);

            return movie;
        }