private static MovieIdentifier CreateMovieId(int year, XmlNode titleLink) { var title = titleLink.InnerText; var movieId = new MovieIdentifier { Year = year, Title = title }; return(movieId); }
private static List <MovieIdentifier> ExtractMovieIds(int year, XmlNode topGrossingTable) { var movieIds = new List <MovieIdentifier>(); foreach (XmlNode n in topGrossingTable.ChildNodes) { var titleLink = n.SelectSingleNode(".//a"); if (titleLink != null && titleLink.ParentNode.Name != "sup") // not a superscript link { MovieIdentifier movieId = CreateMovieId(year, titleLink); movieIds.Add(movieId); } } return(movieIds); }
private static async Task <string> CreateRequestUri(MovieIdentifier m) { var values = new Dictionary <string, string> { { "t", m.Title }, { "y", m.Year.ToString() }, { "plot", "short" }, { "r", "json" }, { "type", "movie" } }; string query; using (var content = new FormUrlEncodedContent(values)) { query = await content.ReadAsStringAsync(); } var requestUri = "?" + query; return(requestUri); }
private static async Task <ContestantRequest> GetContestantFromOmdbApi(MovieIdentifier m) { try { using (var client = CreateClient()) { var requestUri = await CreateRequestUri(m); var response = await client.GetAsync(requestUri); response.EnsureSuccessStatusCode(); var movieContestant = await CreateContestant(response); return(movieContestant); } } catch (Exception ex) { throw new Exception($"Failed to get contestant info for movie {m.Title} ({m.Year}).", ex); } }