Esempio n. 1
0
        public void GetInfoAsyncTest()
        {
            BiliInterfaceInfo info = new BiliInterfaceInfo();

            info = AsyncHelper.RunSync(() => BiliInterface.GetInfoAsync("av2680512"));

            Assert.AreEqual(info.title, "【创刊号】哔哩哔哩月刊鬼畜排行榜#001");
        }
Esempio n. 2
0
        private async void buttonRAWInsert_Click(object sender, EventArgs e)
        {
            if (dataGridViewRAW.DataSource == null)
            {
                MessageBox.Show("还没有生成或加载任何数据!", "NOOOOOOOOOO!");
                return;
            }
            Log.Info("开始批量获取");
            TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Indeterminate);
            List <string>            lines = Regex.Split(textBoxAV.Text, "\r\n|\r|\n").ToList <string>();
            List <BiliInterfaceInfo> llraw = (List <BiliInterfaceInfo>)dataGridViewRAW.DataSource;
            List <BiliInterfaceInfo> ll    = new List <BiliInterfaceInfo>();

            llraw.ForEach(i =>
            {
                if (!lines.Contains(i.avnum))
                {
                    ll.Add(i);
                }
            });

            string failedAVs = "";

            IEnumerable <Task <BiliInterfaceInfo> > llasync =
                from s in lines where s != "" select BiliInterface.GetInfoAsync(s);

            Task <BiliInterfaceInfo>[] lltasks = llasync.ToArray();
            BiliInterfaceInfo[]        lls     = await Task.WhenAll(lltasks);

            foreach (BiliInterfaceInfo info in lls)
            {
                if (info.pic != null)
                {
                    ll.Add(info);
                }
                else
                {
                    failedAVs += info.avnum + ";";
                }
            }
            ll.Sort(sortt);
            for (int i = 1; i <= ll.Count; i++)
            {
                ll[i - 1].Fpaiming = i;
            }
            dataGridViewRAW.DataSource = ll;
            if (failedAVs != "")
            {
                Log.Error("注意!下列视频数据未正确获取!\r\n" + failedAVs);
            }
            textBoxOut.Text = await BiliInterface.GetCsvInfosAsync(ll);

            TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.NoProgress);
            Log.Info("批量获取完成");
        }