示例#1
0
        public void TestPersonsGetPersonMovieCredits()
        {
            MovieCredits item = Config.Client.GetPersonMovieCreditsAsync(IdHelper.BruceWillis).Result;

            Assert.NotNull(item);
            Assert.NotNull(item.Cast);
            Assert.NotNull(item.Crew);

            Assert.Equal(IdHelper.BruceWillis, item.Id);

            MovieRole cast = item.Cast.SingleOrDefault(s => s.CreditId == "52fe4329c3a36847f803f193");

            Assert.NotNull(cast);
            Assert.Equal(false, cast.Adult);
            Assert.Equal("Lieutenant Muldoon", cast.Character);
            Assert.Equal("52fe4329c3a36847f803f193", cast.CreditId);
            Assert.Equal(1992, cast.Id);
            Assert.Equal("Planet Terror", cast.OriginalTitle);
            Assert.True(TestImagesHelpers.TestImagePath(cast.PosterPath), "cast.PosterPath was not a valid image path, was: " + cast.PosterPath);
            Assert.Equal(new DateTime(2007, 4, 6), cast.ReleaseDate);
            Assert.Equal("Planet Terror", cast.Title);

            MovieJob job = item.Crew.SingleOrDefault(s => s.CreditId == "52fe432ec3a36847f8040603");

            Assert.NotNull(job);
            Assert.Equal(false, job.Adult);
            Assert.Equal("52fe432ec3a36847f8040603", job.CreditId);
            Assert.Equal("Production", job.Department);
            Assert.Equal(2026, job.Id);
            Assert.Equal("Producer", job.Job);
            Assert.Equal(new DateTime(2005, 3, 9), job.ReleaseDate);
            Assert.True(TestImagesHelpers.TestImagePath(job.PosterPath), "job.PosterPath was not a valid image path, was: " + job.PosterPath);
            Assert.Equal("Hostage", job.Title);
            Assert.Equal("Hostage", job.OriginalTitle);
        }
示例#2
0
        public void TestPersonsGetPersonMovieCredits()
        {
            MovieCredits item = _config.Client.GetPersonMovieCredits(BruceWillis);

            Assert.IsNotNull(item);
            Assert.IsNotNull(item.Cast);
            Assert.IsNotNull(item.Crew);

            Assert.AreEqual(BruceWillis, item.Id);

            MovieRole cast = item.Cast.SingleOrDefault(s => s.CreditId == "52fe4329c3a36847f803f193");

            Assert.IsNotNull(cast);
            Assert.AreEqual(false, cast.Adult);
            Assert.AreEqual("Lieutenant Muldoon", cast.Character);
            Assert.AreEqual("52fe4329c3a36847f803f193", cast.CreditId);
            Assert.AreEqual(1992, cast.Id);
            Assert.AreEqual("Planet Terror", cast.OriginalTitle);
            Assert.AreEqual("/7Yjzttt0VfPphSsUg8vFUO9WaEt.jpg", cast.PosterPath);
            Assert.AreEqual(new DateTime(2007, 4, 6), cast.ReleaseDate);
            Assert.AreEqual("Planet Terror", cast.Title);

            MovieJob job = item.Crew.SingleOrDefault(s => s.CreditId == "52fe42fec3a36847f8032887");

            Assert.IsNotNull(job);
            Assert.AreEqual(false, job.Adult);
            Assert.AreEqual("52fe42fec3a36847f8032887", job.CreditId);
            Assert.AreEqual("Production", job.Department);
            Assert.AreEqual(1571, job.Id);
            Assert.AreEqual("Producer", job.Job);
            Assert.AreEqual(new DateTime(2007, 6, 21), job.ReleaseDate);
            Assert.AreEqual("/8czarUCdvqPnulkLX8mdXyrLk2D.jpg", job.PosterPath);
            Assert.AreEqual("Live Free or Die Hard", job.Title);
            Assert.AreEqual("Live Free or Die Hard", job.OriginalTitle);
        }
示例#3
0
        public async Task GetCreditsAsync_ValidId_ReturnsValidResult(string id)
        {
            ITelevisionApi apiUnderTest = new TelevisionApi(_clientWithNoApiKey);

            MovieCredits result = await apiUnderTest.GetCreditsAsync(id, apiKey : _userApiKey);

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result.Cast);
            Assert.IsNotEmpty(result.Crew);
        }
示例#4
0
        public async Task GetEpisodeCreditsAsync_ValidId_ReturnsValidResult(int id, int seasonNumber, int episodeNumber)
        {
            ITelevisionApi apiUnderTest = new TelevisionApi(_clientWithNoApiKey);

            MovieCredits result = await apiUnderTest.GetEpisodeCreditsAsync(id, seasonNumber, episodeNumber, apiKey : _userApiKey);

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result.Cast);
            Assert.IsNotEmpty(result.Crew);
        }
