Esempio n. 1
0
        private async void btnLogin_Click(object sender, EventArgs e)
        {
            if (!validation())
            {
                return;
            }

            btnLogin.Enabled = false;
            try
            {
                var vozClient = new NextVozClient();

                if (string.IsNullOrEmpty(rbCookies.Text))
                {
                    await vozClient.Login(txtUserName.Text, txtPassword.Text);
                }
                else
                {
                    await vozClient.Login(rbCookies.Text);
                }

                Setting.Instance.Cookies = vozClient.GetCookies();

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                btnLogin.Enabled = true;
            }
        }
Esempio n. 2
0
        public async Task <ThreadInfo> GetThreadInfo(string url)
        {
            var id = Helpers.NextVozRegex.GetThreadId(url);

            if (string.IsNullOrEmpty(id))
            {
                id = url;
            }

            var info = new ThreadInfo();

            info.ThreadId = id;
            info.Url      = $"https://voz.vn/t/{id}";

            if (_client == null)
            {
                _client = new NextVozClient(Setting.Instance.Cookies);
            }

            var content = await _client.GetContent(info.Url);

            info.Name = Helpers.NextVozRegex.GetThreadName(content);
            info.Page = Helpers.NextVozRegex.GetTotalPage(content);

            return(info);
        }
 private void Browser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     Task.Run(() =>
     {
         var cookies = Cookies.GetUriCookieContainer(new Uri("https://next.voz.vn"));
         if (NextVozClient.IsLogin(cookies))
         {
             try
             {
                 this.Invoke((Action)(() => Close()));
             }
             catch { }
         }
     });
 }
Esempio n. 4
0
        public async Task Start()
        {
            if (_isPause)
            {
                _isPause = false;

                return;
            }

            Status.Set("Đang tải về ...");



            IsDownloading    = true;
            _isPause         = false;
            _isStop          = false;
            _isGetThreadsEnd = false;

            _client = new NextVozClient(Setting.Instance.Cookies);

            var info = await GetThreadInfo(Setting.Instance.Link);

            var from = Math.Max(Setting.Instance.FromPage, 1);
            var to   = Math.Max(Setting.Instance.ToPage, 1);

            if (Setting.Instance.AllPage)
            {
                from = 1;
                to   = info.Page;
            }

            for (int i = from; i <= to; i++)
            {
                this._pages.Enqueue($"https://voz.vn/t/{info.ThreadId}/page-{i}");
            }

            DownloadProcess.Create(Setting.Instance.NumberThreads);

            var dir = Setting.Instance.SavePath;

            if (Setting.Instance.CreateDirByThreadName)
            {
                dir = Path.Combine(Application.StartupPath, "Images", info.ThreadId.Trim('/'));
            }

            _store = new ImageStore(
                dir,
                Setting.Instance.SubDirectory,
                Setting.Instance.MaxImageInSubDirectory,
                new DownloadedInfo()
            {
            });

            Status.Set(_store.Info.TotalDownloadedImage, _store.Info.TotalDownloadedSize);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            var t1 = Task.Run(getImagesUrl);

            var t2 = Task.Run(download);
        }
Esempio n. 5
0
        private void init()
        {
            System.Net.ServicePointManager.MaxServicePoints       = Int32.MaxValue;
            System.Net.ServicePointManager.DefaultConnectionLimit = Int32.MaxValue;
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

            try
            {
                txtLink.Text                    = Setting.Instance.Link;
                txtSavePath.Text                = Setting.Instance.SavePath;
                cbDownloadAllPage.Checked       = Setting.Instance.AllPage;
                cbSubDirectory.Checked          = Setting.Instance.SubDirectory;
                cbIgnoreSmallImage.Checked      = Setting.Instance.IgnoreSmallImage;
                cbCreateDirByThreadName.Checked = Setting.Instance.CreateDirByThreadName;
                nrMaxImageInSubDirectory.Value  = Setting.Instance.MaxImageInSubDirectory;
                nrNumberThreads.Value           = Setting.Instance.NumberThreads;
                nrFormPage.Value                = Setting.Instance.FromPage;
                nrToPage.Value                  = Setting.Instance.ToPage;
            }
            catch
            {
            }

            if (string.IsNullOrEmpty(txtSavePath.Text))
            {
                txtSavePath.Text = Path.Combine(Application.StartupPath, "Images");
            }

            if (!string.IsNullOrEmpty(Setting.Instance.Cookies))
            {
                btnLogin.Enabled = false;
                btnLogin.Text    = "Đang đăng nhập";

                var vozClient = new NextVozClient(Setting.Instance.Cookies);

                Task.Run(async() =>
                {
                    try
                    {
                        await vozClient.Login(Setting.Instance.Cookies);

                        this.Invoke((Action)(() =>
                        {
                            btnLogin.Enabled = true;
                            btnLogin.Text = "Đăng xuất";
                        }));
                    }
                    catch
                    {
                        this.Invoke((Action)(() =>
                        {
                            btnLogin.Enabled = true;
                            btnLogin.Text = "Đăng nhập";
                        }));
                    }
                });
            }

            btnLogin.Enabled = string.IsNullOrEmpty(Setting.Instance.Cookies);

            _downloader = new NextVozDownloadImage();

            if (!string.IsNullOrEmpty(Setting.Instance.Link))
            {
                linkChanged();
            }

            SetDoubleBuffered(this.lvDownloadProcess);

            EXListView lv = new EXListView();

            lv.Location = lvDownloadProcess.Location;
            lv.Width    = lvDownloadProcess.Width;
            lv.Height   = lvDownloadProcess.Height;
            lv.Anchor   = lvDownloadProcess.Anchor;

            this.Controls.Remove(lvDownloadProcess);
            this.Controls.Add(lv);

            lv.Columns.Add("Link", 450);
            lv.Columns.Add("Process", 300);


            Status.Init(lbStatus, lbTotalDownloaded, lbTotalSize);
            DownloadProcess.Init(lv);
        }