Exemple #1
0
        private async void buttonRawRead_Click(object sender, EventArgs e)
        {
            if (openFileDialogGuichu.ShowDialog() == DialogResult.OK)
            {
                MemoryStream tempMs = new MemoryStream();
                using (FileStream fs = new FileStream(openFileDialogGuichu.FileName, FileMode.Open))
                {
                    using (GZipStream Compress = new GZipStream(fs, CompressionMode.Decompress))
                    {
                        Compress.CopyTo(tempMs);
                    }
                }
                byte[]    bytes = tempMs.ToArray();
                string    str   = Encoding.GetEncoding("UTF-8").GetString(bytes);
                BiliShell bs    = JsonConvert.DeserializeObject <BiliShell>(str);
                if (bs.ver != 1)
                {
                    MessageBox.Show("此文件是使用新版BR生成的,无法打开!");
                    return;
                }
                List <BiliInterfaceInfo> bi = JsonConvert.DeserializeObject <List <BiliInterfaceInfo> >(bs.infos.ToString());
                textBoxAV.Text = "";
                //TODO: 判断是否为空文件
                foreach (BiliInterfaceInfo i in bi)
                {
                    textBoxAV.Text += i.AVNUM + "\r\n";
                }
                dataGridViewRAW.DataSource = bi;

                Log.Info("文件加载完成,正在生成csv");
                textBoxOut.Text = await BiliInterface.GetCsvInfosAsync(bi);

                Log.Info("生成csv完成");
            }
        }
Exemple #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("批量获取完成");
        }
Exemple #3
0
        private async void buttonGen_Click(object sender, EventArgs e)
        {
            Log.Info("开始批量获取");
            TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Indeterminate);
            List <string>            lines = Regex.Split(textBoxAV.Text, "\r\n|\r|\n").ToList <string>();
            List <BiliInterfaceInfo> ll    = new List <BiliInterfaceInfo>();
            string failedAVs = "";
            var    avs       = from s in lines where s != "" select s;
            //IEnumerable<Task<BiliInterfaceInfo>> llasync =
            //    from s in lines where s != "" select BiliInterface.GetInfoHTaskAsync(s);
            //Task<BiliInterfaceInfo>[] lltasks = llasync.ToArray();
            //BiliInterfaceInfo[] lls = await Task.WhenAll(lltasks);
            Stopwatch sw = new Stopwatch(); sw.Restart();

            BiliInterfaceInfo[] lls = await concurrentAsync(
                100,
                avs,
                new Func <string, ScoreType, Task <BiliInterfaceInfo> >(BiliInterface.GetInfoTaskAsync),
                ScoreType.Guichu);

            Log.Info($"获取用时:{sw.ElapsedMilliseconds}ms"); sw.Stop();
            Log.Info("正在排序");
            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("批量获取完成");
        }