public ActionResult IndexPost(MovieLookupViewModel viewModel) {
            if (!_authorizer.Authorize(Permissions.LookupMovie)) {
                return new HttpUnauthorizedResult();
            }

            if ((string.IsNullOrWhiteSpace(viewModel.MovieTitle) && string.IsNullOrWhiteSpace(viewModel.IMDB_Id)) ||
                (!string.IsNullOrWhiteSpace(viewModel.MovieTitle) && !string.IsNullOrWhiteSpace(viewModel.IMDB_Id))) {
                ModelState.AddModelError("MovieTitle", T("You must enter either a Title or an IMDB ID to lookup, but not both.").Text);
                return View("Index", viewModel);
            }

            IEnumerable<TmdbMovie> movies;
            var tmdbApi = new TmdbApi(_orchardServices.WorkContext.CurrentSite.As<MovieSettingsPart>().TMDB_APIKey);

            try {
                if (!string.IsNullOrWhiteSpace(viewModel.MovieTitle)) {
                    movies = tmdbApi.MovieSearch(viewModel.MovieTitle);
                } else {
                    movies = tmdbApi.MovieSearchByImdb(viewModel.IMDB_Id);
                }
                if (movies.Any()) {
                    viewModel.MovieResults = movies.Select(r =>
                        new MovieResult {
                            Id = r.Id, Name = r.Name, Released = r.Released
                        });
                } else {
                    viewModel.NoMatch = true;
                }
            }
            catch (Exception ex) {
                viewModel.NoMatch = true;
            }

            return View("Index", viewModel);
        }
Exemple #2
0
        public EpiTmdbApi()
        {
            var apiKey = ApiKey;
            if (string.IsNullOrEmpty(apiKey) || apiKey.ToLower().Contains("your"))
                throw new TmdbNotConfiguredException();

            _tmdbApi = new TmdbApi(apiKey);
        }
Exemple #3
0
 internal static TheMovieDb.TmdbMovie LookupMovieOnLine(string str)
 {
     TmdbMovie currentMovie = new TheMovieDb.TmdbMovie();
     try
     {
         TmdbApi login = new TheMovieDb.TmdbApi("d49ca7319b09616c927940697304294c");
         TmdbMovie m = login.MovieSearch(str).FirstOrDefault();
         //if(
         currentMovie = login.MovieSearchByImdb(m.ImdbId).FirstOrDefault();
     }
     catch (Exception ex)
     {
         //do nothing
     }
     return currentMovie;
 }
Exemple #4
0
        internal static TheMovieDb.TmdbMovie LookupMovieOnLine(string str)
        {
            TmdbMovie currentMovie = new TheMovieDb.TmdbMovie();

            try
            {
                TmdbApi   login = new TheMovieDb.TmdbApi("d49ca7319b09616c927940697304294c");
                TmdbMovie m     = login.MovieSearch(str).FirstOrDefault();
                //if(
                currentMovie = login.MovieSearchByImdb(m.ImdbId).FirstOrDefault();
            }
            catch (Exception ex)
            {
                //do nothing
            }
            return(currentMovie);
        }
Exemple #5
0
        public static void PopulateGenre()
        {
            MyMoviesEntities dbcontext = new MyMoviesEntities();
            TheMovieDb.TmdbApi login = new TheMovieDb.TmdbApi("d49ca7319b09616c927940697304294c");
            List<TmdbGenre> m = login.GetGenres().ToList();
            foreach (TmdbGenre g in m)
            {

                if (!(dbcontext.Genres.Where(w => w.Name == g.Name).ToList().Count() > 0))
                {
                    Genre currentGenre = new Genre();
                    currentGenre.Name = g.Name;
                    currentGenre.Type = g.Type;
                    dbcontext.Genres.Add(currentGenre);
                    dbcontext.SaveChanges();
                    Console.WriteLine(g.Name);
                }
            }
        }
Exemple #6
0
        public static void PopulateGenre()
        {
            MyMoviesEntities dbcontext = new MyMoviesEntities();

            TheMovieDb.TmdbApi login = new TheMovieDb.TmdbApi("d49ca7319b09616c927940697304294c");
            List <TmdbGenre>   m     = login.GetGenres().ToList();

            foreach (TmdbGenre g in m)
            {
                if (!(dbcontext.Genres.Where(w => w.Name == g.Name).ToList().Count() > 0))
                {
                    Genre currentGenre = new Genre();
                    currentGenre.Name = g.Name;
                    currentGenre.Type = g.Type;
                    dbcontext.Genres.Add(currentGenre);
                    dbcontext.SaveChanges();
                    Console.WriteLine(g.Name);
                }
            }
        }//end method
Exemple #7
0
 public void Tmdb()
 {
     TmdbApi theMovieDb = new TmdbApi(Config.TmdbApiKey);
     IEnumerable<TmdbMovie> movies = theMovieDb.MovieSearch("True Grit");
     Assert.IsNotNull(movies);
     IEnumerable<TmdbMovie> movieSearchByImdb = theMovieDb.MovieSearchByImdb("tt1403865");
     Assert.IsNotNull(movieSearchByImdb);
 }