Пример #1
0
        public List <MovieResult> movieResultsBySearch(string searchTerm)
        {
            if (searchTerm.Count() != 0)
            {
                TmdbMovieSearch results = api.SearchMovie(searchTerm, 1);
                return((api.SearchMovie(searchTerm, 1) as TmdbMovieSearch).results);
            }

            else
            {
                return(new List <MovieResult>());
            }
        }
Пример #2
0
        public override bool GetResults(string keywords, string imdbID, bool skipImages)
        {
            bool result = false;

            api           = new Tmdb(AccessKey, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage);
            configuration = api.GetConfiguration();

            TmdbMovie movie = null;

            if (!string.IsNullOrEmpty(imdbID))
            {
                movie = api.GetMovieByIMDB(imdbID, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage);
                if (movie != null)
                {
                    result = GetResults(new[] { movie });
                }
            }
            if (movie == null)// no imdb identification,use list
            {
                var searchResults = api.SearchMovie(Escape(keywords), 1);
                if (searchResults.results.Any())
                {
                    var list = searchResults.results.Select(item => api.GetMovieInfo(item.id)).ToList();
                    result = GetResults(list);
                }
            }

            return(result);
        }
Пример #3
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            if (tbSearch.Text != "")
            {
                Tmdb api = new Tmdb(App.ApiKey, null);
                api.SearchMovie(tbSearch.Text, 1, null, result =>
                {
                    var baseUrl = "";
                    if (tmdbConfig != null)
                    {
                        baseUrl = string.Format("{0}{1}", tmdbConfig.images.base_url, tmdbConfig.images.poster_sizes[0]);
                    }

                    if (result.Data != null)
                    {
                        listbox.ItemsSource = (from r in result.Data.results
                                               select new Movie
                        {
                            ID = r.id,
                            Title = r.title,
                            ThumbnailUrl = r.poster_path != null ? baseUrl + r.poster_path : null
                        }).ToList();
                    }
                    else
                    {
                        MessageBox.Show(result.Error.status_message, "Error", MessageBoxButton.OK);
                    }
                });
            }
        }
Пример #4
0
        public void SearchMovie()
        {
            var result = api.SearchMovie("Redemption", 1);

            Assert.Greater(result.results.Count, 1);

            foreach (var movie in result.results)
            {
                Console.WriteLine(movie.title + " - " + movie.id + " - " + movie.poster_path + " - " + movie.release_date);
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            Tmdb api = new Tmdb("apikey", null);

            Console.Write("Enter Movie Title: ");
            var search = Console.ReadLine();

            if (string.IsNullOrEmpty(search))
            {
                return;
            }

            Console.WriteLine("Synchronous call...");
            {
                int page = 1;
                while (true)
                {
                    var result = api.SearchMovie(search, page++);
                    if (result != null)
                    {
                        if (page == 1)
                        {
                            Console.WriteLine(string.Format("{0} matches found", result.total_results));
                        }

                        if (result.results.Count == 0)
                        {
                            break;
                        }

                        foreach (var movie in result.results)
                        {
                            Console.WriteLine(string.Format("{0} {1} {2}", movie.id, movie.title, movie.release_date));
                        }
                    }
                    else if (api.Error != null)
                    {
                        Console.WriteLine(string.Format("{0} {1}", api.Error.status_code, api.Error.status_message));
                    }
                }
            }

            Console.WriteLine("Asynchronous call...");
            {
                api.SearchMovie(search, 1, null, result =>
                {
                    if (result.Data != null)
                    {
                        foreach (var movie in result.Data.results)
                        {
                            Console.WriteLine(string.Format("{0} {1} {2}", movie.id, movie.title, movie.release_date));
                        }
                    }
                    else
                    {
                        Console.WriteLine(string.Format("{0} {1}", result.Error.status_code, result.Error.status_message));
                    }
                });
            }

            Console.WriteLine("Press any key...");
            Console.Read();
        }