Ejemplo n.º 1
0
 private void LoadUserInfo()
 {
     try
     {
         string  userInfoUrl = "https://api.live.bilibili.com/User/getUserInfo";
         JObject jo          = JObject.Parse(BiliHelper.BiliGetRequest(userInfoUrl, BiliHelper.Data.BiliCookie));
         this.Text                   = (string)jo["data"]["uname"];
         this.lb_BiliCoin.Text       = (string)jo["data"]["billCoin"];
         this.lb_Gold.Text           = (string)jo["data"]["gold"];
         this.lb_Silver.Text         = (string)jo["data"]["silver"];
         this.pic_Logo.ImageLocation = (string)jo["data"]["face"];
         //保存Cookie,方便下次登录
         string savaPath = System.IO.Directory.GetCurrentDirectory() + @"\账号库\";
         //先判断有没有这个文件夹,没有就创建。
         if (!Directory.Exists(savaPath))
         {
             Directory.CreateDirectory(savaPath);
         }
         BinaryFormatter bf = new BinaryFormatter();
         using (FileStream fs = new FileStream(savaPath + (string)jo["data"]["uname"] + ".dat", FileMode.Create))
         {
             //将Cookie序列化,并且保存到指定的流
             bf.Serialize(fs, BiliHelper.Data.BiliCookie);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Ejemplo n.º 2
0
 private void LoadBagList()
 {
     try
     {
         this.listView1.Items.Clear();
         string  bagHost  = "https://api.live.bilibili.com/xlive/web-room/v1/gift/bag_list";
         JObject bagJson  = JObject.Parse(BiliHelper.BiliGetRequest(bagHost, BiliHelper.Data.BiliCookie));
         int     bagCount = bagJson["data"]["list"].Count();//背包礼物种类数量
         //加载背包
         for (int i = 0; i < bagCount; i++)
         {
             ListViewItem li = new ListViewItem(bagJson["data"]["list"][i]["bag_id"].ToString());
             li.SubItems.Add(bagJson["data"]["list"][i]["gift_id"].ToString());
             li.SubItems.Add(bagJson["data"]["list"][i]["gift_name"].ToString());
             li.SubItems.Add(bagJson["data"]["list"][i]["gift_num"].ToString());
             li.SubItems.Add(bagJson["data"]["list"][i]["corner_mark"].ToString());
             this.listView1.Items.Add(li);
         }
         //背包列表自适应大小
         for (int i = 0; i < this.listView1.Columns.Count; i++)
         {
             this.listView1.Columns[i].Width = this.listView1.ClientSize.Width / this.listView1.Columns.Count;
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs ee)
        {
            //一键满所有勋章,一切以辣条为基准
            int seedCount = 0;//记录送出辣条数

            try
            {
                string  medalHost  = "https://api.live.bilibili.com/i/api/medal?page=1&pageSize=100";
                JObject medalJson  = JObject.Parse(BiliHelper.BiliGetRequest(medalHost, BiliHelper.Data.BiliCookie));
                int     medalCount = medalJson["data"]["fansMedalList"].Count();
                //从第一个勋章开始送
                for (int i = 0; i < medalCount; i++)
                {
                    string roomId              = medalJson["data"]["fansMedalList"][i]["roomid"].ToString();
                    string medalTodayFeed      = medalJson["data"]["fansMedalList"][i]["todayFeed"].ToString();
                    string medalTodayFeedLimit = medalJson["data"]["fansMedalList"][i]["dayLimit"].ToString();
                    int    needCount           = int.Parse(medalTodayFeedLimit) - int.Parse(medalTodayFeed);//还需要辣条数
                    //获取背包
                    string  bagHost  = "https://api.live.bilibili.com/xlive/web-room/v1/gift/bag_list";
                    JObject bagJson  = JObject.Parse(BiliHelper.BiliGetRequest(bagHost, BiliHelper.Data.BiliCookie));
                    int     bagCount = bagJson["data"]["list"].Count();//背包礼物种类数量
                    //从背包第一个礼物开始送
                    for (int j = 0; j < bagCount; j++)
                    {
                        //只送辣条
                        if (bagJson["data"]["list"][j]["gift_name"].ToString() == "辣条")
                        {
                            //这个背包的礼物数量
                            int    currentNum = int.Parse(bagJson["data"]["list"][j]["gift_num"].ToString());
                            string bagId      = bagJson["data"]["list"][j]["bag_id"].ToString();
                            if (currentNum > needCount)
                            {
                                //如果当前这个背包的辣条数大于需要的,就送需要的辣条数量
                                BiliHelper.BiliSendGift(roomId, "1", needCount.ToString(), bagId);
                                seedCount += needCount;

                                //输出日志
                                this.tb_Log.AppendText("[" + DateTime.Now.Date.ToString() + "]" + "成功将" + medalJson["data"]["fansMedalList"][i]["medal_name"] + "勋章亲密度送满" + Environment.NewLine);
                                break;//跳出,进行下一个勋章
                            }
                            else
                            {
                                //如果当前这个背包的辣条数小于需要的,就送全部辣条
                                BiliHelper.BiliSendGift(roomId, "1", currentNum.ToString(), bagId);
                                seedCount += currentNum; //如果是自己的勋章,也会加。
                                needCount -= currentNum; //刷新还需要的辣条数(如果不更新,会导致一个房间送过多辣条)
                            }
                        }
                    }
                }
                MessageBox.Show("全部赠送完毕,累积送出" + seedCount);
                //刷新勋章
                LoadMedalList();
            }
            catch (Exception e)
            {
                MessageBox.Show("1.勋章里面有自己勋章的时候,可能会出现+或者\n2.对方未开通直播间可能出现\n【给泽酱看的:" + e.Message + "】");
            }
        }
Ejemplo n.º 4
0
        public static string BiliSendGift(string roomId, string giftId, string giftNum, string bagId)
        {
            string  anchorInfoHost = "https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=";
            JObject anchorInfoJson = JObject.Parse(BiliGetRequest(anchorInfoHost + roomId));
            string  uid            = anchorInfoJson["data"]["room_info"]["uid"].ToString();
            string  giftPostData   = "gift_id=" + giftId + "&ruid=" + uid + "&gift_num=" + giftNum + "&bag_id=" + bagId + "&biz_id=" + roomId;

            return(BiliHelper.BiliPostRequest("https://api.live.bilibili.com/gift/v2/live/bag_send", giftPostData, BiliHelper.Data.BiliCookie));
        }
Ejemplo n.º 5
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            //获取二维码登录
            string  host        = "https://passport.bilibili.com/qrcode/getLoginUrl";
            string  toQRcodeApi = "http://qr.topscan.com/api.php?text=";
            JObject QRcodeUrl   = JObject.Parse(BiliHelper.BiliGetRequest(host));

            oauthKey = QRcodeUrl["data"]["oauthKey"].ToString();
            this.pictureBox1.ImageLocation = toQRcodeApi + QRcodeUrl["data"]["url"];
            this.timer1.Start();
        }
Ejemplo n.º 6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            string  host        = "https://passport.bilibili.com/qrcode/getLoginInfo";
            string  postData    = "oauthKey=" + oauthKey + "&gourl=https://passport.bilibili.com/account/security";
            JObject scanEndText = JObject.Parse(BiliHelper.BiliPostRequest(host, postData, out CookieContainer myCookieContainer));

            //判断扫码是否成功
            if (scanEndText["status"].ToString() == "True")
            {
                MessageBox.Show("扫码成功");
                BiliHelper.Data.BiliCookie = myCookieContainer;

                //进入工具主页
                ToolsPage toolsPageFrm = new ToolsPage();
                toolsPageFrm.Show();
                this.Hide();
                this.timer1.Stop();
            }
        }
Ejemplo n.º 7
0
 private void LoadMedalList()
 {
     try
     {
         this.listView2.Items.Clear();
         string  medalHost  = "https://api.live.bilibili.com/i/api/medal?page=1&pageSize=100";
         JObject medalJson  = JObject.Parse(BiliHelper.BiliGetRequest(medalHost, BiliHelper.Data.BiliCookie));
         int     medalCount = medalJson["data"]["fansMedalList"].Count();
         for (int i = 0; i < medalCount; i++)
         {
             string       medalName            = medalJson["data"]["fansMedalList"][i]["medal_name"].ToString();
             string       medalLevel           = medalJson["data"]["fansMedalList"][i]["level"].ToString();
             string       medalColor           = medalJson["data"]["fansMedalList"][i]["medal_color"].ToString();
             string       medalCurrentIntimacy = medalJson["data"]["fansMedalList"][i]["intimacy"].ToString();
             string       medalTotalIntimacy   = medalJson["data"]["fansMedalList"][i]["next_intimacy"].ToString();
             string       medalTodayFeed       = medalJson["data"]["fansMedalList"][i]["todayFeed"].ToString();
             string       medalTodayFeedLimit  = medalJson["data"]["fansMedalList"][i]["dayLimit"].ToString();
             string       medalUpName          = medalJson["data"]["fansMedalList"][i]["target_name"].ToString();
             ListViewItem li = new ListViewItem(medalLevel);
             li.UseItemStyleForSubItems = false;
             li.SubItems.Add(medalName);
             li.SubItems.Add(medalCurrentIntimacy + "/" + medalTotalIntimacy);
             li.SubItems.Add(medalTodayFeed + "/" + medalTodayFeedLimit);
             li.SubItems.Add(medalUpName);
             li.BackColor             = Color.FromArgb(int.Parse(medalColor));
             li.SubItems[1].BackColor = Color.FromArgb(int.Parse(medalColor));
             this.listView2.Items.Add(li);
         }
         //自适应单元格宽度
         for (int i = 0; i < this.listView2.Columns.Count; i++)
         {
             this.listView2.Columns[i].Width = -2;
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }