internal static void IgnoreIrrelevantResults (Match match, IMDbRegEx imDbRegex, IMDbSearchResult result) { //TODO: Also ignore "Making Of" titles. //TODO: Also ignore documentaries (option). string extra = imDbRegex.GetMatchValue (match, "Extra", true); IgnoreVideoGameResult(result, extra); }
internal static IMDbSearchResult MultipleMatchesMineDetailsOfSingleFilmResult (Match match, IMDbRegEx imDbRegex) { #region Result's details Debugger.LogMessageToFile( "[IMDb Conventional Film Search Engine] " + "New search result was found. " + "Proceeding to add result to the list of total search results..."); var result = new IMDbSearchResult(); result.IMDb_ID = imDbRegex.GetMatchValue (match, "IMDbID", true); Debugger.LogMessageToFile ("[IMDb Conventional Film Search Engine] " + "Result IMDb ID: " + result.IMDb_ID); result.Title = imDbRegex.GetMatchValue (match, "Title", true); Debugger.LogMessageToFile ("[IMDb Conventional Film Search Engine] " + "Result Title: " + result.Title); result.Year = imDbRegex.GetMatchValue (match, "Year", true); Debugger.LogMessageToFile ("[IMDb Conventional Film Search Engine] " + "Result Year: " + result.Year); string URL = imDbRegex.GetMatchValue (match, "URL", true); result.URL = "http://www.imdb.com" + URL; Debugger.LogMessageToFile ("[IMDb Conventional Film Search Engine] " + "Result URL: " + result.URL); #endregion return result; }
internal static List<IIMDbSearchResult> SingleMatchAddToSearchResults (string html, IMDbRegEx imDbRegex, List<IIMDbSearchResult> results) { var titleIndexFound = LocateTitleIndex(html); if (!titleIndexFound) return results; Debugger.LogMessageToFile ("[IMDb Conventional Film Search Engine] " + "A single result was found."); //TODO: Are these RegExes the same as the 'movie result' ones? const string titleAndYearPattern = @"<title>(?<Title>.*?)\((?<Year>.*?)\)</title>"; const string ImdbIdPattern = @"<a\shref=""/title/(?<IMDbID>[^/]*)/fullcredits"""; Match match = imDbRegex.GetRegExMatch(html, titleAndYearPattern); #region Return if no matches were found if (match == null || match.Length == 0) return results; #endregion var result = new IMDbSearchResult { Title = imDbRegex.GetMatchValue(match, "Title", true), Year = imDbRegex.GetMatchValue(match, "Year", true) }; MineImdbIdFromSingleFilmMatch (html, imDbRegex, ImdbIdPattern, result); AddSingleFilmResultToSearchResults (results, result); return results; }
public IList<IIMDbSearchResult> SearchMovies(string title) { List<IIMDbSearchResult> results = new List<IIMDbSearchResult>(); string url = "http://www.imdb.com/find?s=title&q=" + JCUtils.WebUtils.EncodeURLstring(title); string html; try { html = JCUtils.WebUtils.GET(url); } catch { try { Thread.Sleep(2000); html = JCUtils.WebUtils.GET(url); } catch (Exception) { //MessageBox.Show(e.ToString()); return results; } } if (html.ToLower().IndexOf("<b>popular titles") < 0 && html.ToLower().IndexOf("<b>titles") < 0) { int num1 = 0; int num2 = 0; string text1 = ""; string text2 = ""; num1 = html.ToLower().IndexOf("<title>"); if (num1 > -1) { string regExString1 = @"<title>(?<Title>.*?)\((?<Year>.*?)\)</title>"; string regExString2 = @"<a\shref=""/title/(?<IMDbID>[^/]*)/fullcredits"""; Match match = GetRegExMatch(html, regExString1); if (match != null && match.Length > 0) { IMDbSearchResult result = new IMDbSearchResult(); result.Title = GetMatchValue(match, "Title", true); result.Year = GetMatchValue(match, "Year", true); match = GetRegExMatch(html, regExString2); if (match != null && match.Length > 0) result.IMDb_ID = GetMatchValue(match, "IMDbID", true); if (result.IMDb_ID.Trim() != "" && result.Title.Trim() != "") results.Add(result); } } } else { Match match = GetRegExMatch(html, _movieResultPattern1); while (match != null && match.Length > 0) { IMDbSearchResult result = new IMDbSearchResult(); result.IMDb_ID = GetMatchValue(match, "IMDbID", true); result.Title = GetMatchValue(match, "Title", true); result.Year = GetMatchValue(match, "Year", true); result.URL = "http://www.imdb.com" + GetMatchValue(match, "URL", true); string extra = GetMatchValue(match, "Extra", true); if (extra.ToLower().Trim().Contains("(vg)")) result.Ignore = true; if (!result.Ignore) results.Add(result); match = match.NextMatch(); } match = GetRegExMatch(html, _movieResultPattern2); while (match != null && match.Length > 0) { IMDbSearchResult result = new IMDbSearchResult(); result.IMDb_ID = GetMatchValue(match, "IMDbID", true); result.Title = GetMatchValue(match, "Title", true); result.Year = GetMatchValue(match, "Year", true); result.URL = "http://www.imdb.com" + GetMatchValue(match, "URL", true); string extra = GetMatchValue(match, "Extra", true); if (extra.ToLower().Trim().Contains("(vg)")) result.Ignore = true; results.Add(result); match = match.NextMatch(); } } //MessageBox.Show("Results: " + results.Count.ToString() ); return results; }