public static CookieContainer Get115Cookie() { CookieContainer cc = new CookieContainer(); var sessionCookie = ScanDataBaseManager.GetOneOneFiveCookie(); if (sessionCookie != null && !string.IsNullOrEmpty(sessionCookie.OneOneFiveCookie)) { List <CookieItem> sessionCookieItems = JsonConvert.DeserializeObject <List <CookieItem> >(sessionCookie.OneOneFiveCookie); foreach (var item in sessionCookieItems) { Cookie temp = new Cookie(item.Name, item.Value, "/", "115.com"); cc.Add(temp); } } //cookieData = new ChromeCookieReader().ReadCookies("webapi.115.com"); //foreach (var item in cookieData.Where(x => !x.Value.Contains(",")).Distinct()) //{ // Cookie c = new Cookie(item.Name, item.Value, "/", "115.com"); // cc.Add(c); //} //var tempCc = HtmlManager.GetCookies("http://www.115.com", "utf-8", cc); return(cc); }
public JsonResult Add115Task(string mag) { CookieContainer cc = new CookieContainer(); bool ret = false; string msg = ""; foreach (var t in JsonConvert.DeserializeObject <List <CookieItem> >(ScanDataBaseManager.GetOneOneFiveCookie().OneOneFiveCookie)) { Cookie c = new Cookie(t.Name, t.Value, "/", "115.com"); cc.Add(c); } var split = mag.Split(new string[] { "magnet:?" }, StringSplitOptions.None).Where(x => !string.IsNullOrEmpty(x)); Dictionary <string, string> param = new Dictionary <string, string>(); if (split.Count() <= 1) { param.Add("url", mag); } else { int index = 0; foreach (var s in split) { param.Add(string.Format("url[{0}]", index), "magnet:?" + s); index++; } } param.Add("sign", ""); param.Add("uid", "340200422"); param.Add("time", DateTime.Now.ToFileTimeUtc() + ""); var returnStr = ""; if (split.Count() <= 1) { returnStr = HtmlManager.Post("https://115.com/web/lixian/?ct=lixian&ac=add_task_url", param, cc); } else { returnStr = HtmlManager.Post("https://115.com/web/lixian/?ct=lixian&ac=add_task_urls", param, cc); } if (!string.IsNullOrEmpty(returnStr)) { var data = Newtonsoft.Json.Linq.JObject.Parse(returnStr); bool.TryParse(data.Property("state").Value.ToString(), out ret); if (ret == false) { msg = data.Property("error_msg").Value.ToString(); } } if (string.IsNullOrEmpty(msg)) { msg = "下载成功"; } return(Json(new { status = ret, msg = msg }, JsonRequestBehavior.AllowGet)); }