Beispiel #1
0
        public async void OnStartAsync(string url)
        {
            try
            {
                DownloaderClient client = new DownloaderClient();
                await client.Create_joblistAsync(url);

                _jobs = client.getJobs();
                statusgroup.setLengthPlaylist(_jobs.Count);
                statusgroup.UpdateThreadText(_threadStatus[0]);

                if (_jobs.Count == 0)
                {
                    await client.Create_joblistAsync(url);

                    statusgroup.UpdateThreadText(_threadStatus[0]);
                }
                if (statusgroup.getProgressCounter() > 0)
                {
                    statusgroup.resetProgressCounter();
                }

                while (true)
                {
                    if (_jobs.Count > 0)
                    {
                        statusgroup.UpdateThreadText(_threadStatus[1]);
                        var job = _jobs[0];
                        _jobs.RemoveAt(0);
                        await client.start_downloadAsync(job.Id);

                        statusgroup.Updatelbl(_jobs.Count, job.Title);
                        statusgroup.addProgressCounter();
                        statusgroup.UpdateUI();
                        Thread.Sleep(1000);
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                    if (_jobs.Count == 0)
                    {
                        statusgroup.UpdateThreadText(_threadStatus[2]);
                        _Downloader.Abort();
                    }
                }
            }
            catch (Exception ex)
            {
                Mainform main = new Mainform();
                lbl_invoke.Invoke(new UpdateMbox(UpdateMboxes), ex.Message);
            }
        }
        private async void btn_download_ClickAsync(object sender, EventArgs e)
        {
            string           url    = txt_url.Text;
            DownloaderClient client = new DownloaderClient();
            string           id     = client.GetVideoID(url);
            await client.start_downloadAsync(id);

            Download download = client.GetDownload();

            if (download.getError() != string.Empty)
            {
                MessageBox.Show(download.getError());
            }
            else
            {
                UpdateInfoPanel(download.getTitle(), download.getAuthor(), download.getDuration());
            }
        }