Ejemplo n.º 1
0
        public PartialViewResult TmdbSearch(string q)
        {
            var epiTmdbId = new EpiTmdbApi();
            var results = epiTmdbId.Search(q);

            return PartialView(results);
        }
Ejemplo n.º 2
0
        private bool UpdateMovieFromTmdb(Movie movie)
        {
            var tmdb = new EpiTmdbApi();
            var result = (movie.TmdbId.HasValue && movie.TmdbId.Value > 0) ?
                tmdb.QueryMovieByTmdbId(movie.TmdbId.Value) :
                tmdb.QueryMovieByImdbId(movie.ImdbId);

            if (result != null)
            {
                movie.ImdbQueried = true;
                movie.Plot = result.Plot;
                movie.Title = result.Title;
                movie.Year = result.Year;
                movie.Score = result.Score;
                movie.ImageUrl = result.Poster;
                movie.Runtime = result.Runtime;
                movie.Homepage = result.Homepage;
                movie.SetGenres(result.Genres);
                movie.TrailerUrl = result.TrailerUrl;
                if (!string.IsNullOrEmpty(result.ImdbId))
                    movie.ImdbId = result.ImdbId;

                movie.Casts.ToList().ForEach(_movieSystemService.DbEntities.DeleteObject);
                foreach (var cast in result.Casts)
                    movie.AddCastMember(cast.Job, cast.Name, cast.ImdbId, cast.TmdbId, cast.SortOrder, cast.RoleName);

                movie.ImdbQueryFailCount = 0;
                movie.TmdbId = result.TmdbId;
                _log.Info("TmdbApi successful query {0}({1}) : {2}", movie.TmdbId, movie.ImdbId, movie.Title);
            }
            else
            {
                _log.Error("TmdbApi FAILED query {0} : {1}", movie.ImdbId, movie.Title);
                movie.ImdbQueryFailCount = movie.ImdbQueryFailCount <= 5 ? 10 : movie.ImdbQueryFailCount + 1;
            }

            return true;
        }