public void CollectBaiduMovie(MovieInfo m, MovieRule r, string url, string Title) { string html = Url.GetHtml(url, r.Encoding); Match match = html.GetMatchGroup(r.BaiduDramaRule); if (match.Success && !r.BaiduDramaRule.IsNullOrEmpty() && !match.Groups["url"].Value.IsNullOrEmpty()) { MovieUrlBaidu drama = new MovieUrlBaidu(); 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.MovieUrlBaidu where l.MovieID == m.id && l.MovieTitle == drama.Title select l).ToList(); if (dramas.Count == 0) { ent.AddToMovieUrlBaidu(drama); ent.SaveChanges(); } } } else { Match m_source = html.GetMatchGroup(r.DramaPageBaiduRule); if (m_source.Success) { CollectSources(r, m_source.Groups["source"].Value.AppendToDomain(url), m); } } }
public static MovieInfo GetMovie(this MovieUrlBaidu baidu) { using (DataEntities ent = new DataEntities()) { return((from l in ent.MovieInfo where l.id == baidu.MovieID select l).FirstOrDefault()); } }
/// <summary> /// 百度 /// </summary> /// <param name="id"></param> protected void Baidu(int id) { MovieUrlBaidu b = MovieUrlBaiduView.GetModelByID(id.ToS()); Response.Clear(); Response.Write(CreateDramapage(b, MovieInfoView.GetClass(b))); }
/// <summary> /// 获取影视地址 /// </summary> /// <param name="qs"></param> /// <param name="cls"></param> /// <returns></returns> public string GetMovieDramaUrl(MovieUrlBaidu b, Class cls) { if (b == null) { return(""); } string result = ""; string sitrurl = "/Movie/"; result = string.Format("{0}{1}/{2}/Baidu/{3}{4}", sitrurl, cls.ClassForder, TitleFilter(b.MovieTitle), 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); }
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 Baidu(int id) { DataEntities ent = new DataEntities(); MovieUrlBaidu b = (from l in ent.MovieUrlBaidu where l.id == id select l).FirstOrDefault(); ent.Dispose(); Response.Clear(); Response.Write(CreateDramapage(b, b.GetClass())); }
/// <summary> /// 生成播放页面--快播 /// </summary> /// <param name="kuaib">百度影音地址</param> /// <param name="cls">分类</param> public static void CreateDramapage(MovieUrlBaidu 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); }
/// <summary> /// 获取百度下一集地址 /// </summary> /// <param name="kuai"></param> /// <returns></returns> public static MovieUrlBaidu GetNextBaidu(MovieUrlBaidu kuai) { List <MovieUrlBaidu> lresult = MovieUrlBaiduView.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()); } }
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="id"></param> protected void CreateBaiduPage(long id) { MovieUrlBaidu b = MovieUrlBaiduView.GetModelByID(id.ToS()); if (b.Id > 0) { Class c = MovieInfoView.GetClass(b); Voodoo.Basement.CreatePage.CreateDramapage(b, c); Response.Write(string.Format("《{0}》-百度影音剧集《{1}》完成", b.MovieTitle, b.Title)); } else { Response.Write("不存在"); } }
/// <summary> /// 获取百度下一集地址 /// </summary> /// <param name="kuai"></param> /// <returns></returns> public static MovieUrlBaidu GetNextBaidu(MovieUrlBaidu kuai) { using (DataEntities ent = new DataEntities()) { List <MovieUrlBaidu> lresult = //MovieUrlBaiduView.GetModelList(string.Format("MovieID={0} and id>{1} order by id asc", kuai.MovieID, kuai.Id)); (from l in ent.MovieUrlBaidu 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">赋值后的实体</param> /// <returns></returns> public static int Update(MovieUrlBaidu M) { IDbHelper Sql = GetHelper(); StringBuilder sb = new StringBuilder(); sb.Append("update [MovieUrlBaidu] 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 CreateBaiduPage(long id) { DataEntities ent = new DataEntities(); MovieUrlBaidu b = (from l in ent.MovieUrlBaidu where l.id == id select l).FirstOrDefault(); if (b.id > 0) { Class c = b.GetClass(); Voodoo.Basement.CreatePage.CreateDramapage(b, c); Response.Write(string.Format("《{0}》-百度影音剧集《{1}》完成", b.MovieTitle, b.Title)); } else { Response.Write("不存在"); } ent.Dispose(); }
/// <summary> /// 将数据插入表 /// </summary> /// <param name="M">赋值后的实体</param> /// <returns></returns> public static void Insert(MovieUrlBaidu M) { IDbHelper Sql = GetHelper(); StringBuilder sb = new StringBuilder(); sb.Append("insert into [MovieUrlBaidu]([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 MovieUrlBaidu"); } 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 <MovieUrlBaidu> DataTableToList(DataTable dt) { List <MovieUrlBaidu> Ms = new List <MovieUrlBaidu>(); for (int i = 0; i < dt.Rows.Count; i++) { MovieUrlBaidu M = new MovieUrlBaidu(); 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="m_where">条件语句,不包含“where”</param> /// <returns></returns> public static MovieUrlBaidu Find(string m_where) { IDbHelper Sql = GetHelper(); MovieUrlBaidu M = new MovieUrlBaidu(); DbDataReader Rs = Sql.ExecuteReader(CommandType.Text, "select [id],[MovieID],[MovieTitle],[Title],[UpdateTime],[Enable],[Url] from [MovieUrlBaidu] 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 void AddToMovieUrlBaidu(MovieUrlBaidu movieUrlBaidu) { base.AddObject("MovieUrlBaidu", movieUrlBaidu); }
public static Class GetClass(MovieUrlBaidu mu) { return(ClassView.GetModelByID(MovieInfoView.GetModelByID(mu.MovieID.ToS()).ClassID.ToS())); }
/// <summary> /// 获取影视地址 /// </summary> /// <param name="qs"></param> /// <param name="cls"></param> /// <returns></returns> public static string GetMovieDramaUrl(MovieUrlBaidu b, Class cls) { return(GetConverter().GetMovieDramaUrl(b, cls)); }
/// <summary> /// 获取影视地址 /// </summary> /// <param name="qs"></param> /// <param name="cls"></param> /// <returns></returns> public string GetMovieDramaUrl(MovieUrlBaidu b, Class cls) { if (b == null) { return ""; } string result = ""; string sitrurl = "/Movie/"; result = string.Format("{0}{1}/{2}/Baidu/{3}{4}", sitrurl, cls.ClassForder, TitleFilter(b.MovieTitle), 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; }
/// <summary> /// 获取影视地址 /// </summary> /// <param name="qs"></param> /// <param name="cls"></param> /// <returns></returns> public string GetMovieDramaUrl(MovieUrlBaidu b, Class cls) { return(string.Format("/Dynamic/Movie/?a=baidu&id={0}", b.id)); }
public static MovieUrlBaidu CreateMovieUrlBaidu(long id) { MovieUrlBaidu movieUrlBaidu = new MovieUrlBaidu(); movieUrlBaidu.id = id; return movieUrlBaidu; }