public async Task KissManga_Test() { string url = "http://kissmanga.com/Manga/Onepunch-Man"; var service = new KissManga(logger, downloader, new HtmlAtilityPackAdapter(), new JurassicScriptEngine()); Assert.IsTrue(service.Of(url)); var chapters = await service.FindChapters(url, new Progress <int>(), source.Token); Assert.IsTrue(chapters.Any(), "Cannot find chapters."); var chapter = chapters.Last(); Assert.AreEqual("Onepunch-Man", chapter.Manga); Assert.AreEqual("Onepunch-Man 001", chapter.DisplayName); Assert.AreEqual("http://kissmanga.com/Manga/Onepunch-Man/Punch-001?id=369844", chapter.Url); var images = await service.FindImages(chapter, new Progress <int>(), source.Token); Assert.AreEqual(28, images.Count()); Assert.IsTrue(images.ToArray()[0].StartsWith("https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?container=focus&gadget=a&no_expand=1&resize_h=0&rewriteMime=image%2F*&url=http%3a%2f%2f2.bp.blogspot.com%2f-daAIY2sJQcE%2fV8rt280634I%2fAAAAAAAA404%2fLd1A6XZGrvcKioYmulO4MG8RcbPJf8zagCHM%2fs16000%2f0001-001.png&imgmax=30000")); Assert.IsTrue(images.ToArray()[1].StartsWith("https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?container=focus&gadget=a&no_expand=1&resize_h=0&rewriteMime=image%2F*&url=http%3a%2f%2f2.bp.blogspot.com%2f-cx66pnwxYF4%2fV8rt3BUIFuI%2fAAAAAAAA408%2fC9nPR0AhT-oiTLiUzrKoo_K4JpGhv8OHACHM%2fs16000%2f0001-002.png&imgmax=30000")); Assert.IsTrue(images.ToArray()[2].StartsWith("https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?container=focus&gadget=a&no_expand=1&resize_h=0&rewriteMime=image%2F*&url=http%3a%2f%2f2.bp.blogspot.com%2f-EfldQUNYKe8%2fV8rt3cmh-nI%2fAAAAAAAA41A%2f_O27IwHy_FkjCy8epn_zhccCy-6KRyCTwCHM%2fs16000%2f0001-003.png&imgmax=30000")); string imageString = await downloader.DownloadStringAsync(images.ToArray()[0], source.Token); Assert.IsNotNull(imageString, "Cannot download image!"); }
private void BtnAdd_Click(object sender, EventArgs e) { string url = gfxBrowser.Url.ToString(); string name = string.Empty; string num = string.Empty; switch (cmboSource.SelectedItem.ToString().ToLower()) { case "mangadex": name = url.Split('/')[5]; num = url.Split('/')[4]; url = MangaDexHelper.MANGADEX_URL + "/api/manga/" + num; Manga m = new MangaDex(FileHelper.CreateDI(Path.Combine(FileHelper.APP_ROOT.FullName, num)), url); FrmEdit editor = new FrmEdit(m, false); DialogResult result = editor.ShowDialog(); if (result == DialogResult.OK) { // cleanup foreach (Chapter ch in m.GetChapters()) { try { string s = ch.GetChapterRoot().ToString(); Directory.Delete(ch.GetChapterRoot().ToString()); } catch (Exception) { } } WFClient.dbm.GetMangaDB().Add(m); String[] dls = m.GetDLChapters(); if (dls == null || dls[0].Equals("-1")) { foreach (Chapter c in m.GetSetPrunedChapters(false)) { WFClient.dlm.AddToQueue(new MangaDexDownload(c)); } } else { // Only download selected chapters foreach (Chapter c in m.GetSetPrunedChapters(false)) { if (dls.Contains(c.GetNum())) { WFClient.dlm.AddToQueue(new MangaDexDownload(c)); } } } // Start downloading the first one WFClient.dlm.DownloadNext(); } else { } break; case "kissmanga": // MessageBox.Show("Sorry, can't do this yet! ;(\n\n(ignore the download started box)"); // break; // TODO string kName = KissMangaHelper.GetName(url); string kHash = KissMangaHelper.GetHash(url); // Manga km = new Manga(FileHelper.CreateDI(Path.Combine(FileHelper.APP_ROOT.FullName, num)), url); Manga km = new KissManga(FileHelper.CreateDI(Path.Combine(FileHelper.APP_ROOT.FullName, kHash)), url); FrmEdit editor1 = new FrmEdit(km, false); DialogResult result1 = editor1.ShowDialog(); if (result1 == DialogResult.OK) { // cleanup foreach (Chapter ch in km.GetChapters()) { try { string s = ch.GetChapterRoot().ToString(); Directory.Delete(ch.GetChapterRoot().ToString()); } catch (Exception) { } } WFClient.dbm.GetMangaDB().Add(km); String[] dls = km.GetDLChapters(); if (dls == null || dls[0].Equals("-1")) { foreach (Chapter c in km.GetSetPrunedChapters(false)) { WFClient.dlm.AddToQueue(new KissMangaDownload(c)); } } else { // Only download selected chapters foreach (Chapter c in km.GetSetPrunedChapters(false)) { if (dls.Contains(c.GetNum())) { WFClient.dlm.AddToQueue(new KissMangaDownload(c)); } } } // Start downloading the first one WFClient.dlm.DownloadNext(); } else { } break; case "nhentai": num = url.Split('/')[4]; name = gfxBrowser.DocumentTitle.Substring(0, gfxBrowser.DocumentTitle.IndexOf("nhentai:") - 3); JObject hJson = new JObject( new JProperty("hentai", new JObject( new JProperty("title", name), new JProperty("num", num), new JProperty("url", url)))); DirectoryInfo hDir = FileHelper.CreateDI(Path.Combine(FileHelper.APP_ROOT.FullName, "h" + num)); Hentai h = new Nhentai(hDir, hJson.ToString()); FrmEdit edit = new FrmEdit(h, false); DialogResult rezult = edit.ShowDialog(); if (rezult == DialogResult.OK) { WFClient.dbm.GetMangaDB().Add(h); Chapter ch = h.GetChapters()[0]; WFClient.dlm.AddToQueue(new NhentaiDownload(ch)); // Start downloading the first one WFClient.dlm.DownloadNext(); } break; } MessageBox.Show("Download started! You may close the browser at any time, but please keep MikuReader open until the download has completed."); }