Example #1
0
 private void button1_Click(object sender, EventArgs e) // Search Button
 {
     try
     {
         toolStripStatusLabel1.Text = "Searching...";
         string request = textBox1.Text.Replace(' ', '+').Replace("*", "%2a");
         if (Transfer.IsAPI)
         {
             int countContent = R34API.GetCountContent(request);
             if (countContent > 0)
             {
                 toolStripStatusLabel1.Text = "Search completed";
                 if (MessageBox.Show(countContent + " results found. Open in a browser?", "Searching results", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                 {
                     Process.Start("https://rule34.xxx/index.php?page=post&s=list&tags=" + request);
                 }
             }
             else
             {
                 toolStripStatusLabel1.Text = "Search completed";
                 MessageBox.Show("Nobody here but us chickens!", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else // If parsing method
         {
             if (R34Parser.IsSomethingFound(request))
             {
                 int countContent = R34Parser.GetCountContent(request, R34Parser.GetMaxPid(request));
                 if (countContent > 0)
                 {
                     toolStripStatusLabel1.Text = "Search completed";
                     if (MessageBox.Show(countContent + " results found. Open in a browser?", "Searching results", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                     {
                         Process.Start("https://rule34.xxx/index.php?page=post&s=list&tags=" + request);
                     }
                 }
                 else
                 {
                     toolStripStatusLabel1.Text = "Search completed";
                     MessageBox.Show("Unable to search this deep in temporarily (error on site)", "Search error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 toolStripStatusLabel1.Text = "Search completed";
                 MessageBox.Show("Nobody here but us chickens!", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception exp)
     {
         toolStripStatusLabel1.Text = "Search error";
         MessageBox.Show(exp.Message, "Search error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
        private async void button2_Click(object sender, EventArgs e) // Download Button
        {
            try
            {
                string request = textBox1.Text.Replace(' ', '+').Replace("*", "%2a");
                if (Transfer.IsAPI)
                {
                    int countContent = R34API.GetCountContent(request);
                    if (countContent > 0)
                    {
                        if (folderBrowserDialog1.ShowDialog() != DialogResult.Cancel)
                        {
                            Properties.Settings.Default.Path = folderBrowserDialog1.SelectedPath;
                            Properties.Settings.Default.Save();

                            DownloadingForm dlf = new DownloadingForm(countContent);
                            dlf.ShowDialog();

                            if (Transfer.Limit > 0)
                            {
                                toolStripStatusLabel1.Text    = "Downloading content...";
                                toolStripProgressBar1.Maximum = Transfer.Limit;

                                var progress  = new Progress <int>(s => toolStripProgressBar1.Value = s);
                                var progress2 = new Progress <int>(s => toolStripStatusLabel2.Text = s + " / " + Transfer.Limit);
                                await Task.Factory.StartNew(() => R34API.DownloadContent(request, folderBrowserDialog1.SelectedPath, progress, progress2, Transfer.Limit), TaskCreationOptions.LongRunning);

                                toolStripStatusLabel1.Text = "Download completed";
                                if (MessageBox.Show("Download completed! Open the folder?", "Download completed", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                                {
                                    Process.Start(folderBrowserDialog1.SelectedPath);
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Nobody here but us chickens!", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else // If parsing method
                {
                    if (R34Parser.IsSomethingFound(request))
                    {
                        if (folderBrowserDialog1.ShowDialog() != DialogResult.Cancel)
                        {
                            Properties.Settings.Default.Path = folderBrowserDialog1.SelectedPath;
                            Properties.Settings.Default.Save();

                            int             countContent = R34Parser.GetCountContent(request, R34Parser.GetMaxPid(request));
                            DownloadingForm dlf;
                            if (countContent > 0)
                            {
                                dlf = new DownloadingForm(countContent);
                            }
                            else
                            {
                                dlf = new DownloadingForm(11111);
                            }
                            dlf.ShowDialog();

                            if (Transfer.Limit > 0)
                            {
                                toolStripStatusLabel1.Text    = "Downloading content...";
                                toolStripProgressBar1.Maximum = Transfer.Limit;

                                var progress  = new Progress <int>(s => toolStripProgressBar1.Value = s);
                                var progress2 = new Progress <int>(s => toolStripStatusLabel2.Text = s + " / " + Transfer.Limit);
                                await Task.Factory.StartNew(() => R34Parser.DownloadPages(request, folderBrowserDialog1.SelectedPath, progress, progress2, Transfer.Limit), TaskCreationOptions.LongRunning);

                                toolStripStatusLabel1.Text = "Download completed";
                                if (MessageBox.Show("Download completed! Open the folder?", "Download completed", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                                {
                                    Process.Start(folderBrowserDialog1.SelectedPath);
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Nobody here but us chickens!", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception exp)
            {
                toolStripStatusLabel1.Text = "Download error";
                MessageBox.Show(exp.Message, "Download error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }