예제 #1
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);
            }
        }
예제 #2
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);
            }
        }