/// <summary> /// 生成播放页面--快播 /// </summary> /// <param name="kuaib">快播地址</param> /// <param name="cls">分类</param> public string CreateDramapage(MovieUrlKuaib kuaib, Class cls) { DataEntities ent = new DataEntities(); MovieInfo movie = (from l in ent.MovieInfo where l.id == kuaib.MovieID select l).FirstOrDefault(); string FileName = BasePage.GetMovieDramaUrl(kuaib, cls); string Content = ""; Content = GetTempateString(1, TempType.快播页面); Content = ReplacePublicTemplate(Content); Content = ReplacePublicTemplate(Content); Content = ReplacePublicTemplate(Content); Content = ReplaceSystemSetting(Content); #region 替换内容 MovieUrlKuaib next = BasePage.GetNextKuaibo(kuaib); if (next == null) { next = new MovieUrlKuaib(); next.Url = ""; } Content = Content.Replace("[!--class.id--]", cls.ID.ToString()); Content = Content.Replace("[!--class.name--]", cls.ClassName); Content = Content.Replace("[!--class.url--]", BasePage.GetClassUrl(cls)); Content = Content.Replace("[!--movie.url--]", BasePage.GetMovieUrl(movie, movie.GetClass())); Content = Content.Replace("[!--movie.nextpageurl--]", BasePage.SystemSetting.SiteUrl + BasePage.GetMovieDramaUrl(next, next.GetClass())); Content = Content.Replace("[!--drama.title--]", kuaib.Title); Content = Content.Replace("[!--drama.url--]", kuaib.Url); Content = Content.Replace("[!--drama.updatetime--]", kuaib.UpdateTime.ToString()); Content = ReplaceContent(Content, movie, cls); StringBuilder sb = new StringBuilder(); List<MovieUrlKuaib> qb = (from l in ent.MovieUrlKuaib where l.MovieID == movie.id select l).ToList(); string list_tmp = GetTempateString(1, TempType.下载地址); foreach (MovieUrlKuaib q in qb) { string row = list_tmp.Replace("[!--url.id--]", q.id.ToS()); row = row.Replace("[!--url.url--]", q.Url); row = row.Replace("[!--url.title--]", q.Title); row = row.Replace("[!--url.movieid--]", q.MovieID.ToS()); row = row.Replace("[!--url.movietitle--]", q.MovieTitle); row = row.Replace("[!--url--]", BasePage.GetMovieDramaUrl(q, q.GetClass())); sb.Append(row); } Content = Content.Replace("[!--movie.kuib--]", sb.ToS()); sb = new StringBuilder(); List<MovieUrlBaidu> baidu = (from l in ent.MovieUrlBaidu where l.MovieID == movie.id select l).ToList(); foreach (MovieUrlBaidu q in baidu) { string row = list_tmp.Replace("[!--url.id--]", q.id.ToS()); row = row.Replace("[!--url.url--]", q.Url); row = row.Replace("[!--url.title--]", q.Title); row = row.Replace("[!--url.movieid--]", q.MovieID.ToS()); row = row.Replace("[!--url.movietitle--]", q.MovieTitle); row = row.Replace("[!--url--]", BasePage.GetMovieDramaUrl(q, q.GetClass())); sb.Append(row); } Content = Content.Replace("[!--movie.baidu--]", sb.ToS()); sb = new StringBuilder(); List<MovieUrlMag> mag = (from l in ent.MovieUrlMag where l.MovieID == movie.id select l).ToList(); foreach (MovieUrlMag q in mag) { string row = list_tmp.Replace("[!--url.id--]", q.id.ToS()); row = row.Replace("[!--url.url--]", q.Url); row = row.Replace("[!--url.title--]", q.Title); row = row.Replace("[!--url.movieid--]", q.MovieID.ToS()); row = row.Replace("[!--url.movietitle--]", q.MovieTitle); sb.Append(row); } Content = Content.Replace("[!--movie.mag--]", sb.ToS()); #endregion Content = ReplaceTagContent(Content); //替换导航条 Content = Content.Replace("[!--newsnav--]", BuildClassNavString(cls)); ent.Dispose(); return Content; }
/// <summary> /// 旧的电影采集 /// </summary> protected void OldCollect() { Response.Buffer = false; //打开列表页面 Response.Write("打开列表页面<br/>"); string listUrl = "http://kuaib.tv.sohu.com/html/more_list21.htm"; openurl: string html_List = Url.GetHtml(listUrl, "utf-8"); //打开信息页面 Match m_list = html_List.GetMatchGroup("<img src=\"(?<image>.*?)\" width=\"120\" height=\"165\" alt=\"\" />[\\s\\S]*?<h4><a href=\"(?<url>.*?)\" target=\"_blank\">(?<title>.*?)</a></h4>"); while (m_list.Success) { //判断是否存在 if (MovieInfoView.Exist(string.Format("Title=N'{0}'", m_list.Groups["title"].Value))) { m_list = m_list.NextMatch(); continue; } Response.Write("下载封面<br/>"); //如果不存在,则先下载封面,内容页面是没有封面的 try { Url.DownFile(m_list.Groups["image"].Value, Server.MapPath("~/config/movieface.jpg")); } catch (Exception ex) { Response.Write(ex.Message + "<br/>"); } //打开内容页面 Response.Write("打开内容页面<br/>"); string html_content = Url.GetHtml(m_list.Groups["url"].Value, "utf-8"); Match m_movie = html_content.GetMatchGroup("<em id='specialID'>《(?<title>.*?)》</em>[\\s\\S]*?<param name='URL' value='(?<url>.*?)'>[\\s\\S]*?<div id=\"introID\">[\\s]*?<p>(?<intro>[\\s\\S]*?)</p>[\\s\\S]*?var VRS_DIRECTOR=\"(?<director>.*?)\";[\\s\\S]*?var VRS_CATEGORY=\"(?<tags>.*?)\";[\\s\\S]*?var VRS_ACTOR=\"(?<actor>.*?)\";[\\s\\S]*?var VRS_AREA=\"(?<location>.*?)\";[\\s\\S]*?var VRS_PLAY_YEAR=\"(?<year>.*?)\";"); if (!m_movie.Success) { Response.Write("!!!!!内容匹配失败<br/>"); } string title = m_movie.Groups["title"].Value; string intro = m_movie.Groups["intro"].Value; string director = m_movie.Groups["director"].Value; string actor = m_movie.Groups["actor"].Value; string location = m_movie.Groups["location"].Value; string url = m_movie.Groups["url"].Value; string year = m_movie.Groups["year"].Value; string tags = m_movie.Groups["tags"].Value; Response.Write("处理类别:" + location + "<br/>"); Class cls = ClassView.Find(string.Format("classname=N'{0}'", location)); if (cls.ID <= 0) { cls.Alter = location; cls.ClassKeywords = location + "在线观看"; cls.ClassName = location; cls.IsLeafClass = true; cls.ShowInNav = true; cls.ClassForder = location; cls.ModelID = 6; ClassView.Insert(cls); } MovieInfo mv = new MovieInfo(); mv.Actors = actor; mv.ClassID = cls.ID; mv.ClassName = cls.ClassName; mv.ClickCount = 0; mv.Director = director; mv.Enable = true; mv.InsertTime = DateTime.Now; mv.Intro = intro; mv.IsMove = true; mv.Location = location; mv.PublicYear = year; mv.ReplyCount = 0; mv.ScoreAvg = 10; mv.ScoreTime = 0; mv.Status = 1; mv.Tags = tags; mv.Title = title; mv.TjCount = 0; mv.UpdateTime = DateTime.Now; Response.Write("保存:" + title + "<br/>"); MovieInfoView.Insert(mv); //设置封面 Response.Write("设置封面<br/>"); mv.FaceImage = string.Format("/u/MoviekFace/{0}.jpg", mv.Id); try { Voodoo.IO.File.Move(Server.MapPath("~/config/movieface.jpg"), Server.MapPath(mv.FaceImage)); } catch { Voodoo.IO.File.Copy(Server.MapPath("~/config/0.jpg"), Server.MapPath(mv.FaceImage)); } MovieInfoView.Update(mv); //添加地址 Response.Write("添加地址:" + url + "<br/>"); MovieUrlKuaib mk = new MovieUrlKuaib(); mk.Enable = true; mk.MovieID = mv.Id; mk.MovieTitle = mv.Title; mk.Title = "全集"; mk.UpdateTime = DateTime.Now; mk.Url = url; MovieUrlKuaibView.Insert(mk); //生成 Response.Write("生成<br/>"); //CreatePage.CreateDramapage(mk,cls); //CreatePage.CreateContentPage(mv,cls); //CreatePage.CreateListPage(cls,0); //CreatePage.GreateIndexPage(); Response.Write(title + "-完成<br/><br/><br/>"); m_list = m_list.NextMatch(); } //处理列表下一页 Match m_next = html_List.GetMatchGroup("<a href='(?<key>[^'/]*?)'>下一页</a>"); if (m_next.Success) { listUrl = m_next.Groups["key"].Value.AppendToDomain(listUrl); goto openurl; } }