示例#1
0
        /// <summary>
        /// Checks to see if there is a new page of Homestuck.
        /// If there is, gets the new latest page and changes the
        /// latestPage parameter to match.
        /// </summary>
        /// <param name="latestPage">
        /// Passed in: the current latest page. If there is a new
        /// page from the current latest page, this is changed to
        /// be the new latest page.
        /// </param>
        /// <returns>
        /// Information on the new page, and whether or not there
        /// is a new page.
        /// </returns>
        static PageCheckResults CheckForNewPage(ref int latestPage)
        {
            PageCheckResults result;
            if (HSPageExists(latestPage + 1))
                result = new PageCheckResults
                {
                    newPageExists = true,
                    page = GetPageInformation(latestPage + 1)
                };
            else if (HSPageExists(latestPage + 2))
                result = new PageCheckResults
                {
                    newPageExists = true,
                    page = GetPageInformation(latestPage + 2)
                };
            else
                result = new PageCheckResults
                {
                    newPageExists = false
                };

            if (result.newPageExists)
            {
                Console.WriteLine("Page found. Updating latestPage...");
                latestPage = UpdateLatestPage(beginningTestPage: latestPage);
                // number of pages: new latest page - found new page number + 1
                result.numberOfPages = latestPage - result.page.number + 1;
            }

            return result;
        }
示例#2
0
        static void UpdateNewPageJson(PageCheckResults page)
        {
            string filename;
            if (CommandLineOptions.JsonFile != null)
                filename = CommandLineOptions.JsonFile;
            else
                filename = "new-page.json";

            string json = JsonConvert.SerializeObject(page, Formatting.Indented);

            Encoding utf8NoBOM = new UTF8Encoding(false);
            File.WriteAllText(filename, json, utf8NoBOM);
        }