public void CollectKuaiboMovie(MovieInfo m, MovieRule r, string url, string Title) { string html = Url.GetHtml(url, r.Encoding); Match match = html.GetMatchGroup(r.KuaibDramaRule); if (match.Success && !r.KuaibDramaRule.IsNullOrEmpty()) { MovieUrlKuaib drama = new MovieUrlKuaib(); drama.Enable = true; drama.MovieID = m.id; drama.MovieTitle = m.Title; drama.Title = Title.IsNull(match.Groups["title"].Value); drama.UpdateTime = DateTime.Now; drama.Url = match.Groups["url"].Value; using (kuaiboyingshiEntities ent = new kuaiboyingshiEntities()) { var dramas = (from l in ent.MovieUrlKuaib where l.MovieID == m.id && l.MovieTitle == drama.Title select l).ToList(); if (dramas.Count == 0) { ent.AddToMovieUrlKuaib(drama); ent.SaveChanges(); } } } else { Match m_source = html.GetMatchGroup(r.DramaPageKuaibRule); if (m_source.Success) { CollectSources(r, m_source.Groups["source"].Value.AppendToDomain(url), m); } } }
/// <summary> /// 快播 /// </summary> /// <param name="id"></param> protected void Kuaib(int id) { MovieUrlKuaib k = MovieUrlKuaibView.GetModelByID(id.ToS()); Response.Clear(); Response.Write(CreateDramapage(k, MovieInfoView.GetClass(k))); }
public string GetMovieDramaUrl(MovieUrlKuaib b, Class cls) { if (b == null) { return(""); } using (DataEntities ent = new DataEntities()) { MovieInfo movie = (from l in ent.MovieInfo where l.id == b.MovieID select l).FirstOrDefault(); string result = ""; string sitrurl = "/Movie/"; result = string.Format("{0}{1}/{2}/Kuaib/{3}{4}", sitrurl, cls.ClassForder, TitleFilter(movie.Title.Replace("/", "_")), b.id, BasePage.SystemSetting.ExtName ); result = Regex.Replace(result, "[/]{2,}", "/"); result = result.Replace(":", "_"); result = result.Replace(">", ""); result = result.Replace("<", ""); result = result.Replace("*", ""); result = result.Replace("?", ""); result = result.Replace("|", "_"); return(result); } }
public static string GetMovieDramaUrl(MovieUrlKuaib b, Class cls) { if (b == null) { return(""); } MovieInfo movie = MovieInfoView.GetModelByID(b.MovieID.ToS()); string result = ""; string sitrurl = "/Movie/"; result = string.Format("{0}{1}/{2}/Kuaib/{3}{4}", sitrurl, cls.ClassForder, TitleFilter(movie.Title.Replace("/", "_")), b.Id, BasePage.SystemSetting.ExtName ); result = Regex.Replace(result, "[/]{2,}", "/"); result = result.Replace(":", "_"); result = result.Replace(">", ""); result = result.Replace("<", ""); result = result.Replace("*", ""); result = result.Replace("?", ""); result = result.Replace("|", "_"); return(result); }
public static MovieInfo GetMovie(this MovieUrlKuaib kuaib) { using (DataEntities ent = new DataEntities()) { return((from l in ent.MovieInfo where l.id == kuaib.MovieID select l).FirstOrDefault()); } }
/// <summary> /// 生成播放页面--快播 /// </summary> /// <param name="kuaib">快播地址</param> /// <param name="cls">分类</param> public static void CreateDramapage(MovieUrlKuaib kuaib, Class cls) { TemplateHelper h = new TemplateHelper(); string FileName = BasePage.GetMovieDramaUrl(kuaib, cls); Voodoo.IO.File.Write(System.Web.HttpContext.Current.Server.MapPath("~" + FileName), h.CreateDramapage(kuaib, cls)); ping(BasePage.SystemSetting.SiteUrl.TrimEnd('/') + FileName); CreatePagesByCrateWith(4); }
protected void SaveDramas(int MovieID, List <Drama> dramas) { if (dramas.Count == 0) { return; } using (DataEntities ent = new DataEntities()) { MovieInfo mv = //MovieInfoView.GetModelByID(MovieID.ToS()); (from l in ent.MovieInfo where l.id == MovieID select l).FirstOrDefault(); List <MovieUrlBaidu> baidus = new List <MovieUrlBaidu>(); List <MovieUrlKuaib> kuaibos = new List <MovieUrlKuaib>(); if (dramas[0].Type == "baidu") { baidus = //MovieUrlBaiduView.GetModelList(string.Format("movieid={0}", MovieID)); (from l in ent.MovieUrlBaidu where l.MovieID == MovieID select l).ToList(); foreach (var drama in dramas) { if (baidus.Where(p => p.Title == drama.Title).Count() == 0) { MovieUrlBaidu m = new MovieUrlBaidu(); m.Enable = true; m.MovieID = mv.id; m.MovieTitle = mv.Title; m.Title = drama.Title; m.UpdateTime = DateTime.UtcNow.AddHours(8); m.Url = drama.Url; ent.AddToMovieUrlBaidu(m); } } } else { kuaibos = //MovieUrlKuaibView.GetModelList(string.Format("movieid={0}", MovieID)); (from l in ent.MovieUrlKuaib where l.MovieID == MovieID select l).ToList(); foreach (var drama in dramas) { if (kuaibos.Where(p => p.Title == drama.Title).Count() == 0) { MovieUrlKuaib m = new MovieUrlKuaib(); m.Enable = true; m.MovieID = mv.id; m.MovieTitle = mv.Title; m.Title = drama.Title; m.UpdateTime = DateTime.UtcNow.AddHours(8); m.Url = drama.Url; ent.AddToMovieUrlKuaib(m); } } } ent.SaveChanges(); } }
/// <summary> /// 快播 /// </summary> /// <param name="id"></param> protected void Kuaib(int id) { DataEntities ent = new DataEntities(); MovieUrlKuaib k = (from l in ent.MovieUrlKuaib where l.id == id select l).FirstOrDefault(); ent.Dispose(); Response.Clear(); Response.Write(CreateDramapage(k, k.GetClass())); }
/// <summary> /// 获取快播上一集地址 /// </summary> /// <param name="kuai"></param> /// <returns></returns> public static MovieUrlKuaib GetPreKuaibo(MovieUrlKuaib kuai) { List <MovieUrlKuaib> lresult = MovieUrlKuaibView.GetModelList(string.Format("MovieID={0} and id<{1} order by id desc", kuai.MovieID, kuai.Id)); if (lresult.Count == 0) { return(null); } else { return(lresult.First()); } }
/// <summary> /// 生成快播页面 /// </summary> /// <param name="id"></param> protected void CreateKuaiboPage(long id) { MovieUrlKuaib k = MovieUrlKuaibView.GetModelByID(id.ToS()); if (k.Id > 0) { Class c = MovieInfoView.GetClass(k); Voodoo.Basement.CreatePage.CreateDramapage(k, c); Response.Write(string.Format("《{0}》-快播剧集《{1}》完成", k.MovieTitle, k.Title)); } else { Response.Write("不存在"); } }
protected void SaveDramas(int MovieID, List <Drama> dramas) { if (dramas.Count == 0) { return; } MovieInfo mv = MovieInfoView.GetModelByID(MovieID.ToS()); List <MovieUrlBaidu> baidus = new List <MovieUrlBaidu>(); List <MovieUrlKuaib> kuaibos = new List <MovieUrlKuaib>(); if (dramas[0].Type == "baidu") { baidus = MovieUrlBaiduView.GetModelList(string.Format("movieid={0}", MovieID)); foreach (var drama in dramas) { if (baidus.Where(p => p.Title == drama.Title).Count() == 0) { MovieUrlBaidu m = new MovieUrlBaidu(); m.Enable = true; m.MovieID = mv.Id; m.MovieTitle = mv.Title; m.Title = drama.Title; m.UpdateTime = DateTime.UtcNow.AddHours(8); m.Url = drama.Url; MovieUrlBaiduView.Insert(m); } } } else { kuaibos = MovieUrlKuaibView.GetModelList(string.Format("movieid={0}", MovieID)); foreach (var drama in dramas) { if (kuaibos.Where(p => p.Title == drama.Title).Count() == 0) { MovieUrlKuaib m = new MovieUrlKuaib(); m.Enable = true; m.MovieID = mv.Id; m.MovieTitle = mv.Title; m.Title = drama.Title; m.UpdateTime = DateTime.UtcNow.AddHours(8); m.Url = drama.Url; MovieUrlKuaibView.Insert(m); } } } }
/// <summary> /// 获取快播上一集地址 /// </summary> /// <param name="kuai"></param> /// <returns></returns> public static MovieUrlKuaib GetPreKuaibo(MovieUrlKuaib kuai) { using (DataEntities ent = new DataEntities()) { List <MovieUrlKuaib> lresult = //MovieUrlKuaibView.GetModelList(string.Format("MovieID={0} and id<{1} order by id desc", kuai.MovieID, kuai.Id)); (from l in ent.MovieUrlKuaib where l.MovieID == kuai.MovieID && l.id < kuai.id orderby l.id descending select l).ToList(); if (lresult.Count == 0) { return(null); } else { return(lresult.First()); } } }
/// <summary> /// 将修改过的实体修改到数据库 /// </summary> /// <param name="M">赋值后的实体</param> /// <returns></returns> public static int Update(MovieUrlKuaib M) { IDbHelper Sql = GetHelper(); StringBuilder sb = new StringBuilder(); sb.Append("update [MovieUrlKuaib] set "); sb.Append("[MovieID]=" + M.MovieID.ToS()); sb.Append(","); sb.Append("[MovieTitle]=N'" + M.MovieTitle + "'"); sb.Append(","); sb.Append("[Title]=N'" + M.Title + "'"); sb.Append(","); sb.Append("[UpdateTime]=N'" + M.UpdateTime + "'"); sb.Append(","); sb.Append("[Enable]=" + M.Enable.ToS()); sb.Append(","); sb.Append("[Url]=N'" + M.Url + "'"); sb.Append(" where Id='" + M.Id + "'"); sb.Append(""); if (DataBase.CmsDbType == DataBase.DbType.SqlServer) { sb.Append(";select @@ROWCOUNT"); } if (DataBase.CmsDbType == DataBase.DbType.SQLite) { sb.Append(";select 0"); } if (DataBase.CmsDbType == DataBase.DbType.MySql) { sb.Append(";SELECT ROW_COUNT()"); } if (DataBase.CmsDbType == DataBase.DbType.Access) { sb.Append(";select 0"); } if (DataBase.CmsDbType == DataBase.DbType.Oracle) { sb.Append(";select SQL%ROWCOUNT"); } return(Sql.ExecuteScalar(CommandType.Text, sb.ToString()).ToInt32()); }
/// <summary> /// 生成快播页面 /// </summary> /// <param name="id"></param> protected void CreateKuaiboPage(long id) { DataEntities ent = new DataEntities(); MovieUrlKuaib k = (from l in ent.MovieUrlKuaib where l.id == id select l).FirstOrDefault(); if (k.id > 0) { Class c = k.GetClass(); Voodoo.Basement.CreatePage.CreateDramapage(k, c); Response.Write(string.Format("《{0}》-快播剧集《{1}》完成", k.MovieTitle, k.Title)); } else { Response.Write("不存在"); } ent.Dispose(); }
/// <summary> /// 将数据插入表 /// </summary> /// <param name="M">赋值后的实体</param> /// <returns></returns> public static void Insert(MovieUrlKuaib M) { IDbHelper Sql = GetHelper(); StringBuilder sb = new StringBuilder(); sb.Append("insert into [MovieUrlKuaib]([MovieID],[MovieTitle],[Title],[UpdateTime],[Enable],[Url]) values("); sb.Append(M.MovieID.ToS()); sb.Append(","); sb.Append("N'" + M.MovieTitle + "'"); sb.Append(","); sb.Append("N'" + M.Title + "'"); sb.Append(","); sb.Append("N'" + M.UpdateTime + "'"); sb.Append(","); sb.Append(M.Enable.ToS()); sb.Append(","); sb.Append("N'" + M.Url + "'"); sb.Append(")"); if (DataBase.CmsDbType == DataBase.DbType.SqlServer) { sb.Append(";select @@Identity"); } if (DataBase.CmsDbType == DataBase.DbType.SQLite) { sb.Append(";select last_insert_rowid()"); } if (DataBase.CmsDbType == DataBase.DbType.MySql) { sb.Append(";select LAST_INSERT_ID()"); } if (DataBase.CmsDbType == DataBase.DbType.Access) { sb.Append(";select max(id) from MovieUrlKuaib"); } if (DataBase.CmsDbType == DataBase.DbType.Oracle) { sb.Append(";select LAST_INSERT_ID()"); } M.Id = Sql.ExecuteScalar(CommandType.Text, sb.ToString()).ToInt32(); }
/// <summary> /// DataTable转换为list /// </summary> /// <param name="dt"></param> /// <returns></returns> protected static List <MovieUrlKuaib> DataTableToList(DataTable dt) { List <MovieUrlKuaib> Ms = new List <MovieUrlKuaib>(); for (int i = 0; i < dt.Rows.Count; i++) { MovieUrlKuaib M = new MovieUrlKuaib(); M.Id = dt.Rows[i]["id"].ToInt64(); M.MovieID = dt.Rows[i]["MovieID"].ToInt32(); M.MovieTitle = dt.Rows[i]["MovieTitle"].ToString(); M.Title = dt.Rows[i]["Title"].ToString(); M.UpdateTime = dt.Rows[i]["UpdateTime"].ToDateTime(); M.Enable = dt.Rows[i]["Enable"].ToBoolean(); M.Url = dt.Rows[i]["Url"].ToString(); Ms.Add(M); } return(Ms); }
/// <summary> /// 获取快播下一集地址 /// </summary> /// <param name="kuai"></param> /// <returns></returns> public static MovieUrlKuaib GetNextKuaibo(MovieUrlKuaib kuai) { if (kuai == null) { return(new MovieUrlKuaib() { Id = int.MinValue }); } List <MovieUrlKuaib> lresult = MovieUrlKuaibView.GetModelList(string.Format("MovieID={0} and id>{1} order by id asc", kuai.MovieID, kuai.Id)); if (lresult.Count == 0) { return(null); } else { return(lresult.First()); } }
/// <summary> /// 获取快播下一集地址 /// </summary> /// <param name="kuai"></param> /// <returns></returns> public static MovieUrlKuaib GetNextKuaibo(MovieUrlKuaib kuai) { if (kuai == null) { return(new MovieUrlKuaib() { id = int.MinValue }); } using (DataEntities ent = new DataEntities()) { List <MovieUrlKuaib> lresult = //MovieUrlKuaibView.GetModelList(string.Format("MovieID={0} and id>{1} order by id asc", kuai.MovieID, kuai.Id)); (from l in ent.MovieUrlKuaib where l.MovieID == kuai.MovieID && l.id > kuai.id orderby l.id select l).ToList(); if (lresult.Count == 0) { return(null); } else { return(lresult.First()); } } }
/// <summary> /// 根据条件语句取得第一个实体 /// </summary> /// <param name="m_where">条件语句,不包含“where”</param> /// <returns></returns> public static MovieUrlKuaib Find(string m_where) { IDbHelper Sql = GetHelper(); MovieUrlKuaib M = new MovieUrlKuaib(); DbDataReader Rs = Sql.ExecuteReader(CommandType.Text, "select [id],[MovieID],[MovieTitle],[Title],[UpdateTime],[Enable],[Url] from [MovieUrlKuaib] where " + m_where, true); if (!Rs.Read()) { M.Id = long.MinValue; } else { M.Id = Rs["id"].ToInt64(); M.MovieID = Rs["MovieID"].ToInt32(); M.MovieTitle = Rs["MovieTitle"].ToString(); M.Title = Rs["Title"].ToString(); M.UpdateTime = Rs["UpdateTime"].ToDateTime(); M.Enable = Rs["Enable"].ToBoolean(); M.Url = Rs["Url"].ToString(); } Rs.Close(); Rs = null; return(M); }
public static string GetMovieDramaUrl(MovieUrlKuaib b, Class cls) { return(GetConverter().GetMovieDramaUrl(b, cls)); }
public string GetMovieDramaUrl(MovieUrlKuaib b, Class cls) { if (b == null) { return ""; } using (DataEntities ent = new DataEntities()) { MovieInfo movie = (from l in ent.MovieInfo where l.id == b.MovieID select l).FirstOrDefault(); string result = ""; string sitrurl = "/Movie/"; result = string.Format("{0}{1}/{2}/Kuaib/{3}{4}", sitrurl, cls.ClassForder, TitleFilter(movie.Title.Replace("/", "_")), b.id, BasePage.SystemSetting.ExtName ); result = Regex.Replace(result, "[/]{2,}", "/"); result = result.Replace(":", "_"); result = result.Replace(">", ""); result = result.Replace("<", ""); result = result.Replace("*", ""); result = result.Replace("?", ""); result = result.Replace("|", "_"); return result; } }
public string GetMovieDramaUrl(MovieUrlKuaib b, Class cls) { return(string.Format("/Dynamic/Movie/?a=kuaib&id={0}", b.id)); }
/// <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; } }
public static MovieUrlKuaib CreateMovieUrlKuaib(long id) { MovieUrlKuaib movieUrlKuaib = new MovieUrlKuaib(); movieUrlKuaib.id = id; return movieUrlKuaib; }
public void AddToMovieUrlKuaib(MovieUrlKuaib movieUrlKuaib) { base.AddObject("MovieUrlKuaib", movieUrlKuaib); }
public static Class GetClass(MovieUrlKuaib mu) { return(ClassView.GetModelByID(MovieInfoView.GetModelByID(mu.MovieID.ToS()).ClassID.ToS())); }