Example #1
0
        static async Task RunAsync(int page_num, string apiKey)
        {
            try
            {
                var         resPageString = String.Format("discover/movie?api_key={0}&page={1}", apiKey, page_num);
                ResultsPage page          = await GetMovieResultsPageAsync(resPageString);

                //ShowResultsPage(page);

                //Console.WriteLine($"Num Pages: {page.total_pages}, Page Number: {page.page}");

                //Movie movie = await GetMovieAsync("movie/337167?api_key=493443bebf07f4d8e08d527ca2c84d2a&language=en-US%27");

                /*Parallel.ForEach(page.results, res =>
                 *  {
                 *      RetrieveWriteMovie(res).GetAwaiter().GetResult();
                 *  });
                 */
                foreach (var res in page.results)
                {
                    RetrieveWriteMovie(res, apiKey).GetAwaiter().GetResult();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Results page failure: {page_num}");
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
Example #2
0
        static async Task <ResultsPage> GetMovieResultsPageAsync(string path)
        {
            ResultsPage         resultsPage;
            HttpResponseMessage response = await client.GetAsync(path);

            if (response.IsSuccessStatusCode)
            {
                resultsPage = await response.Content.ReadAsAsync <ResultsPage>();
            }
            else
            {
                resultsPage = new ResultsPage();
            }
            return(resultsPage);
        }