void DlNextST() { try { tsd.Stop(); } catch { } try { if (downloader.Status == DownloadStatus.Downloading) { downloader.Cancel(); } } catch { } if (listb.Count != 0) { List <BiliInterfaceInfo> lb = (List <BiliInterfaceInfo>)dataGridViewRAW.DataSource; listb[0].Fpaiming = lb?.Find(x => x.AVNUM == listb[0].AVNUM)?.Fpaiming ?? 0; string topstring = ""; if (listb[0].Fpaiming != 0 && listb[0].Fpaiming <= 20) { topstring = "TOP_" + listb[0].Fpaiming + "-"; } if (listb[0].mp4url != null) { tsd = new TSDownload(listb[0].mp4url, Environment.CurrentDirectory + $@"\video\{topstring}{listb[0].AVNUM}-{TSDownload.removeInvChrInPath(listb[0].title)}.mp4"); } else if (listb[0].flvurl != null) { tsd = new TSDownload(listb[0].flvurl, Environment.CurrentDirectory + $@"\video\{topstring}{listb[0].AVNUM}-{TSDownload.removeInvChrInPath(listb[0].title)}.flv"); } tsd.Progressbar = verticalProgressBar1; nowAV = listb[0]; Log.Info("正在下载视频 - " + listb[0].AVNUM + " | " + tsd.URL); pictureBoxDl.ImageLocation = listb[0].pic; tsd.Start(); listb.RemoveAt(0); } else { Log.Info("批量下载完成"); timer1.Enabled = false; textBox1.Text = "下载状态将会显示在这里"; } }
private void DlNext() { try { tsd.Stop(); } catch { } timer1.Enabled = false; if (listb.Count != 0) { List <BiliInterfaceInfo> lb = (List <BiliInterfaceInfo>)dataGridViewRAW.DataSource; listb[0].Fpaiming = lb?.Find(x => x.AVNUM == listb[0].AVNUM)?.Fpaiming ?? 0; string topstring = ""; if (listb[0].Fpaiming != 0 && listb[0].Fpaiming <= 20) { topstring = "TOP_" + listb[0].Fpaiming + "-"; } if (listb[0].mp4url != null) { downloader = new MultiThreadedWebDownloaderEx(listb[0].mp4url) { DownloadPath = Environment.CurrentDirectory + $@"\video\{topstring}{listb[0].AVNUM}-{TSDownload.removeInvChrInPath(listb[0].title)}.mp4" }; } else if (listb[0].flvurl != null) { downloader = new MultiThreadedWebDownloaderEx(listb[0].flvurl) { DownloadPath = Environment.CurrentDirectory + $@"\video\{topstring}{listb[0].AVNUM}-{TSDownload.removeInvChrInPath(listb[0].title)}.flv" }; } //string noNeed; //try //{ // downloader.CheckUrl(out noNeed); //TODO: 在C# 7.0发布后就可以使用out string noNeed啦~ //} //catch //{ // Log.Error("检测下载地址时发生错误,请稍后再试"); // listb.RemoveAt(0); DlNext(); //} nowAV = listb[0]; Log.Info("正在下载视频 - " + listb[0].AVNUM + " | " + downloader.DownloadPath); pictureBoxDl.ImageLocation = listb[0].pic; verticalProgressBar1.Maximum = 100; downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged; downloader.DownloadCompleted += Downloader_DownloadCompleted; downloader.BeginDownload(); listb.RemoveAt(0); } else { Log.Info("批量下载完成"); //timer1.Enabled = false; textBox1.Text = "所有视频都已下载完成!\r\n\r\n下载状态将会显示在这里"; verticalProgressBar1.Value = verticalProgressBar1.Maximum; } }