private void BtnAdd_Clicked(object sender, EventArgs e) { string url = txtUrl.Text; string name = string.Empty; string num = string.Empty; if (url == "" || url == null) { PopUp("Error", "Please enter a URL"); return; } if (url.StartsWith("https://mangadex.org/title/")) { // TODO: Name name = url.Split('/')[5]; num = url.Split('/')[4]; url = "https://mangadex.org/api/manga/" + num; Manga m = new Manga(FileHelper.CreateDI(Path.Combine(FileHelper.APP_ROOT.FullName, num)), url); MClient.dbm.GetMangaDB().Add(m); foreach (Chapter c in m.GetChapters()) { MClient.dlm.AddToQueue(new MangaDexDownload(c)); } // Start downloading the first one MClient.dlm.DownloadNext(); } else if (url.StartsWith("https://nhentai.net/g/")) { num = url.Split('/')[4]; name = txtName.Text != "" ? txtName.Text : "Hentai " + new Random().Next(); 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 Hentai(hDir, hJson.ToString()); MClient.dbm.GetMangaDB().Add(h); Chapter ch = h.GetChapters()[0]; MClient.dlm.AddToQueue(new NhentaiDownload(ch)); // Start downloading the first one MClient.dlm.DownloadNext(); } else { PopUp("Error", "Invalid URL!"); return; } PopUp("Info", "Download started!\nPlease do not close MikuReader until the download is complete."); }
private void temp() { var url = "https://mangadex.org/api/manga/" + "32043"; Manga m = new Manga(FileHelper.CreateDI(Path.Combine(FileHelper.APP_ROOT.FullName, "32043")), url); MClient.dbm.GetMangaDB().Add(m); foreach (Chapter c in m.GetChapters()) { MClient.dlm.AddToQueue(new MangaDexDownload(c)); } MClient.dlm.DownloadNext(); RepopulateItems(); }
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 = "https://mangadex.org/api/manga/" + num; Manga m = new Manga(FileHelper.CreateDI(Path.Combine(FileHelper.APP_ROOT.FullName, num)), url); WFClient.dbm.GetMangaDB().Add(m); foreach (Chapter c in m.GetChapters()) { WFClient.dlm.AddToQueue(new MangaDexDownload(c)); } // Start downloading the first one WFClient.dlm.DownloadNext(); 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 Hentai(hDir, hJson.ToString()); 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."); }