private void radButtonSearch_Click(object sender, EventArgs e) { radTextBoxTitle.Enabled = false; // using Named capture groups to extract info from search text Regex regTitle = new Regex(@"(?<Title>.+)\((?<Year>\d{4})\)"); var year = String.Empty; var titleWithoutYear = String.Empty; if (regTitle.IsMatch(radTextBoxTitle.Text)) { var match = regTitle.Match(radTextBoxTitle.Text); titleWithoutYear = match.Groups["Title"].Value; year = match.Groups["Year"].Value; } else { titleWithoutYear = radTextBoxTitle.Text; } // title OK if (!String.IsNullOrEmpty(titleWithoutYear)) { List <OmdbSearchResult> omdbSearchResults = new OmdbAPI().SearchMovie(titleWithoutYear.Trim(), year); if (omdbSearchResults == null) { radListViewMovieSearch.DataSource = null; radListViewMovieSearch.Items.Add("There are no records"); radTextBoxTitle.Enabled = true; return; } // set data to control radListViewMovieSearch.DataSource = omdbSearchResults; radListViewMovieSearch.Columns[0].Width = 250; radListViewMovieSearch.Columns[1].Width = 60; radListViewMovieSearch.Columns[2].Width = 60; radListViewMovieSearch.Columns[3].Width = 60; } //ImdbDetails = UtilitySelenium.GetInstance.GetImdbByMovieTitleOrUrl(radTextBoxTitle.Text, null); radTextBoxTitle.Enabled = true; }
public static string GetPosterUrl(string title, int year) { string result = OmdbAPI.NameAPI(title, year); string poster = "N/A"; File.WriteAllText(HttpContext.Current.Server.MapPath("~/MyFiles/Latestresult.xml"), result); XmlDocument doc = new XmlDocument(); doc.LoadXml(result); if (doc.SelectSingleNode("/root/@response").InnerText == "True") { XmlNodeList nodelist = doc.SelectNodes("/root/movie"); foreach (XmlNode node in nodelist) { poster = node.SelectSingleNode("@poster").InnerText; } } return(poster); }
public APIGateway() { finnkinoApi = new FinnkinoAPI(); ratingsAPI = new OmdbAPI(); }