示例#5
0
 public List <MovieRole> GetMovieCredits(int personId, int page)
 {
     if (page == 1)
     {
         movieCredits      = CacheRepo.Credits.GetOrCreate(personId.ToString(), () => tClient.GetPersonMovieCreditsAsync(personId).Result);
         movieCredits.Cast = movieCredits.Cast.Where(z => z.ReleaseDate.HasValue).OrderByDescending(x => x.ReleaseDate).ToList();
         personMoviesTotal = movieCredits.Cast.Count;
     }
     if (page > personMoviesTotal / 15 + 1)
     {
         return(null);
     }
     return(movieCredits.Cast.Skip((page - 1) * 15).Take(15).ToList());
 }
示例#6
0
        public IActionResult GetPersonDetails(int movieId)
        {
            MovieCredits movieCredits = _creditService.GetCreditsByMovieId(movieId);

            List <PersonDetails> personDetailsLsit = new List <PersonDetails>();

            foreach (var cast in movieCredits.cast)
            {
                PersonDetails personDetails = _personService.GetPersonDetailsByPersonId(cast.id);
                personDetailsLsit.Add(personDetails);
            }

            return(Ok(personDetailsLsit));
        }
示例#7
0
        public async Task TestGetPersonMovieCreditsAsync()
        {
            MovieCredits item = await TMDbClient.GetPersonMovieCreditsAsync(IdHelper.BruceWillis);

            Assert.NotNull(item);
            Assert.NotEmpty(item.Cast);
            Assert.NotEmpty(item.Crew);

            MovieRole cast = item.Cast.Single(s => s.CreditId == "52fe4329c3a36847f803f193");
            MovieJob  crew = item.Crew.Single(s => s.CreditId == "52fe432ec3a36847f8040603");

            await Verify(new
            {
                cast,
                crew
            });
        }
示例#8
0
        public async Task <MovieCredits> GetCredits(int iMovie)
        {
            MovieCredits oMovieCredits = new MovieCredits();

            try
            {
                wsConexion ws = new wsConexion();
                //Settings.sError = "";

                string sResponse = await ws.GetDataRestAsyncCredits(iMovie);

                oMovieCredits = JsonConvert.DeserializeObject <MovieCredits>(sResponse);
            }
            catch (Exception e)
            {
                //oMovieBase.sError = e.Message;
            }
            return(oMovieCredits);
        }
示例#9
0
        public void TestPersonsGetPersonCredits()
        {
            //GetPersonCredits(int id, string language)
            MovieCredits resp = Config.Client.GetPersonMovieCreditsAsync(IdHelper.BruceWillis).Result;

            Assert.NotNull(resp);

            MovieCredits respItalian = Config.Client.GetPersonMovieCreditsAsync(IdHelper.BruceWillis, "it").Result;

            Assert.NotNull(respItalian);

            Assert.Equal(resp.Cast.Count, respItalian.Cast.Count);
            Assert.Equal(resp.Crew.Count, respItalian.Crew.Count);
            Assert.Equal(resp.Id, respItalian.Id);

            // There must be at least one movie with a different title
            bool allTitlesIdentical = true;

            for (int index = 0; index < resp.Cast.Count; index++)
            {
                Assert.Equal(resp.Cast[index].Id, respItalian.Cast[index].Id);
                Assert.Equal(resp.Cast[index].OriginalTitle, respItalian.Cast[index].OriginalTitle);

                if (resp.Cast[index].Title != respItalian.Cast[index].Title)
                {
                    allTitlesIdentical = false;
                }
            }

            for (int index = 0; index < resp.Crew.Count; index++)
            {
                Assert.Equal(resp.Crew[index].Id, respItalian.Crew[index].Id);
                Assert.Equal(resp.Crew[index].OriginalTitle, respItalian.Crew[index].OriginalTitle);

                if (resp.Crew[index].Title != respItalian.Crew[index].Title)
                {
                    allTitlesIdentical = false;
                }
            }

            Assert.False(allTitlesIdentical);
        }
示例#10
0
 public bool Create(MovieCredits credit)
 {
     _credits.InsertOne(credit);
     return(true);
 }
示例#11
0
        public async Task GetCredits(int iMovie)
        {
            oMovieCredits = new MovieCredits();

            oMovieCredits = await cpFeeds.GetCredits(iMovie);
        }
