Exemplo n.º 1
0
        //
        // Internet Search of IMDB screens (scraping)
        //
        private void SearchRecord()
        {
            if (string.IsNullOrEmpty(SearchText))
            {
                return;
            }

            using (new AssistRoutines.WaitCursor())
            {
                IMDBSearch srch = new IMDBSearch();
                srch.Keyword = SearchText;
                List <IMDBResult> rslt = srch.getSearchResult();
                //
                // Load the result into MovieList
                //
                if (rslt.Count <= 0)
                {
                    MessageBox.Show("No movies found in IMDB matching that search.");
                }
                else
                {
                    ReLoadMovieList(rslt);
                }
            }
            //
            // Clear the search phrase
            //
            SearchText = String.Empty;
        }
        private void ThreadSearchImages()
        {
            try
            {
                if (currentMovie == null)
                {
                    return;
                }
                // Search for more covers
                string[]  thumbUrls = new string[1];
                IMDBMovie movie     = currentMovie;
                // TMDB Search  Deda 30.4.2010
                TMDBCoverSearch tmdbSearch = new TMDBCoverSearch();
                tmdbSearch.SearchCovers(movie.Title, movie.IMDBNumber);
                // IMPAward search
                IMPAwardsSearch impSearch = new IMPAwardsSearch();
                impSearch.SearchCovers(movie.Title, movie.IMDBNumber);

                int thumb = 0;

                if (movie.ThumbURL != string.Empty)
                {
                    thumbUrls[0] = movie.ThumbURL;
                    thumb        = 1;
                }
                int pictureCount = impSearch.Count + tmdbSearch.Count + thumb;
                //Hugh, no covers, lets pull our last card
                if ((tmdbSearch.Count == 0) & (impSearch.Count == 0))
                {
                    // IMDB
                    // Last defence in search for covers - will be counted if previous methods fails
                    IMDBSearch imdbSearch = new IMDBSearch();
                    imdbSearch.SearchCovers(movie.IMDBNumber, false);
                    // Nothing found, we loose -> exit
                    if (imdbSearch.Count == 0)
                    {
                        return;
                    }
                    // Last defence survived, so lets grab what we can from IMDB and get out of here
                    pictureCount = imdbSearch.Count + thumb;

                    int pictureIndeximdb = 0;
                    thumbUrls = new string[pictureCount];

                    if ((imdbSearch.Count > 0) && (imdbSearch[0] != string.Empty))
                    {
                        for (int i = 0; i < imdbSearch.Count; ++i)
                        {
                            if (thumbUrls[0] != imdbSearch[i])
                            {
                                thumbUrls[pictureIndeximdb++] = imdbSearch[i];
                            }
                        }
                    }
                    if (AmazonImagesDownloaded != null)
                    {
                        AmazonImagesDownloaded(thumbUrls);
                    }
                    return;
                }

                int pictureIndex = 0;
                thumbUrls = new string[pictureCount];

                if (movie.ThumbURL != string.Empty)
                {
                    thumbUrls[pictureIndex++] = movie.ThumbURL;
                }
                // IMP Award check and add
                if ((impSearch.Count > 0) && (impSearch[0] != string.Empty))
                {
                    for (int i = 0; i < impSearch.Count; ++i)
                    {
                        thumbUrls[pictureIndex++] = impSearch[i];
                    }
                }

                // TMDB Count check and add into thumbs Deda 30.4.2010
                if ((tmdbSearch.Count > 0) && (tmdbSearch[0] != string.Empty))
                {
                    for (int i = 0; i < tmdbSearch.Count; ++i)
                    {
                        thumbUrls[pictureIndex++] = tmdbSearch[i];
                    }
                }

                if (AmazonImagesDownloaded != null)
                {
                    AmazonImagesDownloaded(thumbUrls);
                }
            }
            catch (ThreadAbortException) { }
        }