示例#1
0
        public LikeSelect(string id)
        {
            InitializeComponent();
            var materialSkinManager = MaterialSkinManager.Instance;

            materialSkinManager.AddFormToManage(this);
            Other.RefreshColorSceme();

            //https://api.bilibili.com/medialist/gateway/base/info?media_id=295080471
            WebClient MyWebClient = new WebClient();

            MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于向Internet资源的请求进行身份验证的网络凭据
            MyWebClient.Headers.Add("Cookie", User.cookie);
            MyWebClient.Headers.Add("Origin", "https://space.bilibili.com");
            MyWebClient.Headers.Add("Referer", "https://www.bilibili.com/medialist/detail/ml" + id);
            LikeDataRAW = Encoding.UTF8.GetString(MyWebClient.DownloadData("https://api.bilibili.com/medialist/gateway/base/resource/ids?media_id=" + id)); //如果获取网站页面采用的是UTF-8,则使用这句
            LikeJSON    = JsonConvert.DeserializeObject <JSONCallback.LikeBoxItem.LikeBoxItem>(LikeDataRAW);
            int lasty = 0;

            foreach (JSONCallback.LikeBoxItem.DataItem data in LikeJSON.data)
            {
                string         bvid = data.bv_id;
                LikeSelectItem item = new LikeSelectItem(bvid);
                panel1.Controls.Add(item);
                item.Location = new Point(0, lasty);
                lasty        += item.Size.Height;
            }
        }
示例#2
0
        public void LoadPage()
        {
            // https://api.bilibili.com/x/space/arc/search?mid=258150656&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
            WebClient MyWebClient = new WebClient
            {
                Credentials = CredentialCache.DefaultCredentials//获取或设置用于向Internet资源的请求进行身份验证的网络凭据
            };

            MyWebClient.Headers.Add("Cookie", User.cookie);
            MyWebClient.Headers.Add("Origin", "https://space.bilibili.com");
            MyWebClient.Headers.Add("Referer", "https://www.bilibili.com/medialist/detail/ml" + mid);
            string json = Encoding.UTF8.GetString(MyWebClient.DownloadData(string.Format("https://api.bilibili.com/x/v3/fav/resource/list?media_id={0}&pn={1}&ps=6&order=mtime&type=0&tid=0&jsonp=jsonp", mid, pagenow)));

            MyWebClient.Dispose();
            JSONCallback.LikeBoxItem.LikeBoxItem upUpload = JsonConvert.DeserializeObject <JSONCallback.LikeBoxItem.LikeBoxItem>(json);
            if (upUpload.code != 0)
            {
                MessageBox.Show("获取收藏夹错误: " + upUpload.message);
                Close();
                Dispose();
                return;
            }
            Text = upUpload.data.info.title;
            panel1.Controls.Clear();
            int lasty = 0;

            foreach (JSONCallback.LikeBoxItem.MediasItem data in upUpload.data.medias)
            {
                string         aid  = data.id;
                LikeSelectItem item = new LikeSelectItem(aid, data.title, data.cover, data.attr == 0);
                panel1.Controls.Add(item);
                item.Location = new Point(0, lasty);
                lasty        += item.Size.Height;
            }
            pageall = Convert.ToInt32(Math.Ceiling((double)(upUpload.data.info.media_count / 6)));
            if (pagenow * 6 >= upUpload.data.info.media_count)
            {
                PageNextButton.Visible = false;
            }
            else
            {
                PageNextButton.Visible = true;
            }

            if (pagenow == 1)
            {
                PageUpButton.Visible = false;
            }
            else
            {
                PageUpButton.Visible = true;
            }



            materialLabel1.Text = "第 " + pagenow.ToString() + " 页 / 共 " + pageall.ToString() + " 页";
        }
示例#3
0
 private void materialCheckBox1_CheckedChanged(object sender, EventArgs e)
 {
     foreach (Control c in panel1.Controls)
     {
         if (c is LikeSelectItem)
         {
             LikeSelectItem item = (LikeSelectItem)c;
             item.check = materialCheckBox1.Checked;
         }
     }
 }