示例#12
0
        public IActionResult MovieResult(string imdbId)
        {
            WebRequest      request;
            HttpWebResponse response;
            string          result = null;

            string api           = "api_key=8d8ebd7ef7cb1361e624639ac8fea328";
            string finalResponse = "";
            string getImdbIdUrl  = String.Format("https://api.themoviedb.org/3/find/" + imdbId + "?" + api + "&external_source=imdb_id");

            request        = WebRequest.Create(getImdbIdUrl);
            request.Method = "GET";
            response       = (HttpWebResponse)request.GetResponse();
            using (Stream streamImdb = response.GetResponseStream())
            {
                StreamReader streamReaderImdb = new StreamReader(streamImdb);
                result = streamReaderImdb.ReadToEnd();
                streamReaderImdb.Close();
            }

            ImdbMovieResult imdbMovieResult = JsonConvert.DeserializeObject <ImdbMovieResult>(result);
            int             tmdbId          = imdbMovieResult.movie_results.FirstOrDefault().id;

            bool isThereAnyMovie = _movieService.IsItExistsByTmdbId(tmdbId);

            if (isThereAnyMovie)
            {
                finalResponse += "This movie already exists in the Database!";
            }
            else
            {
                string getTmdbIdUrl = String.Format("https://api.themoviedb.org/3/movie/" + tmdbId + "?" + api + "&language=en-US");

                request  = WebRequest.Create(getTmdbIdUrl);
                response = (HttpWebResponse)request.GetResponse();
                using (Stream streamTmdb = response.GetResponseStream())
                {
                    StreamReader streamReaderTmdb = new StreamReader(streamTmdb);
                    result = streamReaderTmdb.ReadToEnd();
                    streamReaderTmdb.Close();
                }

                TmdbMovieResult tmdbMovieResult = JsonConvert.DeserializeObject <TmdbMovieResult>(result);

                bool isMovieCreated = _movieService.Create(tmdbMovieResult);

                if (isMovieCreated)
                {
                    finalResponse += "Movie were inserted into the Database!";
                }
                else
                {
                    finalResponse += "Some error!";
                }
            }

            bool isThereAnyCredits = _creditService.IsItExistsByTmdbId(tmdbId);

            if (isThereAnyCredits)
            {
                finalResponse += "\nThese credits already exists in the Database!";
            }
            else
            {
                string getCreditsIdUrl = String.Format("https://api.themoviedb.org/3/movie/" + tmdbId + "/credits?" + api);

                request  = WebRequest.Create(getCreditsIdUrl);
                response = (HttpWebResponse)request.GetResponse();
                using (Stream streamCredits = response.GetResponseStream())
                {
                    StreamReader streamReaderCredits = new StreamReader(streamCredits);
                    result = streamReaderCredits.ReadToEnd();
                    streamReaderCredits.Close();
                }

                MovieCredits movieCredits = JsonConvert.DeserializeObject <MovieCredits>(result);

                bool isCreditsCreated = _creditService.Create(movieCredits);

                if (isCreditsCreated)
                {
                    finalResponse += "Credites were inserted into the Database!";
                }
                else
                {
                    finalResponse += "Some error!";
                }

                //int counter = 0;

                //foreach (var cast in movieCredits.cast)
                //{
                //    bool isThereAnyPersonImegas = _personImagesService.IsItExistsByPersonId(cast.id);
                //    if (isThereAnyPersonImegas)
                //        continue;
                //    else
                //        counter++;

                //    string getPersonImageIdUrl = String.Format("https://api.themoviedb.org/3/person/" + cast.id + "/images?" + api);

                //    request = WebRequest.Create(getPersonImageIdUrl);
                //    response = (HttpWebResponse)request.GetResponse();
                //    using (Stream streamPersonImages = response.GetResponseStream())
                //    {
                //        StreamReader streamReaderPersonImages = new StreamReader(streamPersonImages);
                //        result = streamReaderPersonImages.ReadToEnd();
                //        streamReaderPersonImages.Close();
                //    }

                //    PersonImages personImages = JsonConvert.DeserializeObject<PersonImages>(result);
                //    var orderedPersonImages = personImages.profiles.OrderByDescending(x => x.vote_average).ToList();
                //    personImages.profiles = orderedPersonImages;
                //    personImages.id = cast.id;

                //    bool isPersonImagesCreated = _personImagesService.Create(personImages);
                //}

                int personDetailsCounter = 0;

                foreach (var cast in movieCredits.cast)
                {
                    bool isThereAnyPersonDetails = _personService.IsItExistsByPersonId(cast.id);
                    if (isThereAnyPersonDetails)
                    {
                        continue;
                    }
                    else
                    {
                        personDetailsCounter++;
                    }

                    string getPersonDetailsIdUrl = String.Format("https://api.themoviedb.org/3/person/" + cast.id + "?" + api + "&language=en-US");

                    request  = WebRequest.Create(getPersonDetailsIdUrl);
                    response = (HttpWebResponse)request.GetResponse();
                    using (Stream streamPersonDetails = response.GetResponseStream())
                    {
                        StreamReader streamReaderPersonDetails = new StreamReader(streamPersonDetails);
                        result = streamReaderPersonDetails.ReadToEnd();
                        streamReaderPersonDetails.Close();
                    }

                    PersonDetails personDetails = JsonConvert.DeserializeObject <PersonDetails>(result);

                    bool isPersonImagesCreated = _personService.Create(personDetails);
                }

                finalResponse += "\n" + personDetailsCounter + " actor profiles were inserted into the Database!";
            }


            return(Ok(JsonConvert.SerializeObject(finalResponse)));
        }