/// <summary> /// 刷新数据 /// </summary> /// <returns>刷新数据后的实例</returns> public Article Refresh() { GetRealTime(); string str = Bas.GetHTTPBody("https://member.bilibili.com/x/h5/data/article", Account.Instance.Cookies, "https://member.bilibili.com/studio/gabriel/data-center/overview"); if (!string.IsNullOrEmpty(str)) { try { Article_Data_Template obj = JsonConvert.DeserializeObject <Article_Data_Template>(str); if (obj.code == 0) { coin = obj.data.stat.coin; coin_incr = obj.data.stat.incr_coin; fav = obj.data.stat.fav; fav_incr = obj.data.stat.incr_fav; like = obj.data.stat.like; like_incr = obj.data.stat.incr_like; reply = obj.data.stat.reply; reply_incr = obj.data.stat.incr_reply; share = obj.data.stat.share; share_incr = obj.data.stat.incr_share; view = obj.data.stat.view; view_incr = obj.data.stat.incr_view; } } catch { } } return(this); }
private void Refresh(object state) { string str = Bas.GetHTTPBody("https://member.bilibili.com/x/app/h5/activity/videoall?platform=ios", Account.Instance.Cookies); if (!string.IsNullOrEmpty(str)) { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { Dispatcher?.Invoke(() => { EventList.Children.Clear(); }); foreach (JToken i in obj["data"]) { Dispatcher.Invoke(() => { EventList.Children.Add(new EventItem(new EventItem.EventInfo() { Title = i["name"].ToString(), Desc = i["protocol"].ToString(), Link = i["act_url"].ToString(), Start_Time = i["stime"].ToString(), End_Time = "-" })); }); } } } }
/// <summary> /// 获取用户信息 /// </summary> public void GetInfo(object o = null) { if (Islogin) { string str = Bas.GetHTTPBody("https://api.bilibili.com/x/space/myinfo", Cookies); if (!string.IsNullOrEmpty(str)) { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { Pic = obj["data"]["face"].ToString(); UName = obj["data"]["name"].ToString(); Desc = obj["data"]["sign"].ToString(); Level = (int)obj["data"]["level_exp"]["current_level"]; if ((double)obj["data"]["level_exp"]["next_exp"] != -1) { ExpProgress = ((double)obj["data"]["level_exp"]["current_exp"] - (double)obj["data"]["level_exp"]["current_min"]) / ((double)obj["data"]["level_exp"]["next_exp"] - (double)obj["data"]["level_exp"]["current_min"]); str_ExpProgress = $"{obj["data"]["level_exp"]["current_exp"].ToString()}/{obj["data"]["level_exp"]["next_exp"].ToString()}"; } else { ExpProgress = 1; str_ExpProgress = $"{obj["data"]["level_exp"]["current_exp"].ToString()}/{obj["data"]["level_exp"]["current_min"].ToString()}"; } } } } }
/// <summary> /// 获得充电数据 /// </summary> /// <returns>电池数</returns> private double GetCharge() { string str = Bas.GetHTTPBody("https://member.bilibili.com/x/web/elec/balance", Account.Instance.Cookies); if (!string.IsNullOrEmpty(str)) { try { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { return((double)obj["data"]["wallet"]["sponsorBalance"]); } else { return(-1); } } catch { return(-1); } } else { return(-1); } }
/// <summary> /// 刷新数据 /// </summary> /// <returns>刷新数据后的实例</returns> public Article Refresh() { GetRealTime(); string str = Bas.GetHTTPBody("https://member.bilibili.com/x/h5/data/article", Bas.account.Cookies, "https://member.bilibili.com/studio/gabriel/data-center/overview"); if (!string.IsNullOrEmpty(str)) { try { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { coin = (int)obj["data"]["stat"]["coin"]; coin_incr = (int)obj["data"]["stat"]["incr_coin"]; fav = (int)obj["data"]["stat"]["fav"]; fav_incr = (int)obj["data"]["stat"]["incr_fav"]; like = (int)obj["data"]["stat"]["like"]; like_incr = (int)obj["data"]["stat"]["incr_like"]; reply = (int)obj["data"]["stat"]["reply"]; reply_incr = (int)obj["data"]["stat"]["incr_reply"]; share = (int)obj["data"]["stat"]["share"]; share_incr = (int)obj["data"]["stat"]["incr_share"]; view = (int)obj["data"]["stat"]["view"]; view_incr = (int)obj["data"]["stat"]["incr_view"]; } } catch { } } return(this); }
/// <summary> /// 刷新数据 /// </summary> /// <returns>刷新后的实例</returns> public Video Refresh() { GetRealTime(); string str = Bas.GetHTTPBody("https://member.bilibili.com/x/h5/data/overview?type=0", Account.Instance.Cookies, "https://member.bilibili.com/studio/gabriel/data-center/overview"); if (!string.IsNullOrEmpty(str)) { try { Video_Data_Template obj = JsonConvert.DeserializeObject <Video_Data_Template>(str); if (obj.code == 0) { coin = obj.data.stat.coin; coin_incr = obj.data.stat.coin - obj.data.stat.coin_last; comment = obj.data.stat.comment; comment_incr = obj.data.stat.comment - obj.data.stat.comment_last; dm = obj.data.stat.dm; dm_incr = obj.data.stat.dm - obj.data.stat.dm_last; fav = obj.data.stat.fav; fav_incr = obj.data.stat.fav - obj.data.stat.fav_last; like = obj.data.stat.like; like_incr = obj.data.stat.like - obj.data.stat.like_last; play = obj.data.stat.play; play_incr = obj.data.stat.play - obj.data.stat.play_last; share = obj.data.stat.share; share_incr = obj.data.stat.share - obj.data.stat.share_last; fan = obj.data.stat.fan; fan_incr = obj.data.stat.fan - obj.data.stat.fan_last; double tmp1 = GetCharge(); elec = tmp1 == -1 ? obj.data.stat.elec : tmp1; elec_incr = obj.data.stat.elec - obj.data.stat.elec_last; elec_total = obj.data.stat.elec; } } catch { } } double[] tmp = GetGrowUp(); if (tmp != new double[2] { -1, -1 }) { growup_incr = tmp[0]; growup = tmp[1]; } return(this); }
/// <summary> /// 刷新数据 /// </summary> /// <returns>刷新后的实例</returns> public Video Refresh() { GetRealTime(); string str = Bas.GetHTTPBody("https://member.bilibili.com/x/h5/data/overview?type=0", Bas.account.Cookies, "https://member.bilibili.com/studio/gabriel/data-center/overview"); if (!string.IsNullOrEmpty(str)) { try { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { coin = (int)obj["data"]["stat"]["coin"]; coin_incr = (int)obj["data"]["stat"]["coin"] - (int)obj["data"]["stat"]["coin_last"]; comment = (int)obj["data"]["stat"]["comment"]; comment_incr = (int)obj["data"]["stat"]["comment"] - (int)obj["data"]["stat"]["comment_last"]; dm = (int)obj["data"]["stat"]["dm"]; dm_incr = (int)obj["data"]["stat"]["dm"] - (int)obj["data"]["stat"]["dm_last"]; fav = (int)obj["data"]["stat"]["fav"]; fav_incr = (int)obj["data"]["stat"]["fav"] - (int)obj["data"]["stat"]["fav_last"]; like = (int)obj["data"]["stat"]["like"]; like_incr = (int)obj["data"]["stat"]["like"] - (int)obj["data"]["stat"]["like_last"]; play = (int)obj["data"]["stat"]["play"]; play_incr = (int)obj["data"]["stat"]["play"] - (int)obj["data"]["stat"]["play_last"]; share = (int)obj["data"]["stat"]["share"]; share_incr = (int)obj["data"]["stat"]["share"] - (int)obj["data"]["stat"]["share_last"]; } fan = (int)obj["data"]["stat"]["fan"]; fan_incr = (int)obj["data"]["stat"]["fan"] - (int)obj["data"]["stat"]["fan_last"]; double tmp1 = GetCharge(); if (tmp1 != -1) { elec = tmp1; elec_incr = (double)obj["data"]["stat"]["elec"] - (double)obj["data"]["stat"]["elec_last"]; } } catch { } } double[] tmp = GetGrowUp(); if (tmp != new double[2] { -1, -1 }) { growup_incr = tmp[0]; growup = tmp[1]; } return(this); }
/// <summary> /// 注销账号 /// </summary> public void SignOut() { Bas.GetHTTPBody("https://passport.bilibili.com/login?act=exit", Cookies, ""); Islogin = false; if (ST.IsSavePassword) { ST = new AccountTable(ST.UserName, ST.PassWord); } else { ST = new AccountTable(ST.UserName); } Save(); }
/// <summary> /// 获取登陆二维码并显示 /// </summary> private void GetQrcode() { re: //获取二维码要包含的url string str = Bas.GetHTTPBody("https://passport.bilibili.com/qrcode/getLoginUrl", "", "https://passport.bilibili.com/login"); if (!string.IsNullOrEmpty(str)) { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { // 生成二维码的内容 string strCode = obj["data"]["url"].ToString(); QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(strCode, QRCodeGenerator.ECCLevel.Q); QRCode qrcode = new QRCode(qrCodeData); //生成二维码位图 Bitmap qrCodeImage = qrcode.GetGraphic(5, Color.Black, Color.White, null, 0, 6, false); qrcodeBox.Dispatcher.Invoke(delegate() { IntPtr myImagePtr = qrCodeImage.GetHbitmap(); //创建GDI对象,返回指针 BitmapSource imgsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(myImagePtr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); //创建imgSource WinAPIHelper.DeleteObject(myImagePtr); qrcodeBox.Source = imgsource; }); Monitor = new Timer(MonitorCallback, obj["data"]["oauthKey"].ToString(), 1000, 1000); Refresher = new Timer(RefresherCallback, null, 180000, Timeout.Infinite); } } else { goto re; } }
public void CheckUpdate(bool IsGUI = true) { IsFinished = false; string str = Bas.GetHTTPBody("https://cloud.api.zhangbudademao.com/117/Update"); if (!string.IsNullOrEmpty(str)) { try { jobj = JObject.Parse(str); if ((int)jobj["code"] == 0) { if (jobj["data"]["version"].ToString() == System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()) { if (IsGUI) { MessageBox.Show("当前版本已是最新"); } return; } else { if (IsGUI) { UpdateText = "当前版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\r\n最新版本:" + jobj["data"]["version"].ToString() + "(" + jobj["data"]["updatetime"].ToString() + "更新)\r\n\r\n更新内容:\r\n" + jobj["data"]["content"].ToString(); uw = (uw == null || uw.IsVisible == false) ? new UpdateWindow() : uw; uw.Show(); } else { Bas.notifyIcon.ShowToolTip("检查到新版本!请通过“检查更新”屏幕更新。"); } } } } catch { } } }
public void CheckUpdate(bool IsGUI = true) { IsFinished = false; string str = Bas.GetHTTPBody("https://cloud.api.zhangbudademao.com/117/Update"); if (!string.IsNullOrEmpty(str)) { try { jobj = JObject.Parse(str); if ((int)jobj["code"] == 0) { if ((int)jobj["data"]["build"] <= Bas.Build) { if (IsGUI) { MessageBox.Show("当前版本已是最新"); } return; } else { if (IsGUI) { UpdateText = "当前版本:" + Bas.Version + "\r\n最新版本:" + jobj["data"]["version"].ToString() + "(" + jobj["data"]["updatetime"].ToString() + "更新)\r\n\r\n更新内容:\r\n" + jobj["data"]["content"].ToString(); WindowsManager.Instance.GetWindow <UpdateWindow>().Show(); } else { NotifyIconHelper.Instance.ShowToolTip("检查到新版本!请通过“检查更新”屏幕更新。"); } } } } catch { } } }
/// <summary> /// 检查更新 /// </summary> public void CheckUpdate() { if (Plugins.Count > 0) { foreach (PluginInfo i in Plugins) { string str = Bas.GetHTTPBody(i.update_url); if (!string.IsNullOrEmpty(str)) { PluginInfo.UpdateInfo info = JsonConvert.DeserializeObject <PluginInfo.UpdateInfo>(str); if (info.code == 0) { if (info.data.version > i.version) { i.NeedUpdate = true; i.updateinfo = info.data; } } } } } }
/// <summary> /// 获得激励计划数据 /// </summary> /// <returns>[0]:前天收入;[1]:本月收入</returns> private double[] GetGrowUp() { string str = Bas.GetHTTPBody("https://api.bilibili.com/studio/growup/web/up/summary", Account.Instance.Cookies); if (!string.IsNullOrWhiteSpace(str)) { try { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { return(new double[2] { (double)obj["data"]["day_income"], (double)obj["data"]["income"] }); } else { return(new double[2] { -1, -1 }); } } catch { return(new double[2] { -1, -1 }); } } else { return(new double[2] { -1, -1 }); } }
/// <summary> /// 获取实时数据 /// </summary> private void GetRealTime() { //清除旧数据 _coin_real = 0; _fav_real = 0; _like_real = 0; _reply_real = 0; _share_real = 0; _view_real = 0; if (LastTime == null || DateTime.Compare(((DateTime)LastTime).AddDays(1), DateTime.Now) <= 0) { _coin_real_last = 0; _fav_real_last = 0; _like_real_last = 0; _reply_real_last = 0; _share_real_last = 0; _view_real_last = 0; } bool IsChangeLast = false; string str = Bas.GetHTTPBody("https://api.bilibili.com/x/article/creative/article/list?group=0&sort=&pn=1", Bas.account.Cookies, "https://member.bilibili.com/v2"); if (!string.IsNullOrEmpty(str)) { try { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { foreach (JToken i in obj["artlist"]["articles"]) { _coin_real += (int)i["stats"]["coin"]; _fav_real += (int)i["stats"]["favorite"]; _like_real += (int)i["stats"]["like"]; _reply_real += (int)i["stats"]["reply"]; _share_real += (int)i["stats"]["share"]; _view_real += (int)i["stats"]["view"]; if (LastTime == null || DateTime.Compare(((DateTime)LastTime).AddDays(1), DateTime.Now) <= 0) { _coin_real_last += (int)i["stats"]["coin"]; _fav_real_last += (int)i["stats"]["favorite"]; _like_real_last += (int)i["stats"]["like"]; _reply_real_last += (int)i["stats"]["reply"]; _share_real_last += (int)i["stats"]["share"]; _view_real_last += (int)i["stats"]["view"]; IsChangeLast = true; } } if ((int)obj["artlist"]["page"]["pn"] * (int)obj["artlist"]["page"]["ps"] > (int)obj["artlist"]["page"]["total"]) { int pn = 2; while (pn * (int)obj["artlist"]["page"]["ps"] <= (int)obj["artlist"]["page"]["total"]) { string str1 = Bas.GetHTTPBody("https://api.bilibili.com/x/article/creative/article/list?group=0&sort=&pn=" + pn, Bas.account.Cookies, "https://member.bilibili.com/v2"); if (!string.IsNullOrEmpty(str1)) { try { JObject obj1 = JObject.Parse(str1); if ((int)obj1["code"] == 0) { foreach (JToken i in obj1["artlist"]["articles"]) { _coin_real += (int)i["stats"]["coin"]; _fav_real += (int)i["stats"]["favorite"]; _like_real += (int)i["stats"]["like"]; _reply_real += (int)i["stats"]["reply"]; _share_real += (int)i["stats"]["share"]; _view_real += (int)i["stats"]["view"]; if (LastTime == null || DateTime.Compare(((DateTime)LastTime).AddDays(1), DateTime.Now) <= 0) { _coin_real_last += (int)i["stats"]["coin"]; _fav_real_last += (int)i["stats"]["favorite"]; _like_real_last += (int)i["stats"]["like"]; _reply_real_last += (int)i["stats"]["reply"]; _share_real_last += (int)i["stats"]["share"]; _view_real_last += (int)i["stats"]["view"]; } } } } catch { } } pn++; } } } if (IsChangeLast) { LastTime = DateTime.Now.Date.AddHours(12); //设定为当天12点数据 } } catch { } } }
/// <summary> /// 获取实时数据 /// </summary> private void GetRealTime() { //清除旧数据 _coin_real = 0; _dm_real = 0; _fav_real = 0; _like_real = 0; _play_real = 0; _share_real = 0; _comment_real = 0; if (LastTime == null || DateTime.Compare(((DateTime)LastTime).AddDays(1), DateTime.Now) <= 0) { _coin_real_last = 0; _dm_real_last = 0; _fav_real_last = 0; _like_real_last = 0; _play_real_last = 0; _share_real_last = 0; _comment_real_last = 0; _elec_last = GetCharge(); } bool IsChangeLast = false; string str = Bas.GetHTTPBody("https://member.bilibili.com/x/web/archives?status=is_pubing%2Cpubed%2Cnot_pubed&pn=1&ps=10&coop=1", Bas.account.Cookies, "https://member.bilibili.com/v2"); if (!string.IsNullOrEmpty(str)) { try { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { foreach (JToken i in obj["data"]["arc_audits"]) { _coin_real += (int)i["stat"]["coin"]; _dm_real += (int)i["stat"]["danmaku"]; _fav_real += (int)i["stat"]["favorite"]; _like_real += (int)i["stat"]["like"]; _play_real += (int)i["stat"]["view"]; _share_real += (int)i["stat"]["share"]; _comment_real += (int)i["stat"]["reply"]; if (LastTime == null || DateTime.Compare(((DateTime)LastTime).AddDays(1), DateTime.Now) <= 0) { _coin_real_last += (int)i["stat"]["coin"]; _dm_real_last += (int)i["stat"]["danmaku"]; _fav_real_last += (int)i["stat"]["favorite"]; _like_real_last += (int)i["stat"]["like"]; _play_real_last += (int)i["stat"]["view"]; _share_real_last += (int)i["stat"]["share"]; _comment_real_last += (int)i["stat"]["reply"]; IsChangeLast = true; } } if ((int)obj["data"]["page"]["pn"] * (int)obj["data"]["page"]["ps"] > (int)obj["data"]["page"]["count"]) { int pn = 2; while (pn * (int)obj["data"]["page"]["ps"] > (int)obj["data"]["page"]["count"]) { string str1 = Bas.GetHTTPBody("https://member.bilibili.com/x/web/archives?status=is_pubing%2Cpubed%2Cnot_pubed&pn=" + pn + "&ps=10&coop=1", Bas.account.Cookies, "https://member.bilibili.com/v2"); if (!string.IsNullOrEmpty(str1)) { try { JObject obj1 = JObject.Parse(str1); if ((int)obj1["code"] == 0) { foreach (JToken i in obj["data"]["arc_audits"]) { _coin_real += (int)i["stat"]["coin"]; _dm_real += (int)i["stat"]["danmaku"]; _fav_real += (int)i["stat"]["favorite"]; _like_real += (int)i["stat"]["like"]; _play_real += (int)i["stat"]["view"]; _share_real += (int)i["stat"]["share"]; _comment_real += (int)i["stat"]["reply"]; if (LastTime == null || DateTime.Compare(((DateTime)LastTime).AddDays(1), DateTime.Now) <= 0) { _coin_real_last += (int)i["stat"]["coin"]; _dm_real_last += (int)i["stat"]["danmaku"]; _fav_real_last += (int)i["stat"]["favorite"]; _like_real_last += (int)i["stat"]["like"]; _play_real_last += (int)i["stat"]["view"]; _share_real_last += (int)i["stat"]["share"]; _comment_real_last += (int)i["stat"]["reply"]; IsChangeLast = true; } } } } catch { } } pn++; } } } if (IsChangeLast) { LastTime = DateTime.Now.Date.AddHours(12); //设定为当天12点数据 } } catch { } } }