示例#4
0
        private void materialFlatButton1_Click(object sender, EventArgs e)
        {
            var          dialog = new FolderBrowserDialog();
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                path = dialog.SelectedPath;
            }
            foreach (Control c in panel1.Controls)
            {
                LikeSelectItem item = (LikeSelectItem)c;
                item.Download(path);
            }
        }
示例#5
0
        public void LoadPage()
        {
            // https://api.bilibili.com/x/space/arc/search?mid=258150656&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
            WebClient MyWebClient = new WebClient
            {
                Credentials = CredentialCache.DefaultCredentials//获取或设置用于向Internet资源的请求进行身份验证的网络凭据
            };

            MyWebClient.Headers.Add("Cookie", User.cookie);
            MyWebClient.Headers.Add("Origin", "https://space.bilibili.com");
            MyWebClient.Headers.Add("Referer", "https://space.bilibili.com/" + uid + "/video");
            string json = Encoding.UTF8.GetString(MyWebClient.DownloadData(string.Format("https://api.bilibili.com/x/space/arc/search?mid={0}&ps=6&pn={1}&order=pubdate&jsonp=jsonp", uid, pagenow))); //如果获取网站页面采用的是UTF-8,则使用这句

            MyWebClient.Dispose();
            JSONCallback.UpUpload.UpUpload upUpload = JsonConvert.DeserializeObject <JSONCallback.UpUpload.UpUpload>(json);
            panel1.Controls.Clear();
            int lasty = 0;

            foreach (JSONCallback.UpUpload.VlistItem data in upUpload.data.list.vlist)
            {
                LikeSelectItem item = new LikeSelectItem(data.aid, data.title, data.pic);
                panel1.Controls.Add(item);
                item.Location = new Point(0, lasty);
                lasty        += item.Size.Height;
            }

            if (upUpload.data.page.pn * upUpload.data.page.ps >= upUpload.data.page.count)
            {
                PageNextButton.Visible = false;
            }
            else
            {
                PageNextButton.Visible = true;
            }

            if (upUpload.data.page.pn == 1)
            {
                PageUpButton.Visible = false;
            }
            else
            {
                PageUpButton.Visible = true;
            }

            pageall = Convert.ToInt32(Math.Ceiling((double)(upUpload.data.page.count / 6)));

            materialLabel1.Text = "第 " + pagenow.ToString() + " 页 / 共 " + pageall.ToString() + " 页";
        }
示例#6
0
        public LikeSelect(string id)
        {
            InitializeComponent();
            var materialSkinManager = MaterialSkinManager.Instance;

            materialSkinManager.AddFormToManage(this);


            if (Other.IsDarkMode())
            {//Dark Mode
                materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey500, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
                materialSkinManager.Theme       = MaterialSkinManager.Themes.DARK;
            }
            else
            {
                materialSkinManager.ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo500, Primary.Indigo500, Accent.LightBlue200, TextShade.WHITE);
                materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            }

            //https://api.bilibili.com/medialist/gateway/base/info?media_id=295080471
            WebClient MyWebClient = new WebClient();

            MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于向Internet资源的请求进行身份验证的网络凭据
            MyWebClient.Headers.Add("Cookie", User.cookie);
            MyWebClient.Headers.Add("Origin", "https://space.bilibili.com");
            MyWebClient.Headers.Add("Referer", "https://www.bilibili.com/medialist/detail/ml" + id);
            LikeDataRAW = Encoding.UTF8.GetString(MyWebClient.DownloadData("https://api.bilibili.com/medialist/gateway/base/resource/ids?media_id=" + id)); //如果获取网站页面采用的是UTF-8,则使用这句
            LikeJSON    = JsonConvert.DeserializeObject <JSONCallback.LikeBoxItem.LikeBoxItem>(LikeDataRAW);
            int lasty = 0;

            foreach (JSONCallback.LikeBoxItem.DataItem data in LikeJSON.data)
            {
                string         avid = Other.TextGetCenter("/av", "?", data.short_link);
                LikeSelectItem item = new LikeSelectItem(avid);
                panel1.Controls.Add(item);
                item.Location = new Point(0, lasty);
                lasty        += item.Size.Height;
            }
        }