Beispiel #1
0
        /// <summary>
        /// Save all Jobs, and the current one which causes the crash to a CrashLog_...txt
        /// </summary>
        /// <param name="exceptionMessage">Exception Message</param>
        /// <param name="stackTrace">Exception Stack Trace</param>
        /// <param name="currentJobInfo">Current Download Job</param>
        public static void SaveOnCrash(string exceptionMessage, string stackTrace, JobInfo currentJobInfo)
        {
            const string ErrMessage =
                "An application error occurred. Please contact Admin (https://ripper.codeplex.com/workitem/list/basic) "
                + "with the following information:";

            var currentDateTime = ReplaceHexWithAscii(DateTime.Now.ToString("G", CultureInfo.InvariantCulture));

            // Save Current Job and the Error to txt file
            var logFileName = string.Format("Crash_{0}.txt", currentDateTime.Replace("/", "-").Replace(" ", "_").Replace(":", "."));

            // Save Current Job and the Error to txt file
            var file = new FileStream(Path.Combine(Application.StartupPath, logFileName), FileMode.CreateNew);
            var sw = new StreamWriter(file);
            sw.WriteLine(ErrMessage);
            sw.Write(sw.NewLine);
            sw.Write(exceptionMessage);
            sw.Write(sw.NewLine);
            sw.Write(sw.NewLine);
            sw.WriteLine("Stack Trace:");
            sw.Write(sw.NewLine);
            sw.Write(stackTrace);
            sw.Write(sw.NewLine);
            sw.Write(sw.NewLine);

            if (currentJobInfo != null)
            {
                sw.WriteLine("Current Job DUMP:");
                sw.Write(sw.NewLine);

                sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                sw.WriteLine(
                    "<ArrayOfJobInfo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
                sw.WriteLine("  <JobInfo>");
                sw.WriteLine("    <StorePath>{0}</StorePath>", currentJobInfo.StorePath);
                sw.WriteLine("    <Title>{0}</Title>", currentJobInfo.TopicTitle);
                sw.WriteLine("    <PostTitle>{0}</PostTitle>", currentJobInfo.PostTitle);
                sw.WriteLine("    <ForumTitle>{0}</ForumTitle>", currentJobInfo.ForumTitle);
                sw.WriteLine("    <URL>{0}</URL>", currentJobInfo.XMLUrl);
                sw.WriteLine("    <XMLPayLoad>{0}</XMLPayLoad>", currentJobInfo.XMLPayLoad);
                sw.WriteLine("    <ImageCount>{0}</ImageCount>", currentJobInfo.ImageCount);
                sw.WriteLine("  </JobInfo>");
                sw.WriteLine("</ArrayOfJobInfo>");
            }

            sw.Close();
            file.Close();
        }
Beispiel #2
0
        /// <summary>
        /// Checks the Path if its too long and shorten path.
        /// </summary>
        /// <param name="job">The current job.</param>
        /// <param name="path">The path.</param>
        /// <param name="forumTitle">if set to <c>true</c> [forum title].</param>
        /// <param name="postTitle">if set to <c>true</c> [post title].</param>
        /// <returns>Returns the Shortened Path</returns>
        private string CheckAndShortenPath(JobInfo job, string path, bool forumTitle, bool postTitle)
        {
            // check path length
            if (path.Length > 248 && forumTitle && !postTitle)
            {
                path = Path.Combine(
                            CacheController.Instance().UserSettings.DownloadFolder,
                            string.Format(
                                "{0}{1}{2}",
                                Utility.RemoveIllegalCharecters(job.ForumTitle),
                                Path.DirectorySeparatorChar,
                                Utility.RemoveIllegalCharecters(job.TopicTitle)));

                path = this.CheckAndShortenPath(job, path, false, false);
            }

            if (path.Length > 248 && !forumTitle && !postTitle)
            {
                path = Path.Combine(
                        CacheController.Instance().UserSettings.DownloadFolder,
                        CacheController.Instance().UserSettings.DownInSepFolder
                            ? string.Format(
                                "{0}{1}{2}",
                                Utility.RemoveIllegalCharecters(job.TopicTitle),
                                Path.DirectorySeparatorChar,
                                Utility.RemoveIllegalCharecters(job.PostTitle))
                            : Utility.RemoveIllegalCharecters(job.TopicTitle));

                path = this.CheckAndShortenPath(job, path, false, false);
            }

            // if Path is still to long simply put in download folder
            if (path.Length > 248)
            {
                path = CacheController.Instance().UserSettings.DownloadFolder;
            }

            return path;
        }
Beispiel #3
0
        /// <summary>
        /// Parse a Thread or Post as Single Job
        /// </summary>
        /// <param name="sHtmlUrl">The Thread/Post Url</param>
        private void EnqueueThreadOrPost(string sHtmlUrl)
        {
            if (jobsList.Any(t => t.HtmlUrl == sHtmlUrl))
            {
                TopMostMessageBox.Show(mAlreadyQueuedMsg, "Info");
                return;
            }

            JobInfo job = new JobInfo { HtmlUrl = sHtmlUrl, HtmlPayLoad = Maintenance.GetInstance().GetPostPages(sHtmlUrl) };

            job.TopicTitle = Utility.ReplaceHexWithAscii(Maintenance.GetInstance().ExtractTopicTitleFromHtml(job.HtmlPayLoad));

            if (CacheController.Instance().UserSettings.AutoThank)
            {
                job.SecurityToken = Utility.GetSecurityToken(job.HtmlPayLoad);
            }

            if (!sHtmlUrl.Contains(@"showthread") || sHtmlUrl.Contains(@"#post"))
            {
                job.PostTitle =
                    Utility.ReplaceHexWithAscii(
                        Maintenance.GetInstance().ExtractPostTitleFromHtml(job.HtmlPayLoad, sHtmlUrl));

                job.ForumTitle = Maintenance.GetInstance().ExtractForumTitleFromHtml(job.HtmlUrl, true);
            }
            else
            {
                job.ForumTitle = Maintenance.GetInstance().ExtractForumTitleFromHtml(job.HtmlUrl, false);
            }

            job.ImageList = ExtractHelper.ExtractImagesHtml(job.HtmlPayLoad, sHtmlUrl);
            job.ImageCount = job.ImageList.Count;

            if (job.ImageCount == 0)
            {
                // Unlock Controls
                this.UnlockControls();

                return;
            }

            if (string.IsNullOrEmpty(job.TopicTitle))
            {
                TopMostMessageBox.Show(sHtmlUrl.IndexOf("threadid=") > 0 ? mNoThreadMsg : mNoPostMsg, "Info");

                // Unlock Controls
                this.UnlockControls();

                return;
            }

            job.StorePath = this.GenerateStorePath(job);

            JobListAddDelegate newJob = this.JobListAdd;

            Invoke(newJob, new object[] { job });

            ///////////////////////////////////////////////
            this.UnlockControls();
            ///////////////////////////////////////////////
        }
Beispiel #4
0
        /// <summary>
        /// Adds new Job to JobList and ListView
        /// </summary>
        /// <param name="job">The new Job</param>
        private void JobListAdd(JobInfo job)
        {
            this.working = true;

            jobsList.Add(job);

            ListViewItem ijobJob = new ListViewItem { Text = job.TopicTitle };

            ijobJob.SubItems.Add(job.PostTitle);
            ijobJob.SubItems.Add(job.ImageCount.ToString());

            listViewJobList.Items.AddRange(new[] { ijobJob });

            this.groupBox5.Text = string.Format("{0} ({1}):", this._ResourceManager.GetString("lblRippingQue"), this.jobsList.Count);
        }
Beispiel #5
0
        /// <summary>
        /// Get All Post of a Thread and Parse them as new Job
        /// </summary>
        /// <param name="htmlUrl">
        /// The html Url.
        /// </param>
        private void ThrdGetPosts(string htmlUrl)
        {
            ThreadToPost threads = new ThreadToPost();

            string pagecontent = threads.GetThreadPagesNew(htmlUrl);

            string forumTitle = Maintenance.GetInstance().ExtractForumTitleFromHtml(htmlUrl, false);

            List<ImageInfo> arlst = threads.ParseHtml(pagecontent);

            for (int po = 0; po < arlst.Count; po++)
            {
                var po1 = po;

                if (this.InvokeRequired)
                {
                    this.Invoke(
                        (MethodInvoker)delegate
                            {
                                this.StatusLabelInfo.Text = string.Format(
                                    "{0}{1}/{2}", this._ResourceManager.GetString("gbParse"), po1, arlst.Count);

                                this.StatusLabelInfo.ForeColor = Color.Green;
                            });
                }
                else
                {
                    this.StatusLabelInfo.Text = string.Format(
                       "{0}{1}/{2}", this._ResourceManager.GetString("gbParse"), po, arlst.Count);
                    this.StatusLabelInfo.ForeColor = Color.Green;
                }

                string postId = arlst[po].ImageUrl;

                //////////////////////////////////////////////////////////////////////////

                if (CacheController.Instance().UserSettings.SavePids && this.IsPostAlreadyRipped(postId))
                {
                    continue;
                }

                string newPostUrl = string.Format(
                    "{0}showpost.php?p={1}#post{1}", CacheController.Instance().UserSettings.CurrentForumUrl, postId);

                JobInfo jobInfoDouble = this.jobsList.Find(doubleJob => doubleJob.HtmlUrl.Equals(newPostUrl));

                if (jobInfoDouble != null)
                {
                    continue;
                }

                if (this.currentJob != null)
                {
                    if (this.currentJob.HtmlUrl.Equals(newPostUrl))
                    {
                        continue;
                    }
                }

                var newJob = new JobInfo
                                 {
                                     HtmlUrl = newPostUrl,
                                     HtmlPayLoad = Maintenance.GetInstance().GetPostPages(newPostUrl)
                                 };

                if (string.IsNullOrEmpty(newJob.HtmlPayLoad))
                {
                    continue;
                }

                newJob.TopicTitle = Maintenance.GetInstance().ExtractTopicTitleFromHtml(newJob.HtmlPayLoad);

                if (CacheController.Instance().UserSettings.AutoThank)
                {
                    newJob.SecurityToken = Utility.GetSecurityToken(newJob.HtmlPayLoad);
                }

                newJob.ForumTitle = forumTitle;

                newJob.PostTitle = Maintenance.GetInstance().ExtractPostTitleFromHtml(newJob.HtmlPayLoad, newPostUrl);
                newJob.TopicTitle = Utility.ReplaceHexWithAscii(newJob.TopicTitle);

                newJob.ImageList = ExtractHelper.ExtractImagesHtml(newJob.HtmlPayLoad, postId);
                newJob.ImageCount = newJob.ImageList.Count;

                if (newJob.ImageCount == 0)
                {
                    continue;
                }

                newJob.StorePath = this.GenerateStorePath(newJob);

                JobListAddDelegate newJobDelegate = this.JobListAdd;

                this.Invoke(newJobDelegate, new object[] { newJob });

                //// JobListAdd(job);

                //////////////////////////////////////////////////////////////////////////
            }
        }
Beispiel #6
0
        /// <summary>
        /// Generates the Storage Folder for the Current Job
        /// </summary>
        /// <param name="job">The Job</param>
        /// <returns>The Storage Folder</returns>
        private string GenerateStorePath(JobInfo job)
        {
            var storePath = CacheController.Instance().UserSettings.DownloadFolder;

            if (!CacheController.Instance().UserSettings.SubDirs)
            {
                return storePath;
            }

            try
            {
                if (job.ForumTitle != null)
                {
                    if (CacheController.Instance().UserSettings.DownInSepFolder)
                    {
                        storePath = this.CheckAndShortenPath(
                            job,
                            Path.Combine(
                                CacheController.Instance().UserSettings.DownloadFolder,
                                string.Format(
                                    "{0}{1}{2}{1}{3}",
                                    Utility.RemoveIllegalCharecters(job.ForumTitle),
                                    Path.DirectorySeparatorChar,
                                    Utility.RemoveIllegalCharecters(job.TopicTitle),
                                    Utility.RemoveIllegalCharecters(job.PostTitle))),
                            true,
                            false);
                    }
                    else
                    {
                        storePath = this.CheckAndShortenPath(
                            job,
                            Path.Combine(
                                CacheController.Instance().UserSettings.DownloadFolder,
                                string.Format(
                                    "{0}{1}{2}",
                                    Utility.RemoveIllegalCharecters(job.ForumTitle),
                                    Path.DirectorySeparatorChar,
                                    Utility.RemoveIllegalCharecters(job.TopicTitle))),
                            false,
                            false);
                    }
                }
                else
                {
                    storePath = this.CheckAndShortenPath(
                        job,
                        Path.Combine(
                            CacheController.Instance().UserSettings.DownloadFolder,
                            CacheController.Instance().UserSettings.DownInSepFolder
                                ? string.Format(
                                    "{0}{1}{2}",
                                    Utility.RemoveIllegalCharecters(job.TopicTitle),
                                    Path.DirectorySeparatorChar,
                                    Utility.RemoveIllegalCharecters(job.PostTitle))
                                : Utility.RemoveIllegalCharecters(job.TopicTitle)),
                        false,
                        false);
                }

                var renameCount = 2;

                var begining = storePath;

                // Auto Rename if post titles are the same...
                if (this.jobsList.Count != 0)
                {
                    var path = storePath;

                    foreach (JobInfo t in
                        this.jobsList.Where(
                            t =>
                            t.PostTitle.Equals(job.PostTitle) ||
                            Directory.Exists(path) && t.TopicTitle.Equals(job.TopicTitle)))
                    {
                        while (t.StorePath.Equals(storePath) || Directory.Exists(storePath))
                        {
                            storePath = string.Format("{0} Set# {1}", begining, renameCount);
                            renameCount++;
                        }
                    }
                }
                else
                {
                    while (Directory.Exists(storePath))
                    {
                        storePath = string.Format("{0} Set# {1}", begining, renameCount);
                        renameCount++;
                    }
                }
            }
            catch (Exception)
            {
                storePath = Path.Combine(
                    CacheController.Instance().UserSettings.DownloadFolder,
                    Utility.RemoveIllegalCharecters(job.TopicTitle));
            }

            return storePath;
        }
Beispiel #7
0
        /// <summary>
        /// Get All Post of a Thread and Parse them as new Job
        /// </summary>
        /// <param name="sXMLUrl">
        /// The s Xml Url.
        /// </param>
        private void ThrdGetPosts(string sXMLUrl)
        {
            string sPagecontent = Utility.GetForumPageAsString(sXMLUrl);

            var arlst = ExtractHelper.ExtractThreadtoPosts(sPagecontent);

            string sToken = Utility.GetSecurityToken(new Uri(CacheController.Instance().UserSettings.ForumURL));

            for (int po = 0; po < arlst.Count; po++)
            {
                var po1 = po;

                if (this.InvokeRequired)
                {
                    this.Invoke(
                        (MethodInvoker)delegate
                        {
                            this.StatusLabelInfo.Text = string.Format(
                                "{0}{1}/{2}", this._ResourceManager.GetString("gbParse"), po1, arlst.Count);

                            StatusLabelInfo.ForeColor = Color.Green;
                        });
                }
                else
                {
                    this.StatusLabelInfo.Text = string.Format(
                       "{0}{1}/{2}", this._ResourceManager.GetString("gbParse"), po, arlst.Count);
                    StatusLabelInfo.ForeColor = Color.Green;
                }

                string currentPostId = arlst[po].ImageUrl;

                //////////////////////////////////////////////////////////////////////////

                if (CacheController.Instance().UserSettings.SavePids && this.IsPostAlreadyRipped(currentPostId))
                {
                    continue;
                }

                var composedXMLUrl = string.Format(
                    "{0}getSTDpost-imgXML.php?dpver=2&postid={1}",
                    CacheController.Instance().UserSettings.ForumURL,
                    currentPostId);
                var composedHtmlUrl = string.Format("http://vipergirls.to/showpost.php?p={0}", currentPostId);

                var jobInfo = this.jobsList.Find(doubleJob => doubleJob.XMLUrl.Equals(composedXMLUrl));

                if (jobInfo != null)
                {
                    continue;
                }

                if (this.currentJob != null)
                {
                    if (this.currentJob.XMLUrl.Equals(composedXMLUrl))
                    {
                        continue;
                    }
                }

                JobInfo job = new JobInfo
                                  {
                                      XMLUrl = composedXMLUrl,
                                      HtmlUrl = composedHtmlUrl,
                                      XMLPayLoad = Utility.GetForumPageAsString(composedXMLUrl),
                                      HtmlPayLoad = Utility.GetForumPageAsString(composedHtmlUrl)
                                  };

                job.ImageCount = Maintenance.GetInstance().CountImagesFromXML(job.XMLPayLoad);

                if (job.ImageCount.Equals(0))
                {
                    continue;
                }

                job.PostTitle =
                    Utility.ReplaceHexWithAscii(Maintenance.GetInstance().ExtractPostTitleFromHtml(job.HtmlPayLoad, job.HtmlUrl));
                job.ForumTitle = Maintenance.GetInstance().ExtractForumTitleFromXML(job.XMLPayLoad);
                job.TopicTitle =
                    Utility.ReplaceHexWithAscii(Maintenance.GetInstance().ExtractTopicTitleFromHtml(job.HtmlPayLoad));

                job.StorePath = this.GenerateStorePath(job);

                ProcessAutoThankYou(currentPostId, job.ImageCount, job.XMLUrl, sToken);

                //JobListAdd(job);
                JobListAddDelegate newJob = JobListAdd;
                Invoke(newJob, new object[] { job });

                //////////////////////////////////////////////////////////////////////////
            }
        }
Beispiel #8
0
        /// <summary>
        /// Removes a Job from the Joblist and ListView
        /// </summary>
        /// <param name="jiDelete"></param>
        /// <param name="iJobIndex">The Index of the Job inside the Joblist</param>
        private void JobListRemove(JobInfo jiDelete, int iJobIndex)
        {
            //mJobsList.RemoveAt(iJobIndex);
            jobsList.Remove(jiDelete);

            listViewJobList.Items.RemoveAt(iJobIndex);

            groupBox5.Text = string.Format("{0} ({1}):", _ResourceManager.GetString("lblRippingQue"), jobsList.Count);
        }
Beispiel #9
0
        /// <summary>
        /// Full Disc Handling
        /// </summary>
        private void FullDisc()
        {
            bWorking = false;
            bFullDisc = true;

            pauseCurrentThreads.Text = "Resume Download(s)";
            ThreadManager.GetInstance().HoldAllThreads();

            StatusLabelInfo.Text = DeleteMessage;
            StatusLabelInfo.ForeColor = Color.Red;

            TopMostMessageBox.Show(string.Format("Please change your download location, then press \"Resume Download\", because {0}", DeleteMessage), "Warning");

            UpdateDownloadFolder();

            //JobListAdd(mCurrentJob);

            JobListAddDelegate newJob = JobListAdd;
            Invoke(newJob, new object[] { currentJob });

            currentJob = null;
            StatusLabelInfo.Text = string.Empty;
            lvCurJob.Items.Clear();

            for (int i = 0; i != jobsList.Count; i++)
            {
                JobInfo updatedJob = new JobInfo
                                         {
                                             ImageCount = jobsList[i].ImageCount,
                                             PostTitle = jobsList[i].PostTitle
                                         };

                //updatedJob.sStorePath = sDownloadFolder;

                if (CacheController.Instance().UserSettings.SubDirs)
                {
                    switch (this.comboBox1.SelectedIndex)
                    {
                        case 0:
                            updatedJob.StorePath = Path.Combine(CacheController.Instance().UserSettings.DownloadFolder, this.jobsList[i].TopicTitle);
                            break;
                        case 2:
                        case 1:
                            updatedJob.StorePath = Path.Combine(CacheController.Instance().UserSettings.DownloadFolder, this.jobsList[i].TopicTitle + Path.DirectorySeparatorChar + this.jobsList[i].PostTitle);
                            break;
                    }
                }

                updatedJob.TopicTitle = jobsList[i].TopicTitle;
                updatedJob.XMLUrl = jobsList[i].XMLUrl;
                updatedJob.XMLPayLoad = jobsList[i].XMLPayLoad;

                JobListRemove(jobsList[i], i);

                jobsList.Insert(i, updatedJob);
            }

            bFullDisc = false;
        }
Beispiel #10
0
        /// <summary>
        /// Parse a Thread or Post as Single Job
        /// </summary>
        /// <param name="xmlURL">The Thread/Post Url</param>
        private void EnqueueThreadOrPost(string xmlURL, string htmlURL)
        {
            if (this.jobsList.Any(t => t.XMLUrl == xmlURL))
            {
                TopMostMessageBox.Show(this.mAlreadyQueuedMsg, "Info");

                this.UnlockControls();

                return;
            }

            JobInfo job = new JobInfo
                              {
                                  XMLUrl = xmlURL,
                                  HtmlUrl = htmlURL,
                                  XMLPayLoad = Utility.GetForumPageAsString(xmlURL),
                                  HtmlPayLoad = Utility.GetForumPageAsString(htmlURL)
                              };

            job.ImageCount = Maintenance.GetInstance().CountImagesFromXML(job.XMLPayLoad);

            if (job.ImageCount.Equals(0))
            {
                this.UnlockControls();
            }

            job.PostTitle = Maintenance.GetInstance().ExtractPostTitleFromHtml(job.HtmlPayLoad, job.HtmlUrl);
            job.ForumTitle = Maintenance.GetInstance().ExtractForumTitleFromXML(job.XMLPayLoad);
            job.TopicTitle = Maintenance.GetInstance().ExtractTopicTitleFromHtml(job.HtmlPayLoad);
            job.TopicTitle = Utility.ReplaceHexWithAscii(job.TopicTitle);
            job.PostTitle = Utility.ReplaceHexWithAscii(job.PostTitle);

            job.PostIds = Maintenance.GetInstance().GetAllPostIds(job.XMLPayLoad);

            job.StorePath = this.GenerateStorePath(job);

            if (string.IsNullOrEmpty(job.TopicTitle))
            {
                TopMostMessageBox.Show(xmlURL.IndexOf("threadid=") > 0 ? this.mNoThreadMsg : this.mNoPostMsg, "Info");

                this.UnlockControls();

                return;
            }

            if (CacheController.Instance().UserSettings.AutoThank)
            {
                var token = Utility.GetSecurityToken(new Uri(CacheController.Instance().UserSettings.ForumURL));

                foreach (string postId in job.PostIds)
                {
                    this.ProcessAutoThankYou(postId, job.ImageCount, job.XMLUrl, token);
                }
            }

            JobListAddDelegate newJob = this.JobListAdd;
            this.Invoke(newJob, new object[] { job });

            ///////////////////////////////////////////////
            this.UnlockControls();
            ///////////////////////////////////////////////
        }