Exemple #1
0
 private void backWorkerDownloadFiles_DoWork(object sender, DoWorkEventArgs e)
 {
     //遍历下载列表,下载文件
     for (int i = 0; i < voaDownloadList.Count; i++)
     {
         this.backWorkerDownloadFiles.ReportProgress(i + 1);
         ClassVOA voa = (ClassVOA)voaDownloadList[i];
         //this.richTextBox1.AppendText(voa.Mp3Url + "   LRC: " + voa.LrcUrl + "\n");
         try
         {
             if (VOA.ClassConfig.configIsHtmlDownload)
             {
                 voa.DownloadHTML(this.toolStripProgressBar);
             }
             if (VOA.ClassConfig.configIsMP3Download)
             {
                 voa.DownloadMP3(this.toolStripProgressBar);
                 voa.DownloadLRC(this.toolStripProgressBar);
             }
             if (VOA.ClassConfig.configIsTXTDownload)
             {
                 voa.DownloadTXT(this.toolStripProgressBar);
             }
         }
         catch (Exception)
         {
             //下载失败
         }
     }
 }
Exemple #2
0
        public Boolean getVoaList()
        {
            try
            {
                int TypeIsDownloadNum = 0;
                VOAItemList = new ArrayList();
                ////进度条操作
                //this.toolStripProgressBar.Value = 1;
                //this.toolStripProgressBar.Maximum = VOA.ClassConfig.configVOATypeList.Count;
                ////操作结束
                for (int i = 0; i < VOA.ClassConfig.configVOATypeList.Count; i++)
                {
                    VOA.ClassConfigVOAType config = (VOA.ClassConfigVOAType)VOA.ClassConfig.configVOATypeList[i];
                    if (config.TpyeIsDownload)
                    {
                        TypeIsDownloadNum++;
                    }
                }
                for (int i = 0; i < VOA.ClassConfig.configVOATypeList.Count; i++)
                {
                    VOA.ClassConfigVOAType config = (VOA.ClassConfigVOAType)VOA.ClassConfig.configVOATypeList[i];
                    if (config.TpyeIsDownload)
                    {
                        VOA.ClassHTML classHtml = new VOA.ClassHTML();
                        classHtml.Url = config.TypeURL;
                        classHtml.GetHTML();
                        ArrayList temp = classHtml.GetVOAList(60 / TypeIsDownloadNum, config.TypeName);
                        for (int j = 0; j < temp.Count; j++)
                        {
                            VOAItemList.Add(temp[j]);
                        }
                    }
                    this.backWorkerGetVoaList.ReportProgress(i + 1);
                    ////进度条操作
                    //this.toolStripProgressBar.Value = i + 1;
                    ////操作结束
                }

                this.checkedListBoxMain.Items.Clear();
                if (VOAItemList.Count == 0)
                {
                    return(false);
                }
                for (int i = 0; i < VOAItemList.Count; i++)
                {
                    ClassVOA voa = (ClassVOA)VOAItemList[i];
                    CheckBox cb  = new CheckBox();
                    this.checkedListBoxMain.Items.Add(voa.Type + "-" + voa.Name + " (" + voa.Date.ToString("yyyy-MM-dd") + ")");
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #3
0
        private void backWorkerGetVoaUrls_DoWork(object sender, DoWorkEventArgs e)
        {
            //根据下载当天日期创建文件夹
            DateTime dtNow = DateTime.Now;
            string   path  = VOA.ClassConfig.configSavePath + "\\" + dtNow.ToString("yyyy-MM-dd");

            System.IO.Directory.CreateDirectory(path);
            //遍历下载列表,提取下载文件的地址
            for (int i = 0; i < voaDownloadList.Count; i++)
            {
                ClassVOA      voa       = (ClassVOA)voaDownloadList[i];
                VOA.ClassHTML classHtml = new VOA.ClassHTML();
                classHtml.Url = voa.HtmlUrl;
                classHtml.GetHTML();
                voa.Mp3Url = classHtml.GetVOAUrl();
                voa.LrcUrl = classHtml.GetLRCUrl();
                voa.Path   = path + "\\" + deleteInvalidChars(voa.Type + "-" + voa.Name + " (" + voa.Date.ToString("yyyy-MM-dd") + ")") + ".mp3";
                //this.richTextBox1.AppendText(voa.Name + "\n----Mp3Url:   " + voa.Mp3Url + "\n----Mp3Path:   " + voa.Path + "\n----HtmlUrl:   " + voa.HtmlUrl + "\n----type:   " + voa.Type + "\n----date:   " + voa.Date + "\n\n");
                this.backWorkerGetVoaUrls.ReportProgress(i + 1);
            }
        }
Exemple #4
0
        private void buttonDownload_Click(object sender, EventArgs e)
        {
            //StringBuilder str = new StringBuilder();
            //for (int i = 0; i < VOAItemList.Count; i++)
            //{
            //    ClassVOA voa = (ClassVOA)VOAItemList[i];
            //    str.Append(voa.Type + "-" + voa.Name + " (" + voa.Date.ToString("yyyy-MM-dd") + ")----" + voa.HtmlUrl +"\n");
            //}
            ////MessageBox.Show(str.ToString());


            voaDownloadList = new ArrayList();
            for (int i = 0; i < this.checkedListBoxMain.Items.Count; i++)
            {
                if (this.checkedListBoxMain.GetItemChecked(i))
                {
                    ClassVOA voa = (ClassVOA)VOAItemList[i];
                    voaDownloadList.Add(voa);
                }
            }
            if (voaDownloadList.Count == 0)
            {
                MessageBox.Show("请选择需要下载的文件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                //提取下载文件的MP3链接
                this.buttonDownload.Enabled          = false;
                this.buttonFresh.Enabled             = false;
                this.toolStripMenuItemConfig.Enabled = false;
                this.toolStripStatus.Text            = "正在提取文件地址...";
                this.toolStripProgressBar.Value      = 0;
                this.toolStripProgressBar.Maximum    = voaDownloadList.Count;
                this.backWorkerGetVoaUrls.RunWorkerAsync();
            }
        }