private async Task <Movie> LoadInfoForMovie(Movie movie) { // Load movie from OMDB var getInfoTask = OMDbAPI.GetMovieByImdbID(movie.IMDBID); Logger.Info("SEARCH", $"Downloading movie details for {movie.IDTitle} from OMDB"); return(await getInfoTask); }
private async Task <List <Movie> > SearchForMovieRemote(string searchString) { var searchTask = OMDbAPI.SearchForMoviesByTitle(searchString); Logger.Info("SEARCH", $"Searching for {searchString} in OMDB"); List <Movie> movies = await searchTask; if (movies is null) // no movies found { Logger.Warn("HTTP", $"Found 0 matches in OMDB for {searchString}"); return(null); } Logger.Info("SEARCH", $"Found {movies?.Count ?? 0} matches in OMDB for {searchString}"); for (int i = 0; i < movies.Count; i++) { Console.WriteLine($"{i}\t{movies[i].TitleYear}"); } if (!PresentYesNoQuestion("Is your movie in this list?")) { return(null); } Console.WriteLine("============"); Console.WriteLine("Enter the ID of the movie you wish to load full info for."); // Select the specific movie and get the info string input = Console.ReadLine(); if (int.TryParse(input, out int selection) && selection >= 0 && selection < movies.Count) { Movie m = await LoadInfoForMovie(movies[selection]); // Load the Movie from OMDB await movieController.AddCachedMovie(m); // Add Movie to local cache Console.WriteLine($"{m.TitleYear} added to local cache"); List <Movie> output = new List <Movie>(); // Create a new list to return output.Add(m); // add single movie to the list return(output); // return the list with a single movie element } else { Console.WriteLine("Invalid input"); } return(null); }
private void SearchMovie(object send, EventArgs args) { string movieName = nomeFilme.Text; Movie.Rootobject movie = OMDbAPI.BuscaFilme(movieName); cartaz.Source = movie.Poster; sobreFilme.Text = "Title: " + movie.Title; sobreFilme.Text += "\n\nYear: " + movie.Year; sobreFilme.Text += "\n\nGenre: " + movie.Genre; sobreFilme.Text += "\n\nWriter: " + movie.Writer; sobreFilme.Text += "\n\nAwards: " + movie.Awards; sobreFilme.Text += "\n\nPlot: " + movie.Plot; }
public static async void SendMovie(string title, int year) { JObject jObjectMovie = OMDbAPI.GetMovie(title, year); string json = jObjectMovie.ToString(); Movie movie = JsonConvert.DeserializeObject <Movie>(json); if (movie != null && movie.Year != null) { movie.Year = movie.Year.Substring(0, 4); Console.WriteLine(movie.Title + " added"); } //string jsonMovie = JsonConvert.SerializeObject(movie); MovieAPI.Create(movie); }
static async Task TestConnection() { bool success = await OMDbAPI.TestConnection(); if (success) { Console.WriteLine("Connection established"); } else { Console.WriteLine("Connection failure"); } PressAnyKeyToContinue(); }
public async Task GetMovieByImdbIDTest() { Assert.IsNull(await OMDbAPI.GetMovieByImdbID(null)); }
public async Task SearchForMoviesByTitleTest() { List <Movie> result = await OMDbAPI.SearchForMoviesByTitle(null); Assert.IsNull(result); }
public async Task TestConnectionTest() { Assert.IsTrue(await OMDbAPI.TestConnection(), "Testing connection to OMDB failed"); }