public List <Trailer> GetTrailers(ImdbResult imdbResult) { List <Trailer> trailers = new List <Trailer>(); foreach (var imdb in imdbResult.TitlePopular) { Trailer trailer = new Trailer(); trailer = FillTrailerData(imdb); trailers.Add(trailer); } return(trailers); }
public ImdbResult GetImdbResult(string keyword) { var imdbAPI = "http://www.imdb.com/"; var url = string.Format("xml/find?json=1&nr=1&tt=on&q={0}", keyword); HttpClient client = new HttpClient(); client.BaseAddress = new Uri(imdbAPI); var imdbResponse = client.GetAsync(url); ImdbResult imdbResult = new ImdbResult(); if (imdbResponse.Result.IsSuccessStatusCode) { string responseContent = imdbResponse.Result.Content.ReadAsStringAsync().Result; imdbResult = JsonConvert.DeserializeObject <ImdbResult>(responseContent); } return(imdbResult); }