bool WritePage(WrapBGW bgw, int currentPage, int currentProgress, int x2phase, Parser parser) { try { var res = parser.GetResources(); var links = parser.GetLinks(); var text = parser.GetText(); if (bgw != null) bgw.ReportProgress(currentProgress, "Page " + currentPage + ": " + text.title); if (text.narr == null) { if (bgw != null) bgw.ReportProgress(currentProgress, text.promptType); for (int i = 0; i < text.lines.Count(); ++i) { if (!text.lines[i].isImg) { if (bgw != null) bgw.ReportProgress(currentProgress, (text.lines[i].subTexts != null ? text.lines[i].subTexts.Count() : 0) + " special subtexts, Colour: " + text.lines[i].hexColour + ": " + text.lines[i].text); } else if (bgw != null) bgw.ReportProgress(currentProgress, "Imageline"); } } else if(bgw != null) bgw.ReportProgress(currentProgress, "Narrative: " + text.narr.text); if(bgw != null) for (int i = 0; i < links.Count(); ++i) bgw.ReportProgress(currentProgress, "\"" + links[i].originalText + "\" links to " + links[i].pageNumber); for (int i = 0; i < res.Count(); ++i) { var fileSize = res[i].data.Count(); totalMegabytesDownloaded += (float)fileSize / (1024.0f * 1024.0f); if (bgw != null) bgw.ReportProgress(currentProgress, res[i].originalFileName + ": " + fileSize / 1024 + "KB"); } if (bgw != null) bgw.ReportProgress(currentProgress, "Total Data Downloaded: " + (int)totalMegabytesDownloaded + "MB"); if (bgw != null && x2phase != 1) bgw.ReportProgress(currentProgress, ""); var p = new Page(currentPage, text, res, links); p.x2 = x2phase == 2; WritePageToDB(p); if (x2phase != 1) { archivedPages.Add(currentPage); } } catch { Debugger.Break(); if (bgw != null) bgw.ReportProgress(currentProgress, "Error in archiving page: " + currentPage); return false; } return true; }
void HandleYoutubeVideo(WrapBGW bgw, int progress, bool AIsCollide) { //do not under any circumstances let 2 videos download at once, it'll kill the memory lock (FVideoDownloadLock) { if (bgw != null) bgw.ReportProgress(progress, "Now parsing " + (AIsCollide ? " Collide." : "the end...") + " This will take a while...", true); var VidObject = YouTube.Default.GetVideo(AIsCollide ? "https://www.youtube.com/watch?v=Y5wYN6rB_Rg" : "https://www.youtube.com/watch?v=FevMNMwvdPw"); var DLTask = VidObject.GetBytesAsync(); if (bgw != null) do { Thread.Sleep(100); if (bgw.bgw.Cancelled()) { bgw.ReportProgress(progress, "Video download cancelled"); throw new Exception(); } } while (!DLTask.IsCompleted); Parser.Resource[] TheVid = new Parser.Resource[1]; TheVid[0] = new Parser.Resource(DLTask.Result, "video" + VidObject.FileExtension); var fileSize2 = TheVid[0].data.Count(); totalMegabytesDownloaded += (float)fileSize2 / (1024.0f * 1024.0f); if (bgw != null) bgw.ReportProgress(progress, TheVid[0].originalFileName + ": " + fileSize2 / 1024 + "KB"); Parser.Text asdf = new Parser.Text(); Parser.Link[] lnk = new Parser.Link[1]; asdf.narr = new Parser.Text.ScriptLine("#000000", "", 0); if (AIsCollide) { asdf.title = "[S] Collide"; lnk[0] = new Parser.Link("END OF ACT 6", (int)PagesOfImportance.COLLIDE + 1); } else { asdf.narr = new Parser.Text.ScriptLine("#000000", "", 0); asdf.title = "[S] ACT 7"; lnk[0] = new Parser.Link("==>", (int)PagesOfImportance.ACT7 + 1); } WritePageToDB(new Page(AIsCollide ? (int)PagesOfImportance.COLLIDE : (int)PagesOfImportance.ACT7, asdf, TheVid, new Parser.Link[0])); GC.Collect(); } }
bool SavePage(int currentPage, WrapBGW bgw = null, int currentProgress = 0) { if (Enum.IsDefined(typeof(PagesOfImportance), currentPage)) { try { switch ((PagesOfImportance)currentPage) { case PagesOfImportance.CASCADE: HandleCascade(bgw, currentProgress); break; case PagesOfImportance.CALIBORN_PAGE_SMASH: HandlePageSmash(bgw, currentProgress); break; case PagesOfImportance.CALIBORN_PAGE_SMASH2: HandlePageSmash2(bgw, currentProgress); break; case PagesOfImportance.DOTA: HandleDota(bgw, currentProgress); break; case PagesOfImportance.SHES8ACK: FailToHandleVriska(bgw, currentProgress); break; case PagesOfImportance.GAMEOVER: FailMiserably(bgw, currentProgress); break; case PagesOfImportance.OVERSHINE: HandleOvershine(bgw, currentProgress); break; case PagesOfImportance.JAILBREAK_LAST_PAGE: HandleJailbreakLast(bgw, currentProgress); break; case PagesOfImportance.COLLIDE: case PagesOfImportance.ACT7: HandleYoutubeVideo(bgw, currentProgress, (PagesOfImportance)currentPage == PagesOfImportance.COLLIDE); break; } archivedPages.Add(currentPage); } catch { if (bgw != null && !bgw.bgw.Cancelled()) bgw.ReportProgress(currentProgress, "Error parsing special page " + currentPage); return false; } finally { if (bgw != null) bgw.ReportProgress(currentProgress, ""); } return true; } if (archivedPages.IsPageArchived(currentPage)) return true; if (Parser.IsTrickster(currentPage)) ParseTrickster(); if (Parser.Is2x(currentPage)) Parsex2Header(); if (Enum.IsDefined(typeof(PasswordPages), currentPage + 1)) ParseTerezi(); if(bgw != null && Parser.IsOpenBound(currentPage)) bgw.ReportProgress(currentProgress, "Parsing an Openbound page. There are tons of tiny downloads and this will take a couple minutes..."); using (var parser = new Parser()) { if (parser.LoadPage(currentPage)) { int missedPages = 0; if (!parser.x2Flag) { if (!WritePage(bgw, currentPage, currentProgress, 0, parser)) missedPages++; } else { if (!WritePage(bgw, currentPage, currentProgress, 1, parser)) missedPages += 2; else { parser.Reparse(); if (!WritePage(bgw, currentPage, currentProgress, 2, parser)) missedPages += 2; } } //simple enough, leave it to the reader to decode the multiple pages return missedPages == 0; } else return false; } }
void HandleOvershine(WrapBGW bgw, int progress) { if (bgw != null) bgw.ReportProgress(progress, "Now parsing zap."); Parser.Resource[] FUCKYOU = new Parser.Resource[1]; FUCKYOU[0] = new Parser.Resource(Parser.DownloadFile("http://cdn.mspaintadventures.com/storyfiles/hs2/07401.gif"), "07401.gif"); var fileSize2 = FUCKYOU[0].data.Count(); totalMegabytesDownloaded += (float)fileSize2 / (1024.0f * 1024.0f); if (bgw != null) bgw.ReportProgress(progress, FUCKYOU[0].originalFileName + ": " + fileSize2 / 1024 + "KB"); Parser.Text asdf = new Parser.Text(); asdf.narr = new Parser.Text.ScriptLine("#000000", "", 0); asdf.title = ""; Parser.Link[] lnk = new Parser.Link[1]; lnk[0] = new Parser.Link("[S][A6A6I4] ====>", (int)PagesOfImportance.OVERSHINE + 1); WritePageToDB(new Page((int)PagesOfImportance.OVERSHINE, asdf, FUCKYOU, lnk)); }
void HandlePageSmash2(WrapBGW bgw, int progress) { if (bgw != null) bgw.ReportProgress(progress, "Now parsing Caliborn's second hissy fit."); Parser.Resource[] FUCKYOU = new Parser.Resource[1]; FUCKYOU[0] = new Parser.Resource(Parser.DownloadFile("http://www.mspaintadventures.com/007680/05777_2.swf"), "05777_2.swf"); var fileSize2 = FUCKYOU[0].data.Count(); totalMegabytesDownloaded += (float)fileSize2 / (1024.0f * 1024.0f); if (bgw != null) bgw.ReportProgress(progress, FUCKYOU[0].originalFileName + ": " + fileSize2 / 1024 + "KB"); Parser.Link[] lnk = new Parser.Link[1]; lnk[0] = new Parser.Link("", (int)PagesOfImportance.CALIBORN_PAGE_SMASH2 + 1); Parser.Text asdf = new Parser.Text(); asdf.narr = new Parser.Text.ScriptLine("#000000", "", 0); asdf.title = "[S] Cascade."; WritePageToDB(new Page((int)PagesOfImportance.CALIBORN_PAGE_SMASH2, asdf, FUCKYOU, lnk)); }
void HandleJailbreakLast(WrapBGW bgw, int progress) { if (bgw != null) bgw.ReportProgress(progress, "Now parsing your victory."); Parser.Resource[] FUCKYOU = new Parser.Resource[1]; FUCKYOU[0] = new Parser.Resource(Parser.DownloadFile("http://cdn.mspaintadventures.com/storyfiles/jb2/YOUWIN.gif"), "YOUWIN.gif"); var fileSize2 = FUCKYOU[0].data.Count(); totalMegabytesDownloaded += (float)fileSize2 / (1024.0f * 1024.0f); if (bgw != null) bgw.ReportProgress(progress, FUCKYOU[0].originalFileName + ": " + fileSize2 / 1024 + "KB"); Parser.Text asdf = new Parser.Text(); asdf.narr = new Parser.Text.ScriptLine("#000000", "Would you like to play again?", 0); asdf.title = "Enjoy restful slumber."; WritePageToDB(new Page((int)PagesOfImportance.JAILBREAK_LAST_PAGE, asdf, FUCKYOU, new Parser.Link[0])); }
void HandleDota(WrapBGW bgw, int progress) { if (bgw != null) bgw.ReportProgress(progress, "Now parsing Hussie's rekage."); Parser.Resource[] FUCKYOU = new Parser.Resource[1]; FUCKYOU[0] = new Parser.Resource(Parser.DownloadFile("http://cdn.mspaintadventures.com/DOTA/04812.swf"), "04812.swf"); var fileSize2 = FUCKYOU[0].data.Count(); totalMegabytesDownloaded += (float)fileSize2 / (1024.0f * 1024.0f); if (bgw != null) bgw.ReportProgress(progress, FUCKYOU[0].originalFileName + ": " + fileSize2 / 1024 + "KB"); Parser.Text asdf = new Parser.Text(); asdf.narr = new Parser.Text.ScriptLine("#000000", "", 0); asdf.title = ""; Parser.Link[] lnk = new Parser.Link[1]; lnk[0] = new Parser.Link("", (int)PagesOfImportance.DOTA + 1); WritePageToDB(new Page((int)PagesOfImportance.DOTA, asdf, FUCKYOU, lnk)); }
void HandleCascade(WrapBGW bgw, int progress) { //cascade is hosted on newgrounds //also its split into a loader and 5 segments /* * Thank you based /u/Niklink http://uploads.ungrounded.net/userassets/3591000/3591093/cascade_loaderExt.swf http://uploads.ungrounded.net/userassets/3591000/3591093/cascade_segment1.swf http://uploads.ungrounded.net/userassets/3591000/3591093/cascade_segment2.swf http://uploads.ungrounded.net/userassets/3591000/3591093/cascade_segment3.swf http://uploads.ungrounded.net/userassets/3591000/3591093/cascade_segment4.swf http://uploads.ungrounded.net/userassets/3591000/3591093/cascade_segment5.swf * * They are actually also availiable on the www and cdn, so we can try those too */ if (bgw != null) bgw.ReportProgress(progress, "Now parsing Cascade", true); Parser.Resource[] cascadeSegments = new Parser.Resource[7]; Parser.Link[] next = new Parser.Link[1]; next[0] = new Parser.Link("END OF ACT 5", (int)PagesOfImportance.CASCADE + 1); try { cascadeSegments[0] = new Parser.Resource(Parser.DownloadFile("http://uploads.ungrounded.net/userassets/3591000/3591093/cascade_loaderExt.swf"), "cascade_loaderExt.swf"); } catch { cascadeSegments[0] = new Parser.Resource(Parser.DownloadFile("http://cdn.mspaintadventures.com/cascade/cascade_loaderExt.swf"), "cascade_loaderExt.swf"); } var fileSize = cascadeSegments[0].data.Count(); totalMegabytesDownloaded += (float)fileSize / (1024.0f * 1024.0f); if (bgw != null) { bgw.ReportProgress(progress, cascadeSegments[0].originalFileName + ": " + fileSize / 1024 + "KB"); if (bgw.bgw.Cancelled()) { bgw.ReportProgress(progress, "Cascade download cancelled"); throw new Exception(); } } for (int i = 1; i <= 5; ++i){ try { cascadeSegments[i] = new Parser.Resource(Parser.DownloadFile("http://uploads.ungrounded.net/userassets/3591000/3591093/cascade_segment" + i + ".swf"), "cascade_segment" + i + ".swf"); } catch { cascadeSegments[i] = new Parser.Resource(Parser.DownloadFile("http://cdn.mspaintadventures.com/cascade/cascade_segment" + i + ".swf"), "cascade_segment" + i + ".swf"); } var fileSize2 = cascadeSegments[i].data.Count(); totalMegabytesDownloaded += (float)fileSize2 / (1024.0f * 1024.0f); if (bgw != null) { bgw.ReportProgress(progress, cascadeSegments[i].originalFileName + ": " + fileSize2 / 1024 + "KB"); if (bgw.bgw.Cancelled()) { bgw.ReportProgress(progress, "Cascade download cancelled"); throw new Exception(); } } } cascadeSegments[6] = new Parser.Resource(Parser.DownloadFile("http://www.mspaintadventures.com/images/header_cascade.gif"), "header_cascade.gif"); Parser.Text asdf = new Parser.Text(); asdf.narr = new Parser.Text.ScriptLine("#000000", "", 0); asdf.title = "[S] Cascade."; WritePageToDB(new Page((int)PagesOfImportance.CASCADE, asdf, cascadeSegments, next)); if (bgw != null) bgw.ReportProgress(progress, "Cascade committed!"); }
void FailToHandleVriska(WrapBGW bgw, int progress) { if (bgw != null) bgw.ReportProgress(progress, "Now parsing the huge 8itch."); Parser.Resource[] FUCKYOU = new Parser.Resource[1]; FUCKYOU[0] = new Parser.Resource(Parser.DownloadFile("http://www.mspaintadventures.com/shes8ack/07402.swf"), "07402.swf"); var fileSize2 = FUCKYOU[0].data.Count(); totalMegabytesDownloaded += (float)fileSize2 / (1024.0f * 1024.0f); if (bgw != null) bgw.ReportProgress(progress, FUCKYOU[0].originalFileName + ": " + fileSize2 / 1024 + "KB"); Parser.Text asdf = new Parser.Text(); asdf.narr = new Parser.Text.ScriptLine("#000000", "", 0); asdf.title = ""; Parser.Link[] lnk = new Parser.Link[1]; lnk[0] = new Parser.Link("", (int)PagesOfImportance.SHES8ACK + 1); WritePageToDB(new Page((int)PagesOfImportance.SHES8ACK, asdf, FUCKYOU, lnk)); }
void FailMiserably(WrapBGW bgw, int progress) { if (bgw != null) bgw.ReportProgress(progress, "Now parsing death."); Parser.Resource[] FUCKYOU = new Parser.Resource[1]; FUCKYOU[0] = new Parser.Resource(Parser.DownloadFile("http://cdn.mspaintadventures.com/storyfiles/hs2/GAMEOVER/06898.swf"), "06898.swf"); var fileSize2 = FUCKYOU[0].data.Count(); totalMegabytesDownloaded += (float)fileSize2 / (1024.0f * 1024.0f); if (bgw != null) bgw.ReportProgress(progress, FUCKYOU[0].originalFileName + ": " + fileSize2 / 1024 + "KB"); Parser.Text asdf = new Parser.Text(); asdf.narr = new Parser.Text.ScriptLine("#000000", "", 0); asdf.title = ""; Parser.Link[] lnk = new Parser.Link[1]; lnk[0] = new Parser.Link("", (int)PagesOfImportance.GAMEOVER + 1); WritePageToDB(new Page((int)PagesOfImportance.GAMEOVER, asdf, FUCKYOU, lnk)); }