Esempio n. 1
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            MovieName = txtName.Text;

            DownloadLink = txtPath.Text;

            ServicePointManager.DefaultConnectionLimit = 100;

            downloadPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), MovieName.Replace(" ", ""));
            if (!Directory.Exists(downloadPath))
            {
                Directory.CreateDirectory(downloadPath);
            }

            listStat.Items.Add("Fetching Links...");

            var listfiles = MyScrapper.Webscraper(DownloadLink);

            if (listfiles == null)
            {
                listStat.Items.Add($"Did not get any file.");
                Cursor = Cursors.Arrow;
                return;
            }
            else
            {
                chkFileList.Items.Clear();

                foreach (var item in listfiles)
                {
                    chkFileList.Items.Add(item, true);
                }
            }

            listStat.Items.Add($"Got {listfiles.Count} files.");

            Cursor = Cursors.Arrow;
        }
Esempio n. 2
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            MovieName = txtName.Text;

            DownloadLink = txtPath.Text;

            System.Net.ServicePointManager.DefaultConnectionLimit = 100;

            downloadPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), MovieName.Replace(" ", ""));
            if (!Directory.Exists(downloadPath))
            {
                Directory.CreateDirectory(downloadPath);
            }

            listStat.Items.Add("Fetching Links...");

            var listfiles = MyScrapper.Webscraper(DownloadLink);

            if (listfiles == null)
            {
                listStat.Items.Add($"Did not get any file.");
                return;
            }

            listStat.Items.Add($"Got {listfiles.Count} files.");

            listStat.Items.Add("Initiating Download...");

            for (int i = 0; i < listfiles.Count; i++)
            {
                if (i % 3 == 0)
                {
                    listfile1.Add(listfiles[i]);
                }
                else if (i % 3 == 1)
                {
                    listfile2.Add(listfiles[i]);
                }
                else
                {
                    listfile3.Add(listfiles[i]);
                }
            }

            listStat.Items.Add("Starting Download...");

            bk1.DoWork             += Bk1_DoWork;
            bk1.RunWorkerCompleted += Bk1_RunWorkerCompleted;
            bk1.ProgressChanged    += Bk1_ProgressChanged;
            bk1.RunWorkerAsync();

            bk2.DoWork             += Bk2_DoWork;
            bk2.ProgressChanged    += Bk2_ProgressChanged;
            bk2.RunWorkerCompleted += Bk2_RunWorkerCompleted;
            bk2.RunWorkerAsync();

            bk3.DoWork             += Bk3_DoWork;
            bk3.ProgressChanged    += Bk3_ProgressChanged;
            bk3.RunWorkerCompleted += Bk3_RunWorkerCompleted;
            bk3.RunWorkerAsync();

            listStat.Items.Add("Download started.");
        }