Example #1
0
        private static void FetchImagesExample(TMDbClient client)
        {
            const int movieId = 76338; // Thor: The Dark World (2013)

            // In the call below, we're fetching the wanted movie from TMDb, but we're also doing something else.
            // We're requesting additional data, in this case: Images. This means that the Movie property "Images" will be populated (else it will be null).
            // We could combine these properties, requesting even more information in one go:
            //      client.GetMovieAsync(movieId, MovieMethods.Images);
            //      client.GetMovieAsync(movieId, MovieMethods.Images | MovieMethods.Releases);
            //      client.GetMovieAsync(movieId, MovieMethods.Images | MovieMethods.Trailers | MovieMethods.Translations);
            //
            // .. and so on..
            // 
            // Note: Each method normally corresponds to a property on the resulting object. If you haven't requested the information, the property will most likely be null.

            // Also note, that while we could have used 'client.GetMovieImagesAsync()' - it was better to do it like this because we also wanted the Title of the movie.
            Movie movie = client.GetMovieAsync(movieId, MovieMethods.Images).Result;

            Console.WriteLine("Fetching images for '" + movie.Title + "'");

            // Images come in two forms, each dispayed below
            Console.WriteLine("Displaying Backdrops");
            ProcessImages(client, movie.Images.Backdrops.Take(3), client.Config.Images.BackdropSizes);
            Console.WriteLine();

            Console.WriteLine("Displaying Posters");
            ProcessImages(client, movie.Images.Posters.Take(3), client.Config.Images.PosterSizes);
            Console.WriteLine();

            Spacer();
        }
Example #2
0
        public void ClientRateLimitTest()
        {
            const int id = IdHelper.AGoodDayToDieHard;

            TMDbClient client = new TMDbClient(TestConfig.APIKey);
            client.MaxRetryCount = 0;

            try
            {
                Parallel.For(0, 100, i =>
                {
                    try
                    {
                        client.GetMovieAsync(id).Wait();
                    }
                    catch (AggregateException ex)
                    {
                        // Unpack the InnerException
                        throw ex.InnerException;
                    }
                });
            }
            catch (AggregateException ex)
            {
                // Unpack the InnerException
                throw ex.InnerException;
            }

            Assert.Fail();
        }