/// <summary> /// NewTask委托的预处理 /// </summary> public void NewTaskPreprocessor(object e) { ParaNewTask p = (ParaNewTask)e; TaskInfo sourcetask = p.SourceTask; IPlugin plugin = p.Plugin; string url = p.Url; //检查参数有效性 if (!plugin.CheckUrl(url) || sourcetask == null || plugin == null || string.IsNullOrEmpty(url)) { return; } //取得此url的hash string hash = plugin.GetHash(url); //检查是否有已经在进行的相同任务 foreach (TaskInfo t in CoreManager.TaskManager.TaskInfos) { if (hash == t.Hash) { //如果有则不新建此任务 //将状态由停止或删除修改为开始 if (t.Status == DownloadStatus.出现错误 || t.Status == DownloadStatus.已经停止 || t.Status == DownloadStatus.已删除) { CoreManager.TaskManager.StartTask(t); } return; } } //设置新任务 TaskInfo task = CoreManager.TaskManager.AddTask(plugin, url, sourcetask.Proxy); task.Settings = CloneDictionary(sourcetask.Settings); task.DownloadTypes = sourcetask.DownloadTypes; task.Comment = sourcetask.Comment; task.SaveDirectory = sourcetask.SaveDirectory; task.AutoAnswer = sourcetask.AutoAnswer; task.ExtractCache = sourcetask.ExtractCache; //此任务由其他任务所添加 task.IsBeAdded = true; //开始新任务 CoreManager.TaskManager.StartTask(task); //调用UI层的NewTask委托 if (CoreManager.UIDelegates.NewTask != null) { CoreManager.UIDelegates.NewTask(p); } }
// private bool InfoPaser (JiyingDmVideoInfo info, string js_src) // { // List<string> result = new List<string>(js_src.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); // } private bool DownloadChapter(string source) { List <string> src = new List <string>(source.Split(new[] { '$' })); if (src.Count <= 0) { return(false); } string url = ""; string web = src[src.Count - 1]; if (web == "youku") { url = string.Format(@"http://v.youku.com/v_show/id_{0}", src[1]); } else if (web == "tudou") { List <string> sbusrc = new List <string>(src[1].Split(new[] { ',' })); url = string.Format(@"http://www.tudou.com/programs/view/{0}", sbusrc[1]); } else if (web == "qq") { } else if (web == "letv") { url = string.Format(@"http://www.letv.com/ptv/vplay/{0}.html", src[1]); } else if (web == "sohu") { url = string.Format(@"http://tv.sohu.com/20090211/{0}.shtml", src[1]); } else if (web == "cntv") { List <string> sbusrc = new List <string>(src[1].Split(new[] { '*' })); url = string.Format(@"http://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid={0}", sbusrc[2]); return(DownLoadCNTV(url)); } if (url.Length <= 0) { return(false); } //添加任务 ParaNewTask NewTask = new ParaNewTask(new FlvcdPlugin(), url, this.Info); CoreManager.TaskManager.NewTaskPreprocessor(NewTask); return(true); }
// private bool InfoPaser (Dm530VideoInfo info, string js_src) // { // List<string> result = new List<string>(js_src.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); // } private bool DownloadChapter(string source, string title_name) { List <string> src = new List <string>(source.Split(new[] { '$' })); if (src.Count <= 0) { return(false); } string url = ""; string web = src[src.Count - 1]; if (web == "youku") { url = string.Format(@"http://v.youku.com/v_show/id_{0}", src[1]); } else if (web == "tudou") { List <string> sbusrc = new List <string>(src[1].Split(new[] { ',' })); url = string.Format(@"http://www.tudou.com/programs/view/{0}", sbusrc[1]); } else if (web == "qq") { } else if (web == "letv") { url = string.Format(@"http://www.letv.com/ptv/vplay/{0}.html", src[1]); } else if (web == "sohu") { url = string.Format(@"http://tv.sohu.com/20090211/{0}.shtml", src[1]); } else if (web == "cntv") { List <string> sbusrc = new List <string>(src[1].Split(new[] { '*' })); url = string.Format(@"http://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid={0}", sbusrc[2]); string chaper_src = Network.GetHtmlSource(url, Encoding.GetEncoding("GBK"), Info.Proxy); Regex regChapter = new Regex("title\":\"(?<title>[^\"]+)"); Match item = regChapter.Match(chaper_src); if (item.Success == false) { return(false); } string title = item.Groups["title"].Value; regChapter = new Regex("url\":\"(?<vido_url>[^\"]+)"); List <string> partUrls = new List <string>(); foreach (Match match in regChapter.Matches(chaper_src)) { partUrls.Add(match.Groups["vido_url"].Value); } return(DownLoadFile(partUrls, title, title, "")); } else if (web == "hd_iask") { url = string.Format(@"http://p.you.video.sina.com.cn/swf/bokePlayer20140424_V4_1_42_43.swf?vid={0}", src[1]); } else if (web == "flv") { List <string> partUrls = new List <string>(); partUrls.Add(src[1]); DownLoadFile(partUrls, title_name, title_name + "-" + src[0], ".flv"); } if (url.Length <= 0) { return(false); } //添加任务 ParaNewTask NewTask = new ParaNewTask(new FlvcdPlugin(), url, this.Info); CoreManager.TaskManager.NewTaskPreprocessor(NewTask); return(true); }