public void GetWriters(ref IMDbMovie movie, string html)
        {


            if (!Settings.GetIMDbMovieWriters)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Writers...");

            // Grab Writers
            string writerHTML = _imDbRegex.GetRegExString(html, _imDbRegex._writerPattern);

            if (!String.IsNullOrEmpty(writerHTML.Trim()))
            {
                Match match = _imDbRegex.GetRegExMatch(writerHTML, _imDbRegex._personPattern);
                while (match != null && match.Length > 0)
                {
                    string personID = _imDbRegex.GetMatchValue(match, "PersonURL", true);

                    if (String.IsNullOrEmpty(personID.Trim()))
                        continue;
                    
                    IIMDbPerson writer = movie.People.GetPersonByID(personID);
                    
                    if (writer == null)
                    {
                        writer = new IMDbPerson();
                        movie.People.Add(writer);
                    }
                    
                    writer.URL = personID;
                    writer.Name = _imDbRegex.GetMatchValue(match, "PersonName", true);
                    writer.IsWriter = true;

                    match = match.NextMatch();
                }

            }

            string writers = movie.People.GetWriterString();

            Debugger.LogMessageToFile("[IMDb film details downloader]  IMDb returned Writers: " + writers);
            //MessageBox.Show(@"IMDb returned Writers: " + writers);

        }
        internal static void GetOverview(IMDbMovie movie, string trimmedHTML)
        {


            if (!Settings.GetIMDbMovieShortOverview)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Short Overview...");
            

            Match match = IMDbMovieDetailsDownloader._IMDbRegex.GetRegExMatch(trimmedHTML, IMDbMovieDetailsDownloader._IMDbRegex._shortOverviewPattern);

            movie.OverviewShort =
                IMDbMovieDetailsDownloader._IMDbRegex.GetMatchValue
                (match, "ShortOverview", true);
            
            if (movie.OverviewShort.ToLower().EndsWith("more"))
                movie.OverviewShort =
                    movie.OverviewShort.Substring
                    (0, movie.OverviewShort.Length - 4).Trim();
            
            movie.OverviewShort = movie.OverviewShort.Trim() + "...";

            Debugger.LogMessageToFile("IMDb returned Overview: " + movie.OverviewShort);


        }
        internal static void GetReview
            (IMDbMovie movie,
            string trimmedHTML,
            IMDbRegEx imDbRegEx)
        {


            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieReviews)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Review score...");
          
            Match match = imDbRegEx.GetRegExMatch(trimmedHTML, imDbRegEx.ReviewPattern);
           
            movie.Review = imDbRegEx.GetMatchValue(match, "Review", true);
           
            if (movie.Review.Contains("/"))
                movie.Review = movie.Review.Substring(0, movie.Review.IndexOf("/", System.StringComparison.Ordinal));
          
            Debugger.LogMessageToFile("IMDb returned Review: " + movie.Review);

        }
        internal static void MineOverviewUsingRegex
            (IMDbMovie movie,
            string trimmedHTML,
            IMDbRegEx imDbRegEx )
        {


            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieShortOverview)
                return;

            Debugger.LogMessageToFile
                ("[IMDb film details downloader]" +
                 " Extracting Short Overview...");
            

            Match match = imDbRegEx.GetRegExMatch
                (trimmedHTML, imDbRegEx.FilmDescriptionPattern);


            movie.OverviewShort =
                imDbRegEx.GetMatchValue
                (match, "ShortOverview", true);
            
            if (movie.OverviewShort.ToLower().EndsWith("more"))
                movie.OverviewShort =
                    movie.OverviewShort.Substring
                    (0, movie.OverviewShort.Length - 4).Trim();
            
            movie.OverviewShort = movie.OverviewShort.Trim() + "...";

            Debugger.LogMessageToFile("IMDb returned Overview: " + movie.OverviewShort);


        }
        public void GetQuotes(ref IMDbMovie movie, string quotesUrl)
        {

            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieQuotes)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Quotes...");

            // get quotes html
            string html = HtmlDownloaders.DownloadHTMLfromURL(quotesUrl);

            // Grab quotes
            Match match1 = _imDbRegex.GetRegExMatch(html, _imDbRegex.QuoteBlockPattern);
            while (match1 != null && match1.Length > 0)
            {

                string quoteBlockHtml = _imDbRegex.GetMatchValue(match1, "QuoteBlock", false);


                if (!String.IsNullOrEmpty(quoteBlockHtml.Trim()))
                {

                    var quoteBlock = new List<IIMDbQuote>();

                    Match match2 = _imDbRegex.GetRegExMatch(quoteBlockHtml, _imDbRegex.QuotePattern);

                    while (match2 != null && match2.Length > 0)
                    {

                        IMDbQuote quote = new IMDbQuote
                                              {
                                                  Character = _imDbRegex.GetMatchValue(match2, "Character", true),
                                                  Text = _imDbRegex.GetMatchValue(match2, "Quote", true)
                                              };

                        quoteBlock.Add(quote);
                        match2 = match2.NextMatch();
                    }

                    if (quoteBlock.Count > 0)
                        movie.Quotes.Add(quoteBlock);
                }
                match1 = match1.NextMatch();
            }

            string quotes = movie.GetQuotesString();
            //Debugger.LogMessageToFile("[IMDb film details downloader]  IMDb returned Quotes: " + quotes);
            //MessageBox.Show("IMDb returned Quotes: " + quotes);

        }
        public void GetGoofs(ref IMDbMovie movie, string goofUrl)
        {


            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieGoofs)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Goofs...");

            // get goof html
            string html = HtmlDownloaders.DownloadHTMLfromURL(goofUrl);

            // Grab goofs
            Match match = _imDbRegex.GetRegExMatch(html, _imDbRegex.GoofPattern);
            while (match != null && match.Length > 0)
            {
                IMDbGoof goof = new IMDbGoof();
                goof.Category = _imDbRegex.GetMatchValue(match, "Category", true);
                goof.Description = _imDbRegex.GetMatchValue(match, "Goof", true);
                movie.Goofs.Add(goof);
                match = match.NextMatch();
            }

            string goofs = movie.GetGoofsString();

            //Debugger.LogMessageToFile("[IMDb film details downloader]  IMDb returned Goofs: " + goofs);
            //MessageBox.Show("IMDb returned Goofs: " + goofs);

        }
        public void GetGenres(ref IMDbMovie movie, string html)
        {


            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieGenres)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Genres...");

            // Grab Genres
            Match match = _imDbRegex.GetRegExMatch(html, _imDbRegex.GenrePattern);
            if (match != null && match.Length > 0)
            {
                match = _imDbRegex.GetRegExMatch(match.Value, _imDbRegex.Genre2Pattern);
                while (match != null && match.Length > 0)
                {
                    string genre = _imDbRegex.GetMatchValue(match, "Genre", true);

                    if (!String.IsNullOrEmpty(genre.Trim()))
                        movie.Genres.Add(genre);
                    
                    match = match.NextMatch();
                
                }
            }

            string genres = movie.GetGenresString();

            Debugger.LogMessageToFile("[IMDb film details downloader]  IMDb returned Genres: " + genres);

            //MessageBox.Show(@"IMDb returned Genres: " + genres);

        }
        public void GetActorsUsingRegex(ref IMDbMovie movie, string creditsUrl)
        {


            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieActors)
                return;

            // get cast html
            string html = HtmlDownloaders.DownloadHTMLfromURL(creditsUrl);

            // Grab Actors
            string trimmedHtml = _imDbRegex.GetRegExString(html, _imDbRegex.CastPattern);
            
            if (String.IsNullOrEmpty(trimmedHtml.Trim()))
                return;
            
            Match match1 = _imDbRegex.GetRegExMatch(trimmedHtml, _imDbRegex.CastPersonPatternWithCharacterUrLs);
            
            while (match1 != null && match1.Length > 0)
            {

                string personID = _imDbRegex.GetMatchValue(match1, "PersonURL", true);


                if (String.IsNullOrEmpty(personID.Trim())) 
                    continue;
                
                IIMDbPerson actor = movie.People.GetPersonByID(personID);
                
                if (actor == null)
                {
                    actor = new IMDbPerson();
                    movie.People.Add(actor);
                }
                
                
                actor.URL = personID;
                actor.Name = _imDbRegex.GetMatchValue(match1, "PersonName", true);
                actor.IsActor = true;
               
                string characterString = _imDbRegex.GetMatchValue(match1, "CharacterName", true);
                
                ParseCharacters(ref actor, characterString);

                match1 = match1.NextMatch();
            
            }

            Match match2 = _imDbRegex.GetRegExMatch
                (trimmedHtml, _imDbRegex.CastPersonPatternWithNoCharacterUrLs);
            
            while (match2 != null && match2.Length > 0)
            {

                string personID = _imDbRegex.GetMatchValue(match2, "PersonURL", true);

                if (String.IsNullOrEmpty(personID.Trim()))
                    continue;

                IIMDbPerson actor = movie.People.GetPersonByID(personID);

                if (actor == null)
                {
                    actor = new IMDbPerson();
                    movie.People.Add(actor);
                }
                
                actor.URL = personID;
                actor.Name = _imDbRegex.GetMatchValue(match2, "PersonName", true);
                actor.IsActor = true;
                
                string characterString =
                    _imDbRegex.GetMatchValue
                    (match2, "CharacterName", true);
                
                ParseCharacters
                    (ref actor, characterString);

                match2 = match2.NextMatch();

            }


        }
        private void GetWriters(ref IMDbMovie movie, string html)
        {
            // Grab Writers
            string writerHTML = GetRegExString(html, _writerPattern);
            if (writerHTML.Trim() != "")
            {
                Match match = GetRegExMatch(writerHTML, _personPattern);
                while (match != null && match.Length > 0)
                {
                    string personID = GetMatchValue(match, "PersonURL", true);
                    if (personID.Trim() != "")
                    {
                        IIMDbPerson writer = movie.People.GetPersonByID(personID);
                        if (writer == null)
                        {
                            writer = new IMDbPerson();
                            movie.People.Add(writer);
                        }
                        writer.URL = personID;
                        writer.Name = GetMatchValue(match, "PersonName", true);
                        writer.IsWriter = true;

                        match = match.NextMatch();
                    }
                }
            }
        }
        private void GetDirectors(ref IMDbMovie movie, string html)
        {
            // Grab Directors
            string directorHTML = GetRegExString(html, _directorPattern);
            if (directorHTML.Trim() != "")
            {
                Match match = GetRegExMatch(directorHTML, _personPattern);
                while (match != null && match.Length > 0)
                {
                    string personID = GetMatchValue(match, "PersonURL", true);
                    if (personID.Trim() != "")
                    {
                        IIMDbPerson director = movie.People.GetPersonByID(personID);
                        if (director == null)
                        {
                            director = new IMDbPerson();
                            movie.People.Add(director);
                        }
                        director.URL = personID;
                        director.Name = GetMatchValue(match, "PersonName", true);
                        director.IsDirector = true;

                        match = match.NextMatch();
                    }
                }
            }
        }
        public IIMDbMovie GetMovieInfoFromIMDb(string imdbID, bool ShowProgress )
        {
            IMDbMovie movie = new IMDbMovie();


            try
            {

                #region local variables
                Debugger.LogMessageToFile("[IMDb film details downloader] Entered GetMovieInfoFromIMDb()");
                Debugger.LogMessageToFile("[IMDb film details downloader] IMDb base url: " + _url);

                string movieURL = _url + imdbID + "/";
                Debugger.LogMessageToFile("[IMDb film details downloader] movie URL: " + movieURL);

                string html = String.Empty;

                Debugger.LogMessageToFile("[IMDb film details downloader] Downloading film's main html page...");
                try
                {
                    html = JCUtils.WebUtils.GET(movieURL);
                }
                catch
                {
                    Debugger.LogMessageToFile("[IMDb film details downloader] IMDb did not respond. Retrying...");
                    Helpers.UpdateProgress("Updating Movies Section...", "IMDb did not respond. Retrying...", null);
                    try
                    {
                        html = JCUtils.WebUtils.GET(movieURL);
                    }
                    catch
                    {
                        Debugger.LogMessageToFile("A connection error occured while attempting to download IMDb's film web page. Giving up for this item.");
                        Helpers.UpdateProgress("Updating Movies Section...", "Unable to connect to IMDb. Details for this film will not be downloaded.", null);
                        StatusForm.statusForm.TrayIcon.ShowBalloonTip(5000, "Communication with IMDb failed", "MediaFairy was unable to connect to IMDb in order to download details for a film. Please check your internet connection availability, otherwise the online database may be temporarily offline or unreachable.", ToolTipIcon.Warning);
                        return null;
                    }
                }

                //MessageBox.Show("Step 4");

                if (String.IsNullOrEmpty(html))
                {
                    Debugger.LogMessageToFile("[IMDb film details downloader] Unable to get film data from IMDb. The returned film HTML page was empty.");
                    return null;
                }

                Debugger.LogMessageToFile("[IMDb film details downloader] The returned IMDb film html page contains vaid data.");
                //MessageBox.Show("Step 5");

                string trimmedHTML;

                string creditsURL = movieURL + "fullcredits";
                string longOverviewURL = movieURL + "plotsummary";
                string goofURL = movieURL + "goofs";
                string triviaURL = movieURL + "trivia";
                string quotesURL = movieURL + "quotes";
                #endregion


                #region Clean film's html page
                Debugger.LogMessageToFile("Cleaning IMDb result html ");
                trimmedHTML = GetRegExString(html, _trimmedHTMLpattern);
                //Debugger.LogMessageToFile("Trimmed HTML: " + trimmedHTML);
                //MessageBox.Show("Trimmed HTML: " + trimmedHTML);
                //MessageBox.Show("titlePattern: " + _titlePattern);
                #endregion


                #region Get Title
                Debugger.LogMessageToFile("[IMDb film details downloader] Extracting title...");
                Match match = GetRegExMatch(trimmedHTML, _titlePattern);
                //Match match = GetRegExMatch(html, _titlePattern);

                if (match == null)
                {
                    Debugger.LogMessageToFile("Warning! IMDb title matching was unsuccesful. Did IMDb website changed layout?");
                    return null;
                }
                else
                {
                    Debugger.LogMessageToFile("[IMDb film details downloader] The film's title was succesfully located in the IMDb result html.");
                }


                movie.IMDb_ID = imdbID;
                movie.Title = GetMatchValue(match, "Title", true);

                if (String.IsNullOrEmpty(movie.Title))
                {
                    StatusForm.statusForm.TrayIcon.ShowBalloonTip(10000, "Unable to extract film details from IMDb", "MediaFairy's IMDb film details downloader was unable to extract a film's Title from the IMDb database. If the IMDb website changed, please report this issue to the plugin's developer in order for this engine to be updated. Film details downloading for this item will be skipped.", ToolTipIcon.Warning);
                    return movie;
                }

                Debugger.LogMessageToFile("[IMDb film details downloader] IMDb returned title: " + movie.Title);
                MessageBox.Show("IMDb returned title: " + movie.Title);
                #endregion

                
                #region Grab Details
                if (ShowProgress)
                    Importer.thisProgress.Progress(Importer.CurrentProgress, "Downloading details from IMDb for '" + movie.Title + "'...");

                #region Get details from main IMDb page

                #region Extract Year
                Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Year...");
                match = GetRegExMatch(trimmedHTML, _yearPattern);
                //match = GetRegExMatch(html, _yearPattern);
                movie.Year = GetMatchValue(match, "Year", true);
                movie.Year = movie.Year.TrimEnd('/');
                Debugger.LogMessageToFile("[IMDb film details downloader] IMDb returned Year: " + movie.Year);
                MessageBox.Show("IMDb returned Year: " + movie.Year);
                #endregion

                #region Extract Release Date
                Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Release Date...");
                match = GetRegExMatch(trimmedHTML, _releaseDatePattern);
                //match = GetRegExMatch(html, _releaseDatePattern);
                movie.Release_Date = GetMatchValue(match, "ReleaseDate", true);
                Debugger.LogMessageToFile("[IMDb film details downloader] IMDb returned Release Date: " + movie.Release_Date);
                MessageBox.Show("IMDb returned Release Date: " + movie.Release_Date);
                #endregion

                #region Extract Tagline
                Debugger.LogMessageToFile("Extracting Tagline...");
                match = GetRegExMatch(trimmedHTML, _taglinePattern);
                //match = GetRegExMatch(html, _taglinePattern);
                movie.Tagline = GetMatchValue(match, "Tagline", true);
                Debugger.LogMessageToFile("IMDb returned Tagline: " + movie.Tagline);
                MessageBox.Show("IMDb returned Tagline: " + movie.Tagline);
                #endregion

                #region Extract Runtime
                Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Runtime...");
                match = GetRegExMatch(trimmedHTML, _runtimePattern);
                string runtime = GetMatchValue(match, "Runtime", true);
                runtime = FixRuntime(runtime);
                movie.Runtime = runtime;
                Debugger.LogMessageToFile("IMDb returned Runtime: " + movie.Runtime);
                MessageBox.Show("IMDb returned Runtime: " + movie.Runtime);
                #endregion

                #region Extract Rating
                Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Rating...");
                //match = GetRegExMatch(html, _ratingPattern);
                match = GetRegExMatch(trimmedHTML, _ratingPattern);
                movie.Rating = GetMatchValue(match, "Rating", true);
                Debugger.LogMessageToFile("IMDb returned Rating: " + movie.Rating);
                MessageBox.Show("[IMDb film details downloader] IMDb returned Rating: " + movie.Rating);
                #endregion

                #region Extract Rating Description
                Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Rating Description...");
                //match = GetRegExMatch(html, _ratingDescriptionPattern);
                match = GetRegExMatch(trimmedHTML, _ratingDescriptionPattern);
                movie.RatingDescription = GetMatchValue(match, "RatingDescription", true);
                Debugger.LogMessageToFile("[IMDb film details downloader]  IMDb returned Rating Description: " + movie.RatingDescription);
                MessageBox.Show("IMDb returned Rating Description: " + movie.Rating);
                #endregion


                //// Grab Episode Info
                //match = GetRegExMatch(trimmedHTML, _EpisodePattern);
                //movie.Episode = GetMatchValue(match, "Episode", true);
                //Debugger.LogMessageToFile("IMDb returned Episode: " + movie.Episode);

                //Debugger.LogMessageToFile(_trimmedHTMLpattern);
                //Debugger.LogMessageToFile( trimmedHTML );
                //Debugger.LogMessageToFile( _reviewPattern );

                #region Extract Review
                Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Review score...");
                match = GetRegExMatch(trimmedHTML, _reviewPattern);
                movie.Review = GetMatchValue(match, "Review", true);
                if (movie.Review.Contains("/"))
                    movie.Review = movie.Review.Substring(0, movie.Review.IndexOf("/"));
                Debugger.LogMessageToFile("IMDb returned Review: " + movie.Review);
                MessageBox.Show("IMDb returned Review: " + movie.Review);
                #endregion

                #region Extract Studio
                Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Studio...");
                match = GetRegExMatch(trimmedHTML, _studioPattern);
                movie.Studio = GetMatchValue(match, "Studio", true);
                Debugger.LogMessageToFile("[IMDb film details downloader] IMDb returned Studio: " + movie.Studio);
                MessageBox.Show("IMDb returned Studio: " + movie.Studio);
                #endregion


                #region  Grab Short Overview
                Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Short Overview...");
                //match = GetRegExMatch(html, _shortOverviewPattern);
                match = GetRegExMatch(trimmedHTML, _shortOverviewPattern);

                movie.OverviewShort = GetMatchValue(match, "ShortOverview", true);
                if (movie.OverviewShort.ToLower().EndsWith("more"))
                    movie.OverviewShort = movie.OverviewShort.Substring(0, movie.OverviewShort.Length - 4).Trim();
                movie.OverviewShort = movie.OverviewShort.Trim() + "...";

                Debugger.LogMessageToFile("IMDb returned Overview: " + movie.OverviewShort);
                MessageBox.Show("IMDb returned Overview: " + movie.OverviewShort);
                #endregion


                GetDirectors(ref movie, trimmedHTML);

                GetWriters(ref movie, trimmedHTML);

                GetGenres(ref movie, trimmedHTML);

                #endregion

                if (ShowProgress)
                {
                    #region Grab details from additional IMDb pages

                    //if (ShowProgress)
                    //    Importer.thisProgress.Progress(Importer.CurrentProgress, "Getting actors...");
                    GetActors(ref movie, creditsURL);

                    //if (ShowProgress)
                    //    Importer.thisProgress.Progress(Importer.CurrentProgress, "Getting plot...");
                    GetLongOverview(ref movie, longOverviewURL);

                    //if (ShowProgress)
                    //    Importer.thisProgress.Progress(Importer.CurrentProgress, "Getting trivia...");

                    //GetTrivia(ref movie, triviaURL, ShowProgress);

                    //if (ShowProgress)
                    //    Importer.thisProgress.Progress(Importer.CurrentProgress, "Getting goofs...");

                    //GetGoofs(ref movie, goofURL);

                    //if (ShowProgress)
                    //    Importer.thisProgress.Progress(Importer.CurrentProgress, "Getting quotes...");

                    //GetQuotes(ref movie, quotesURL);

                    #endregion
                }

                #endregion

            }
            catch (Exception e)
            {
                Debugger.LogMessageToFile("The GetMovieInfo() method returned an exception: " + Environment.NewLine + e.ToString() );
            }

            return movie;
        }
        internal static void GetStudio(IMDbMovie movie, string trimmedHTML)
        {


            if (!Settings.GetIMDbMovieProductionStudio)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Studio...");
            Match match = IMDbMovieDetailsDownloader._IMDbRegex.GetRegExMatch(trimmedHTML, IMDbMovieDetailsDownloader._IMDbRegex._studioPattern);
            movie.Studio = IMDbMovieDetailsDownloader._IMDbRegex.GetMatchValue(match, "Studio", true);
            Debugger.LogMessageToFile("[IMDb film details downloader] IMDb returned Studio: " + movie.Studio);
            //MessageBox.Show("IMDb returned Studio: " + movie.Studio);
        }
        internal static void GetReview(IMDbMovie movie, string trimmedHTML)
        {


            if (!Settings.GetIMDbMovieReviews)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Review score...");
          
            Match match = IMDbMovieDetailsDownloader._IMDbRegex.GetRegExMatch(trimmedHTML, IMDbMovieDetailsDownloader._IMDbRegex._reviewPattern);
           
            movie.Review = IMDbMovieDetailsDownloader._IMDbRegex.GetMatchValue(match, "Review", true);
           
            if (movie.Review.Contains("/"))
                movie.Review = movie.Review.Substring(0, movie.Review.IndexOf("/"));
          
            Debugger.LogMessageToFile("IMDb returned Review: " + movie.Review);

        }
        internal static void ExtractRatingDescription(IMDbMovie movie, string trimmedHTML)
        {


            if (!Settings.GetIMDbMovieRatingDescription)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Rating Description...");

            Match match = 
                IMDbMovieDetailsDownloader._IMDbRegex.GetRegExMatch
                (trimmedHTML, IMDbMovieDetailsDownloader._IMDbRegex._ratingDescriptionPattern);
         
            movie.RatingDescription = 
                IMDbMovieDetailsDownloader._IMDbRegex.GetMatchValue
                (match, "RatingDescription", true);

            Debugger.LogMessageToFile("[IMDb film details downloader]  IMDb returned Rating Description: " +
                                      movie.RatingDescription);


        }
        public void MineWriterUsingXpath(ref IMDbMovie movie, string html)
        {


            if (!ImdbFilmDetailsIndividualChoices
                .GetIMDbMovieWriters)
                return;

            Debugger.LogMessageToFile
                ("[IMDb film details downloader] " +
                 "Extracting Writers...");

            const string writerXpathExpression = @"//div[@itemprop='creator']//span[@itemprop='name']";

            string writerName = Code.Metadata_Scrapers.XPathDataMiners
                .MatchXpathExpressionReturnFirstMatch
                (html, writerXpathExpression);

            IIMDbPerson writer = new IMDbPerson();
            
            movie.People.Add(writer);

            writer.URL = String.Empty;

            writer.Name = writerName;
                    
            writer.IsWriter = true;

            

            Debugger.LogMessageToFile
                ("[IMDb film details downloader]  " +
                 "IMDb returned Writers: " + writerName);
            
            //MessageBox.Show(@"IMDb returned Writers: " + writerName);

        }
        private void GetActors(ref IMDbMovie movie, string creditsURL)
        {
            // get cast html
            string html = MediaFairy.Downloaders.DownloadHTMLfromURL(creditsURL);

            // Grab Actors
            string trimmedHTML = GetRegExString(html, _castPattern);
            if (trimmedHTML.Trim() != "")
            {
                Match match1 = GetRegExMatch(trimmedHTML, _castPersonPatternWithCharacterURLs);
                while (match1 != null && match1.Length > 0)
                {
                    string personID = GetMatchValue(match1, "PersonURL", true);
                    if (personID.Trim() != "")
                    {
                        IIMDbPerson actor = movie.People.GetPersonByID(personID);
                        if (actor == null)
                        {
                            actor = new IMDbPerson();
                            movie.People.Add(actor);
                        }
                        actor.URL = personID;
                        actor.Name = GetMatchValue(match1, "PersonName", true);
                        actor.IsActor = true;
                        string characterString = GetMatchValue(match1, "CharacterName", true);
                        ParseCharacters(ref actor, characterString);

                        match1 = match1.NextMatch();
                    }
                }

                Match match2 = GetRegExMatch(trimmedHTML, _castPersonPatternWithNOCharacterURLs);
                while (match2 != null && match2.Length > 0)
                {
                    string personID = GetMatchValue(match2, "PersonURL", true);
                    if (personID.Trim() != "")
                    {
                        IIMDbPerson actor = movie.People.GetPersonByID(personID);
                        if (actor == null)
                        {
                            actor = new IMDbPerson();
                            movie.People.Add(actor);
                        }
                        actor.URL = personID;
                        actor.Name = GetMatchValue(match2, "PersonName", true);
                        actor.IsActor = true;
                        string characterString = GetMatchValue(match2, "CharacterName", true);
                        ParseCharacters(ref actor, characterString);

                        match2 = match2.NextMatch();
                    }
                }
            }
        }
        internal static void GetActorsUsingXpath(IMDbMovie movie, string html)
        {


            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieActors)
                return;

            string[] filmStars = Code.Metadata_Scrapers.XPathDataMiners.MatchXpathExpressionReturnAllMatches
                (html, "//div[@itemprop='actors']//span[@itemprop='name']");


            if (filmStars.Length <= 0)
                return;


            foreach (var filmStar in filmStars)
            {

                IMDbPerson actor = new IMDbPerson();
                
                movie.People.Add(actor);

                actor.Name = filmStar;
                actor.IsActor = true;

            }


        }
 private void GetGenres(ref IMDbMovie movie, string html)
 {
     // Grab Genres
     Match match = GetRegExMatch(html, _genrePattern);
     if (match != null && match.Length > 0)
     {
         match = GetRegExMatch(match.Value, _genre2Pattern);
         while (match != null && match.Length > 0)
         {
             string genre = GetMatchValue(match, "Genre", true);
             if (genre.Trim() != "")
                 movie.Genres.Add(genre);
             match = match.NextMatch();
         }
     }
 }
        internal void MineDirectorUsingRegex(ref IMDbMovie movie, string html)
        {


            if (!ImdbFilmDetailsIndividualChoices
                .GetIMDbMovieDirectors)
                return;


            Debugger.LogMessageToFile
                ("[IMDb film details downloader]" +
                 " Extracting Directors...");



            string directorHtml
                = _imDbRegex.GetRegExString
                (html, _imDbRegex.DirectorPattern);


            if (!String.IsNullOrEmpty(directorHtml.Trim()))
            {

                Match match = _imDbRegex.GetRegExMatch(directorHtml, _imDbRegex.PersonPattern);
                
                while (match != null && match.Length > 0)
                {
                    string personID = _imDbRegex.GetMatchValue(match, "PersonURL", true);

                    if (String.IsNullOrEmpty(personID.Trim()))
                        continue;

                    IIMDbPerson director = movie.People.GetPersonByID(personID);

                    if (director == null)
                    {
                        director = new IMDbPerson();
                        movie.People.Add(director);
                    }

                    director.URL = personID;
                    director.Name = _imDbRegex.GetMatchValue(match, "PersonName", true);
                    director.IsDirector = true;

                    match = match.NextMatch();
                }


            }

            string directors = movie.People.GetDirectorString();


            Debugger.LogMessageToFile
            ("[IMDb film details downloader] " +
            " IMDb returned Directors: " + directors);

            //MessageBox.Show(@"IMDb returned Directors: " + directors);


        }
        private void GetLongOverview(ref IMDbMovie movie, string longOverviewURL)
        {
            // get long overview html
            string html = MediaFairy.Downloaders.DownloadHTMLfromURL(longOverviewURL);

            // Grab Long Overview
            Match match = GetRegExMatch(html, _longOverviewPattern);
            movie.OverviewLong = GetMatchValue(match, "LongOverview", true);
        }
        public void GetLongOverview(ref IMDbMovie movie, string longOverviewUrl)
        {


            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieLongOverview)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Plot summary...");

            // get long overview html
            string html = HtmlDownloaders.DownloadHTMLfromURL(longOverviewUrl);

            // Grab Long Overview
            Match match = _imDbRegex.GetRegExMatch(html, _imDbRegex.FilmStorylinePattern);
            movie.OverviewLong = _imDbRegex.GetMatchValue(match, "LongOverview", true);

            Debugger.LogMessageToFile("[IMDb film details downloader]  IMDb returned Plot (LongOverview) : " + movie.OverviewLong);
            //MessageBox.Show("IMDb returned Plot Summary: " + movie.OverviewLong);
        }
        private void GetGoofs(ref IMDbMovie movie, string goofURL)
        {
            // get goof html
            string html = Downloaders.DownloadHTMLfromURL(goofURL);

            // Grab goofs
            Match match = GetRegExMatch(html, _goofPattern);
            while (match != null && match.Length > 0)
            {
                IMDbGoof goof = new IMDbGoof();
                goof.Category = GetMatchValue(match, "Category", true);
                goof.Description = GetMatchValue(match, "Goof", true);
                movie.Goofs.Add(goof);
                match = match.NextMatch();
            }
        }
        public void GetTrivia(ref IMDbMovie movie, string triviaUrl)
        {


            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieTrivia)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Trivia...");

            // get trivia html
            string html = HtmlDownloaders.DownloadHTMLfromURL(triviaUrl);

            // Grab trivia
            Match match = _imDbRegex.GetRegExMatch(html, _imDbRegex.TriviaPattern);

            while (match != null && match.Length > 0)
            {

                string trivia = _imDbRegex.GetMatchValue(match, "Trivia", true);

                if (!String.IsNullOrEmpty(trivia.Trim()))
                    movie.Trivia.Add(trivia.Trim());

                match = match.NextMatch();
            
            }


            string triviaTmp = movie.GetTriviaString();

            //Debugger.LogMessageToFile("[IMDb film details downloader]  IMDb returned Trivia: " + triviaTmp);
            //MessageBox.Show("IMDb returned Trivia: " + triviaTmp);

        }
        private void GetTrivia(ref IMDbMovie movie, string triviaURL , bool ShowProgress)
        {
            // get trivia html
            string html = MediaFairy.Downloaders.DownloadHTMLfromURL(triviaURL);

            // Grab trivia
            Match match = GetRegExMatch(html, _triviaPattern);
            while (match != null && match.Length > 0)
            {
                string trivia = GetMatchValue(match, "Trivia", true);
                if (trivia.Trim() != "")
                    movie.Trivia.Add(trivia.Trim());
                match = match.NextMatch();
            }
        }
        internal static void MineOverviewUsingXpath
            (IMDbMovie movie, string trimmedHTML)
        {


            if (!ImdbFilmDetailsIndividualChoices
                .GetIMDbMovieShortOverview)
                return;

            Debugger.LogMessageToFile
                ("[IMDb film details downloader]" +
                 " Extracting Short Overview...");


            const string filmOverviewXpathExpression
                = @"//p[@itemprop='description']";

            movie.OverviewShort = Code.Metadata_Scrapers.XPathDataMiners
                .MatchXpathExpressionReturnFirstMatch
                (trimmedHTML, filmOverviewXpathExpression).Trim();



            Debugger.LogMessageToFile
                ("IMDb returned Overview: " + movie.OverviewShort);

            //MessageBox.Show(movie.OverviewShort);

        }
        private void GetQuotes(ref IMDbMovie movie, string quotesURL)
        {
            // get quotes html
            string html = MediaFairy.Downloaders.DownloadHTMLfromURL(quotesURL);

            // Grab quotes
            Match match1 = GetRegExMatch(html, _quoteBlockPattern);
            while (match1 != null && match1.Length > 0)
            {
                string quoteBlockHTML = GetMatchValue(match1, "QuoteBlock", false);
                if (quoteBlockHTML.Trim() != "")
                {
                    List<IIMDbQuote> quoteBlock = new List<IIMDbQuote>();
                    Match match2 = GetRegExMatch(quoteBlockHTML, _quotePattern);
                    while (match2 != null && match2.Length > 0)
                    {
                        IMDbQuote quote = new IMDbQuote();
                        quote.Character = GetMatchValue(match2, "Character", true);
                        quote.Text = GetMatchValue(match2, "Quote", true);
                        quoteBlock.Add(quote);
                        match2 = match2.NextMatch();
                    }
                    if (quoteBlock.Count > 0)
                        movie.Quotes.Add(quoteBlock);
                }
                match1 = match1.NextMatch();
            }
        }
        internal static void ExtractRatingDescription
            (IMDbMovie movie,
            string trimmedHTML, IMDbRegEx imDbRegEx)
        {


            if (!ImdbFilmDetailsIndividualChoices.GetIMDbMovieRatingDescription)
                return;

            Debugger.LogMessageToFile("[IMDb film details downloader] Extracting Rating Description...");

            Match match = 
                imDbRegEx.GetRegExMatch
                (trimmedHTML, imDbRegEx.RatingDescriptionPattern);
         
            movie.RatingDescription = 
                imDbRegEx.GetMatchValue
                (match, "RatingDescription", true);

            Debugger.LogMessageToFile("[IMDb film details downloader]  IMDb returned Rating Description: " +
                                      movie.RatingDescription);


        }
        internal void MineDirectorUsingXpath(ref IMDbMovie movie, string html)
        {


            if (!ImdbFilmDetailsIndividualChoices
                .GetIMDbMovieDirectors)
                return;


            Debugger.LogMessageToFile
                ("[IMDb film details downloader]" +
                 " Extracting Director...");

            const string directorXpathExpression = @"//div[@itemprop='director']//span[@itemprop='name']";


            string directorName = Code.Metadata_Scrapers.XPathDataMiners
                .MatchXpathExpressionReturnFirstMatch(html, directorXpathExpression);

            IIMDbPerson director = new IMDbPerson();

            movie.People.Add(director);

            director.URL = String.Empty;

            director.Name = directorName;
                    
            director.IsDirector = true;
                

            Debugger.LogMessageToFile
            ("[IMDb film details downloader] " +
            " IMDb returned Directors: " + director);

            //MessageBox.Show(@"IMDb returned Director: " + directorName);


        }
        internal static void GetStudio
            (IMDbMovie movie,
            string trimmedHtml,
            IMDbRegEx imDbRegEx)
        {


            if (!ImdbFilmDetailsIndividualChoices
                .GetIMDbMovieProductionStudio)
                return;

            Debugger.LogMessageToFile
                ("[IMDb film details downloader] " +
                 "Extracting Studio...");


            Match match
                = imDbRegEx
                .GetRegExMatch
                (trimmedHtml, 
                imDbRegEx.StudioPattern);


            movie.Studio = imDbRegEx.GetMatchValue
                (match, "Studio", true);


            Debugger.LogMessageToFile
                ("[IMDb film details downloader] " +
                 "IMDb returned Studio: " 
                 + movie.Studio);


        }
		internal static IMDbMovie MineFilmDetailsFromAdditionalPages
			(bool showProgress, IMDbFilmDetails filmDetails,
             IMDbMovie movie, string movieUrl)
		{


			if (!showProgress)
				return movie;




            string creditsUrl = movieUrl + "fullcredits";
            string longOverviewUrl = movieUrl + "plotsummary";
            string goofUrl = movieUrl + "goofs";
            string triviaUrl = movieUrl + "trivia";
            string quotesUrl = movieUrl + "quotes";


			MainImportingEngine.ThisProgress.Progress
                (MainImportingEngine.CurrentProgress, "Getting actors...");
			
            //filmDetails.GetActorsUsingRegex(ref movie, creditsUrl);


			MainImportingEngine.ThisProgress.Progress
                (MainImportingEngine.CurrentProgress, "Getting plot summary...");
			
            //filmDetails.GetLongOverview(ref movie, longOverviewUrl);



			//MainImportingEngine.ThisProgress.Progress
			//    (MainImportingEngine.CurrentProgress, "Getting trivia...");

			//filmDetails.GetTrivia(ref movie, triviaUrl);

			//MainImportingEngine.ThisProgress.Progress
			//    (MainImportingEngine.CurrentProgress, "Getting goofs...");

			//filmDetails.GetGoofs(ref movie, goofUrl);

			//MainImportingEngine.ThisProgress.Progress
			//    (MainImportingEngine.CurrentProgress, "Getting quotes...");

			//filmDetails.GetQuotes(ref movie, quotesUrl);

			//TODO: Get these additional IMDb film details

			//Get Stars

			//Get Awards

			//Get Credits

			//Get Plot Keywords

			//Get Official Websites

			//Get Production Country

			//Get Language

			//Get Box Office Budget

			//Get Box Office Gross

			//Get Color

			//Get Aspect Ratio

			//Get Connections

			//Get Soundtracks

			//Get User Review


			return movie;


		}