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(); } }
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); }
/// <summary> /// Retrieves list of quotes from specified xml file /// </summary> /// <param name="xmlPath">path of xml file to read from</param> public static IList<IList<IIMDbQuote>> ReadQuotes( string xmlPath) { try { List<IList<IIMDbQuote>> quotes = new List<IList<IIMDbQuote>>(); if (System.IO.File.Exists(xmlPath)) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(xmlPath); System.Xml.XmlNodeList quoteBlockList = doc.SelectNodes("/Quotes/QuoteBlock"); if (quoteBlockList != null) foreach (System.Xml.XmlNode quoteBlockNode in quoteBlockList) { List<IIMDbQuote> quoteBlock = new List<IIMDbQuote>(); foreach (System.Xml.XmlNode quoteNode in quoteBlockNode.ChildNodes) { if (quoteNode["Character"] != null && quoteNode["Character"].InnerText != null && quoteNode["Character"].InnerText.Trim() != "" && quoteNode["QuoteText"] != null && quoteNode["QuoteText"].InnerText != null && quoteNode["QuoteText"].InnerText.Trim() != "") { IMDbQuote quote = new IMDbQuote(); quote.Character = quoteNode["Character"].InnerText; quote.Text = quoteNode["QuoteText"].InnerText; quoteBlock.Add(quote); } } if (quoteBlock.Count > 0) quotes.Add(quoteBlock); } } return quotes; } catch (Exception ex) { throw ex; } }