private void GetMoviebyTitleAndYear(string Title, string Year) { var caller = new RestSharpCaller("http://www.omdbapi.com/?apikey=5d4834e7&"); var movies = caller.GetMoviesByTitleYear(Title, Year); detailedView = new DetailedView(); if (movies.Response == "True") { passMovieDetails(movies.Search[0].imdbID); detailedView.Show(); } else { MessageBox.Show("Movie not found"); } }
private void buttonDownloadPoster_Click(object sender, EventArgs e) { string title; string year; var regex = "([\\w\\s]+) \\((\\w+)[\\)]$"; var match = Regex.Match(listBoxWatchedMovies.SelectedItem.ToString(), regex, RegexOptions.IgnoreCase); if (match.Success) { title = match.Groups[1].Value; year = match.Groups[2].Value; var caller = new RestSharpCaller("http://www.omdbapi.com/?apikey=5d4834e7&"); var movies = caller.GetMoviesByTitleYear(title, year); if (movies.Response == "True") { string ImageURL = movies.Search[0].Poster; try { SaveImage(movies.Search[0].Title + "_" + movies.Search[0].Year, listBoxWatchedMovies.SelectedItem.ToString(), ImageURL); MessageBox.Show("Poster saved!"); } catch (Exception error) { Console.WriteLine("{0} Exception caught.", error); MessageBox.Show("Error with downloading photo!"); } } else { MessageBox.Show("Movie not found"); } } else { MessageBox.Show("Some problem occurs!"); } }