public frm_Star(Cast cast) { person = cast; DAL = new DataAccessLayer(); InitializeComponent(); }
public Movie DBControl(Movie movie) { SqlCommand cmmd = new SqlCommand("Select * from Movies where ImdbId=@ImdbID", connect); cmmd.Parameters.Add("@ImdbID", SqlDbType.NVarChar).Value = movie.ImdbId; reader = cmmd.ExecuteReader(); if (reader.HasRows) { Movie film = new Movie(); while (reader.Read()) { film.ID = reader.IsDBNull(0) ? 0 : reader.GetInt32(0); film.Name = reader.IsDBNull(1) ? string.Empty : reader.GetString(1); film.Description = reader.IsDBNull(2) ? string.Empty : reader.GetString(2); film.Raiting = reader.IsDBNull(3) ? string.Empty : reader.GetString(3); film.ImdbId = reader.IsDBNull(4) ? string.Empty : reader.GetString(4); film.Poster = reader.IsDBNull(5) ? string.Empty : reader.GetString(5); } reader.Close(); SqlCommand moviecast = new SqlCommand("SP_MovieCast", connect); moviecast.CommandType = CommandType.StoredProcedure; moviecast.Parameters.Add("@movie_Id", SqlDbType.Int).Value = film.ID; reader = moviecast.ExecuteReader(); while (reader.Read()) { Cast cast = new Cast(); cast.ID = reader.IsDBNull(0) ? 0 : reader.GetInt32(0); cast.Name = reader.IsDBNull(1) ? string.Empty : reader.GetString(1); cast.ImdbId = reader.IsDBNull(2) ? string.Empty : reader.GetString(2); SqlCommand castrole = new SqlCommand("SP_CastRole", conn); castrole.CommandType = CommandType.StoredProcedure; castrole.Parameters.Add("@cast_Id", SqlDbType.Int).Value = cast.ID; castrole.Parameters.Add("@movie_Id", SqlDbType.Int).Value = film.ID; SqlDataReader castrolereader = castrole.ExecuteReader(); while (castrolereader.Read()) { Role role = new Role(); role.RoleName = castrolereader.IsDBNull(0) ? string.Empty : castrolereader.GetString(0); cast.Roles.Add(role); } castrolereader.Close(); film.Casts.Add(cast); } reader.Close(); SqlCommand movieimage = new SqlCommand("SP_MovieImage", connect); movieimage.CommandType = CommandType.StoredProcedure; movieimage.Parameters.Add("@movie_Id", SqlDbType.Int).Value = film.ID; reader = movieimage.ExecuteReader(); while (reader.Read()) { film.Images.Add(reader.IsDBNull(0) ? string.Empty : reader.GetString(0)); } reader.Close(); if (film.Casts.Count < 1) { return(null); } return(film); } else { reader.Close(); return(null); } }
public void Cast() { start = 0; end = 0; Cast person; string[] desc = html.Split(new string[] { "div class=\"summary_text\">\n" }, StringSplitOptions.None); end = desc[1].IndexOf('<'); film.Description = desc[1].Substring(0, end - start); txt_description.Text = film.Description.TrimStart(); response = html.Split(new string[] { "<div class=\"credit_summary_item\">\n" }, StringSplitOptions.None); for (int i = 1; i < response.Length; i++) { string[] director = response[i].Split(new string[] { "<a href=", "</a>" }, StringSplitOptions.None); if (director[0].Contains(">Director") == true) { string result = String.Concat(director); start = result.IndexOf("</div>"); result = result.Remove(start); string[] director1 = result.Split(','); for (int y = 0; y < director1.Length; y++) { person = new Cast(); if (director1[y].Contains("<span") == true) { start = director1[y].IndexOf('>') + 1; end = director1[y].IndexOf("<span"); person.Name = director1[y].Substring(start, end - start).TrimEnd(); start = director1[y].IndexOf("/name/"); end = director1[y].IndexOf("\n") - 1; person.ImdbId = director1[y].Substring(start, end - start); } else { start = director1[y].LastIndexOf('>') + 1; person.Name = director1[y].Substring(start).TrimEnd(); start = director1[y].IndexOf("/name/"); end = director1[y].LastIndexOf("\n") - 1; person.ImdbId = director1[y].Substring(start, end - start); } AddRole(person, Role.Director); } AddList("Director", lst_director); } else if (director[0].Contains(">Writer") == true) { string result = String.Concat(director); start = result.IndexOf("</div>"); result = result.Remove(start); string[] director1 = result.Split(','); for (int y = 0; y < director1.Length; y++) { person = new Cast(); if (director1[y].Contains("<span") == true) { start = director1[y].IndexOf('>') + 1; end = director1[y].IndexOf("<span"); person.Name = director1[y].Substring(start, end - start); start = director1[y].IndexOf("/name/"); end = director1[y].IndexOf("\n") - 1; person.ImdbId = director1[y].Substring(start, end - start); } else { start = director1[y].LastIndexOf('>') + 1; person.Name = director1[y].Substring(start).TrimEnd(); start = director1[y].IndexOf("/name/"); end = director1[y].LastIndexOf("\n") - 1; person.ImdbId = director1[y].Substring(start, end - start); } AddRole(person, Role.Writer); } AddList("Writer", lst_writer); } else if (director[0].Contains(">Star") == true) { string result = String.Concat(director); start = result.IndexOf("</div>"); result = result.Remove(start); string[] director1 = result.Split(','); for (int y = 0; y < director1.Length; y++) { person = new Cast(); if (director1[y].Contains("<span") == true) { start = director1[y].IndexOf('>') + 1; end = director1[y].IndexOf("<span"); person.Name = director1[y].Substring(start, end - start); start = director1[y].IndexOf("/name/"); end = director1[y].IndexOf("\n") - 1; person.ImdbId = director1[y].Substring(start, end - start); } else { start = director1[y].LastIndexOf('>') + 1; person.Name = director1[y].Substring(start); start = director1[y].IndexOf("/name/"); end = director1[y].LastIndexOf("\n") - 1; person.ImdbId = director1[y].Substring(start, end - start); } AddRole(person, Role.Actor); } AddList("Actor", lst_star); } else if (director[0].Contains(">Creator") == true) { string result = String.Concat(director); start = result.IndexOf("</div>"); result = result.Remove(start); string[] director1 = result.Split(','); for (int y = 0; y < director1.Length; y++) { person = new Cast(); if (director1[y].Contains("<span") == true) { start = director1[y].IndexOf('>') + 1; end = director1[y].IndexOf("<span"); person.Name = director1[y].Substring(start); start = director1[y].IndexOf("/name/"); person.ImdbId = director1[y].Substring(start); person.Roles.Add(Role.Director); } else { start = director1[y].LastIndexOf('>') + 1; person.Name = director1[y].Substring(start); start = director1[y].IndexOf("/name/"); end = director1[y].LastIndexOf("\n") - 1; person.ImdbId = director1[y].Substring(start, end - start); person.Roles.Add(Role.Director); } film.Casts.Add(person); } AddList("Director", lst_director); } } }
private void MovieDetails_Load(object sender, EventArgs e) { person = new Cast(); panelImage.Controls.Clear(); WebClient webclient = new WebClient(); webclient.Encoding = Encoding.UTF8; html = webclient.DownloadString("https://www.imdb.com/" + key); if (html.Contains("<div class=\"combined-see-more see-more\">")) { string[] article = html.Split(new string[] { "<div class=\"article\"" }, StringSplitOptions.None); foreach (var item in article) { #region Photos if (item.Contains("<div class=\"mediastrip\">")) { start = item.IndexOf("<div class=\"mediastrip\">"); string picdiv = item.Substring(start); start = picdiv.IndexOf("<a"); end = picdiv.IndexOf("</div>"); picdiv = picdiv.Substring(start, end - start); string[] picture = picdiv.Split(new string[] { "<a href=", "</a>" }, StringSplitOptions.None); for (int i = 0; i < picture.Length; i++) { if (picture[i].Contains("src")) { start = picture[i].IndexOf("loadlate=\"") + 10; end = picture[i].IndexOf(".jpg"); string photo = picture[i].Substring(start, end - start + 5); film.Images.Add(photo); } } ImagesList(film.Images); start = item.IndexOf("<div class=\"combined-see-more see-more\">"); end = item.IndexOf("See all") + 7; string seeAll = item.Substring(start, end - start); string[] otherPhotos = seeAll.Split(new string[] { "<a href=", "</a>" }, StringSplitOptions.None); for (int i = 0; i < otherPhotos.Length; i++) { if (otherPhotos[i].Contains("See all")) { start = otherPhotos[i].IndexOf("/title"); end = otherPhotos[i].IndexOf('>'); person.OtherPhotos = otherPhotos[i].Substring(start, end - start); } } } #endregion #region Casts else if (item.Contains("<table class=\"cast_list\">")) { string[] a = item.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.None); a = item.Split(new string[] { "<a href=", "</a>" }, StringSplitOptions.None); for (int i = 0; i < a.Length; i++) { if (a[i].Contains("/name")) { start = a[i].IndexOf('>') + 1; end = a[i].LastIndexOf('\n'); if (end > start) { lst_casts.Items.Add(a[i].Substring(start, end - start)); } } } } #endregion } } else { #region TV Series Casts string[] article = html.Split(new string[] { "<div class=\"article\"" }, StringSplitOptions.None); foreach (var item in article) { if (item.Contains("<table class=\"cast_list\">")) { string[] a = item.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.None); a = item.Split(new string[] { "<a href=", "</a>" }, StringSplitOptions.None); for (int i = 0; i < a.Length; i++) { if (a[i].Contains("/name")) { start = a[i].IndexOf('>') + 1; end = a[i].LastIndexOf('\n'); if (end > start) { lst_casts.Items.Add(a[i].Substring(start, end - start)); } } } } } #endregion } Cast(); Poster(); Ratings(); string[] title = html.Split(new string[] { "<div class=\"title_wrapper\">", "<span id=\"titleYear\">" }, StringSplitOptions.None); start = title[1].IndexOf('>') + 1; end = title[1].IndexOf('&'); film.Name = title[1].Substring(start, end - start); lbl_moviename.Text = film.Name; lbl_rating.Text = film.Raiting + " Imdb Point"; }
public Photos(Cast person) { InitializeComponent(); url = person.OtherPhotos; }
public frm_Writer(Cast cast) { person = cast; InitializeComponent(); }
public Cast Desc(Cast person) { string html = HtmlToString(person.ImdbId); if (html.Contains("class=\"inline\">\n")) { string[] desc = html.Split(new string[] { "class=\"inline\">\n" }, StringSplitOptions.None); string[] desc1 = desc[1].Split(new string[] { "</div>" }, StringSplitOptions.None); #region description string[] desc2 = desc1[0].Split(new string[] { "<a href=", "</a>" }, StringSplitOptions.None); string descfull = ""; for (int i = 0; i < desc2.Length; i++) { if (desc2[i].Contains("See") == false) { if (desc2[i].Contains("<span") == false) { if (desc2[i].Contains('>')) { start = desc2[i].IndexOf('>'); descfull = descfull + desc2[i].Substring(start + 1); } else { descfull = descfull + desc2[i]; } } else { end = desc2[i].IndexOf("."); descfull = descfull + desc2[i].Substring(0, end); } } else { descfull = descfull + "..."; } } person.Description = descfull.TrimStart(); #endregion #region Born string[] born = desc1[3].Split(new string[] { "<a href=", "</a>" }, StringSplitOptions.None); string bornfull = ""; for (int i = 0; i < born.Length; i++) { if (born[i].Contains("search")) { start = born[i].IndexOf('>') + 1; bornfull = bornfull + born[i].Substring(start) + " "; } } person.Born = bornfull; #endregion } return(person); }
public Cast Filmography(Cast person, Movie filmography) { string html = person.HtmlToString(person.ImdbId); string response = html.Substring(html.IndexOf("<div id=\"filmography\">")); response = response.Substring(0, response.IndexOf("<script>")); string[] filmohead = response.Split(new string[] { "<div class=\"filmo-category-section\"" }, StringSplitOptions.None); foreach (var item in filmohead) { if (item.Contains("<div class=\"filmo-row")) { string[] job = item.Split(new string[] { "<div class=\"filmo-row\"", "</div>" }, StringSplitOptions.None); foreach (var flmname in job) { filmography = new Movie(); if (flmname.Contains("id=\"actor")) { start = flmname.IndexOf("<a href=\"") + 9; end = flmname.IndexOf("</a>"); string lnkname = flmname.Substring(start, end - start); filmography.ImdbId = lnkname.Substring(0, lnkname.IndexOf('?')); filmography.Name = lnkname.Substring(lnkname.IndexOf('>') + 1); person.Roles.Add(Role.Actor); person.Filmographies.Add(filmography); } else if (flmname.Contains("id=\"director")) { start = flmname.IndexOf("<a href=\"") + 9; end = flmname.IndexOf("</a>"); string lnkname = flmname.Substring(start, end - start); filmography.ImdbId = lnkname.Substring(0, lnkname.IndexOf('?')); filmography.Name = lnkname.Substring(lnkname.IndexOf('>') + 1); person.Roles.Add(Role.Director); person.Filmographies.Add(filmography); } else if (flmname.Contains("id=\"writer")) { start = flmname.IndexOf("<a href=\"") + 9; end = flmname.IndexOf("</a>"); string lnkname = flmname.Substring(start, end - start); filmography.ImdbId = lnkname.Substring(0, lnkname.IndexOf('?')); filmography.Name = lnkname.Substring(lnkname.IndexOf('>') + 1); person.Roles.Add(Role.Writer); person.Filmographies.Add(filmography); } else if (flmname.Contains("id=\"actress")) { start = flmname.IndexOf("<a href=\"") + 9; end = flmname.IndexOf("</a>"); string lnkname = flmname.Substring(start, end - start); filmography.ImdbId = lnkname.Substring(0, lnkname.IndexOf('?')); filmography.Name = lnkname.Substring(lnkname.IndexOf('>') + 1); person.Roles.Add(Role.Actor); person.Filmographies.Add(filmography); } } } } return(person); }
public frm_Director(Cast cast) { person = cast; InitializeComponent(); }