public IMDbMovieCollection SearchMovies1(string title) { //declarations IMDbMovieCollection movies = new IMDbMovieCollection(); string text1 = "", text2 = "", text3 = ""; int num1 = 0, num2 = 0, num3 = 0; bool flag1 = false; try { #region get html retry_download_html: try { text1 = ToolBox.WebUtils.GetSiteContents("http://www.imdb.com/find?s=tt&q=" + ToolBox.WebUtils.EncodeURL(title)); if (text1 == null || text1.Trim() == "") { if (num1 <= _retries) { num1++; System.Threading.Thread.Sleep(2000); goto retry_download_html; } } } catch { if (num3 <= _retries) { num3 += 1; System.Threading.Thread.Sleep(2000); goto retry_download_html; } } #endregion num1 = text1.ToLower().IndexOf("<b>popular titles"); if (num1 > -1) { num1 += 3; num2 = text1.ToLower().IndexOf("more searches", num1); if (num2 > -1) { text1 = text1.Substring(num1, (num2 - num1)).Trim(); flag1 = true; } } else { num1 = text1.ToLower().IndexOf("<b>titles"); if (num1 > -1) { num1 += 3; num2 = text1.ToLower().IndexOf("more searches", num1); if (num2 > -1) { text1 = text1.Substring(num1, (num2 - num1)).Trim(); flag1 = true; } } else { flag1 = false; num1 = text1.ToLower().IndexOf("<title>"); if (num1 > -1) { num1 += 7; num2 = text1.ToLower().IndexOf("</title>", num1); if (num2 > -1) { IMDbMovie movie = new IMDbMovie(); text2 = text1.Substring(num1, (num2 - num1)).Trim(); text2 = ToolBox.WebUtils.CleanUpHTML(text2, true).Trim(); text2 = ToolBox.WebUtils.FixString(text2).Trim(); num1 = text2.IndexOf("("); if (num1 > -1) { movie.Title = text2.Substring(0, num1).Trim(); num1++; num2 = text2.IndexOf(")", num1); if (num2 > -1) movie.Year = text2.Substring(num1, (num2 - num1)).Trim(); } num1 = text1.ToLower().IndexOf("/title/"); if (num1 > -1) { num1 += 7; num2 = text1.ToLower().IndexOf("/", num1); if (num2 > -1) { movie.IMDb_ID = text1.Substring(num1, (num2 - num1)).Trim(); movies.Add(movie); } } } } } } if (flag1) { num1 = 0; while (num1 > -1) { retry_title: num1 = text1.ToLower().IndexOf("/title/", num1); if (num1 > -1) { num1 += 7; num2 = text1.ToLower().IndexOf("/", num1); if (num2 > -1) { IMDbMovie movie = new IMDbMovie(); movie.IMDb_ID = text1.Substring(num1, (num2 - num1)).Trim(); num1 = text1.ToLower().IndexOf(">", num2); if (num1 > -1) { num1++; num2 = text1.ToLower().IndexOf("<", num1); if (num2 == num1) { goto retry_title; } if (num2 > -1) { text3 = text1.Substring(num1, (num2 - num1)).Trim(); text3 = ToolBox.WebUtils.CleanUpHTML(text3, true).Trim(); text3 = ToolBox.WebUtils.FixString(text3).Trim().Replace("(", "").Replace(")", "").Trim(); num1 = text1.ToLower().IndexOf(">", num2); if (num1 > -1) { num1++; num2 = text1.ToLower().IndexOf("<", num1); if (num2 > -1) { text3 += " ("; text3 += text1.Substring(num1, (num2 - num1)).Trim().Replace("(", "").Replace(")", "") + ")"; } } num2 = text3.IndexOf("("); if (num2 > -1) { movie.Title = text3.Substring(0, num2).Trim(); num2++; num3 = text3.IndexOf(")", num2); if (num3 > -1) movie.Year = text3.Substring(num2, (num3 - num2)).Trim(); } movies.Add(movie); } } } } } } return movies; } catch (Exception ex) { throw ex; } }
public IIMDbMovieCollection SearchMovieInfo(string title ) { IMDbMovieCollection movies = new IMDbMovieCollection(); try { IList<IIMDbSearchResult> results = SearchMovies(title); if (results != null) foreach (IIMDbSearchResult result in results) { if (result.IMDb_ID.Trim() != "") { IIMDbMovie movie = GetMovieInfoFromIMDb(result.IMDb_ID.Trim(), false); if (movie != null) movies.Add(movie); } } return movies; } catch (Exception ex) { throw ex; } }
public IMDbMovieCollection SearchMovieInfo1(string title) { IMDbMovieCollection movies = new IMDbMovieCollection(); try { IMDbMovieCollection results = SearchMovies1(title); if (results != null) { foreach (IMDbMovie result in results) { if (result.IMDb_ID.Trim() != "") { IMDbMovie movie = GetMovieInfo1(result.IMDb_ID.Trim()); if (movie != null) movies.Add(movie); } } } return movies; } catch (Exception ex) { throw ex; } }