Exemple #1
0
        public void AddTrailers(Trailers t, MovieModel movie)
        {
            List <Guid> trailers = new List <Guid>();

            foreach (TrailerModel trailer in t.Youtube.Select(Mapper.Map <TrailerModel>))
            {
                trailer.ExternalId = t.Id.ToString();
                trailer.Save(_trailersRootFolder, _masterService);
                if (trailer.Id != Guid.Empty)
                {
                    trailers.Add(trailer.Id);
                }
            }
            if (trailers.Any())
            {
                movie.Trailers = trailers;
            }
        }
Exemple #2
0
        /// <summary>
        /// Get the link to the youtube trailer of a movie
        /// </summary>
        /// <param name="imdbCode">The unique identifier of a movie</param>
        public Tuple<Trailers, Exception> GetMovieTrailer(string imdbCode)
        {
            Exception ex = null;
            Trailers trailers = new Trailers();

            TMDbClient tmDbclient = new TMDbClient(Constants.TmDbClientId);
            tmDbclient.GetConfig();

            try
            {
                TMDbLib.Objects.Movies.Movie movie = tmDbclient.GetMovie(imdbCode);
                if (movie.ImdbId != null)
                {
                    trailers = tmDbclient.GetMovieTrailers(movie.Id);
                }
                else
                {
                    ex = new Exception();
                }
            }
            catch (Exception e)
            {
                ex = e;
            }

            return new Tuple<Trailers, Exception>(trailers, ex);
        }