private bool downloadImage(Submission sub, Website site, bool scraps = false) { bool status = false; try { sub = site.getSubInfo(sub); if (!sub.scrap || (sub.scrap && scraps)) { byte[] image = site.getImage(sub.fileSource); datahandler.createFile(sub.domain, sub.fileSource, sub.pageSource, sub.author, sub.filename, image, sub.scrap); } status = true; } catch (Exception e) { Console.WriteLine(e + Environment.NewLine + sub.pageSource.ToString() + Environment.NewLine + sub.id); } lock (locker) downloadList.Remove(sub.pageSource.ToString()); ProgressArg prog = new ProgressArg(true, true); onUpdateProgress(prog); threadCount--; return(status); }
private void searchDownload(string searchString, Website site, bool scraps) { List <Submission> subList = new List <Submission>(); subList = site.getSearchSubs(searchString); if (subList == null || !subList.Any()) { Console.WriteLine("Error while retrieving submissions."); return; } subList.Reverse(); string ID = string.Format("Search for {0} on {1}", searchString, site.Name); usersDownloading.Add(ID); ProgressArg e = new ProgressArg(subList.Count()); onUpdateProgress(e); downloadSubmissions(subList, site, scraps); Console.WriteLine(string.Format("Search for {0} on {1} has finished downloading.", searchString, site.Name)); usersDownloading.Remove(ID); }
private void getSubscription(int pageLimit, Website site, bool scraps) { List <Submission> submissions = new List <Submission>(); submissions = site.getSubscription(pageLimit); if (submissions == null || !submissions.Any()) { Console.WriteLine("Error while retrieving submissions."); return; } submissions.Reverse(); string ID = "Subscription " + site.Name; usersDownloading.Add(ID); ProgressArg e = new ProgressArg(submissions.Count()); onUpdateProgress(e); downloadSubmissions(submissions, site, scraps); Console.WriteLine(string.Format("Subscription on {0} has finished.", site.Name)); usersDownloading.Remove(ID); }
public void updateProgressbar(object sender, EventArgs e) { if (!isClosing) { ProgressArg progress = (ProgressArg)e; if (!progress.files) { if (InvokeRequired) { this.Invoke(new MethodInvoker(delegate { totalFiles += progress.amount; remaining += progress.amount; button_stop.Enabled = true; progressBar1.Maximum = remaining; progressBar1.Value = 0; label_numFiles.Text = totalFiles.ToString(); label_leftToDownload.Text = remaining.ToString(); })); } } else { if (InvokeRequired) { this.Invoke(new MethodInvoker(delegate { progressBar1.Increment(1); numFiles++; remaining--; label_leftToDownload.Text = remaining.ToString(); if (remaining <= 0) { progressBar1.Maximum = 0; progressBar1.Value = 0; button_stop.Enabled = false; } label_filesDownloaded.Text = numFiles.ToString(); if (progress.newFiles) { newFiles++; label_newFilesDownloaded.Text = newFiles.ToString(); } })); } } } }
private bool downloadImage(Submission sub, bool scraps = false) { bool status = false; try { var site = getSite(sub.site); if (site == null) { Console.WriteLine("Site is null", sub); return(false); } sub = site.getSubInfo(sub); if (!sub.scrap || (sub.scrap && scraps)) { byte[] image = site.getImage(sub.fileSource); datahandler.createFile(sub.domain, sub.fileSource, sub.pageSource, sub.author, sub.filename, image, sub.scrap); } status = true; } catch (Exception e) { Console.WriteLine(e + Environment.NewLine + sub.pageSource.ToString() + Environment.NewLine + sub.id); lock (fLock) failedDownloads.Add(sub); ProgressFail prf = new ProgressFail(); onUpdateProgress(prf); } finally { lock (locker) downloadList.Remove(sub.pageSource.ToString()); ProgressArg prog = new ProgressArg(true, true); onUpdateProgress(prog); threadCount--; } return(status); }
private void getSubs(string user, Website site, bool scraps) { string userThreadID; //if (scraps) // userThreadID = user + " scraps"; //else userThreadID = string.Format("{0} {1}", user, site.Name); usersDownloading.Add(userThreadID); List <Submission> submissions; submissions = site.loadSubbmissionsFromUser(user, scraps); if (submissions == null) { Console.WriteLine("Error while retrieving submissions."); return; } submissions.Reverse(); Console.WriteLine(string.Format("Found {0} submissions for {1} on {2}", submissions.Count, user, site.Name)); ProgressArg e = new ProgressArg(submissions.Count()); onUpdateProgress(e); downloadSubmissions(submissions, site, scraps); Console.WriteLine(userThreadID + " has finished downloading."); usersDownloading.Remove(userThreadID); }