private void Folder_Hiyobi_Search_Click(object sender, RoutedEventArgs e) { MainWindow.MainPanel.Children.Clear(); MainWindow.label.Visibility = Visibility.Visible; MainWindow.label.FontSize = 100; InternetP parser = new InternetP(); parser.keyword = h.name.Replace("|", "|").Split(' ').ToList(); parser.index = 1; parser.HiyobiSearch(data => new InternetP(data: data).ParseJObject(async jobject => { MainWindow.label.Content = 0 + "/" + jobject["list"].ToList().Count; foreach (JToken tk in jobject["list"]) { MainWindow.label.Content = jobject["list"].ToList().IndexOf(tk) + "/" + jobject["list"].ToList().Count; parser = new InternetP(); parser.url = $"https://cdn.hiyobi.me/data/json/{tk["id"]}_list.json"; JArray imgs = await parser.TryLoadJArray(); if (imgs == null) { continue; } Hitomi h = new Hitomi { id = tk["id"].ToString(), name = tk["title"].ToString(), dir = $"https://hiyobi.me/reader/{tk["id"]}", page = imgs.Count, thumbpath = $"https://cdn.hiyobi.me/tn/{tk["id"]}.jpg", thumb = await ImageProcessor.LoadWebImageAsync($"https://cdn.hiyobi.me/tn/{tk["id"]}.jpg"), type = Hitomi.Type.Hiyobi }; Int64 size = 0; h.files = imgs.ToList().Select(x => $"https://cdn.hiyobi.me/data/{tk["id"]}/{x["name"]}").ToArray(); h.FolderByte = size; h.SizePerPage = size / imgs.Count; foreach (JToken tags in tk["tags"]) { Tag tag = new Tag(); if (tags["value"].ToString().Contains(":")) { tag.types = (Tag.Types)Enum.Parse(typeof(Tag.Types), tags["value"].ToString().Split(':')[0]); tag.name = tags["display"].ToString(); } else { tag.types = Structs.Tag.Types.tag; tag.name = tags["display"].ToString(); } h.tags.Add(tag); } MainWindow.MainPanel.Children.Add(new HitomiPanel(h, MainWindow)); Console.WriteLine($"Completed: https://cdn.hiyobi.me/tn/{tk["id"]}.jpg"); } MainWindow.label.Visibility = Visibility.Hidden; })); }
public async Task <Hitomi> Parser() { InternetP parser; parser = new InternetP(url: $"https://api.hiyobi.me/gallery/{text}"); JObject obj = await parser.LoadJObject(); parser = new InternetP(url: $"https://cdn.hiyobi.me/data/json/{text}_list.json"); JArray imgs = await parser.TryLoadJArray(); if (imgs == null) { return(null); } Hitomi h = new Hitomi { id = obj.StringValue("id"), name = obj.StringValue("title"), type = type, page = imgs.Count, dir = $"https://hiyobi.me/reader/{text}", thumb = ImageProcessor.LoadWebImage($"https://cdn.hiyobi.me/tn/{text}.jpg"), thumbpath = $"https://cdn.hiyobi.me/tn/{text}.jpg", files = imgs.ToList().Select(x => $"https://cdn.hiyobi.me/data/{text}/{x["name"]}").ToArray(), author = string.Join(", ", obj["artists"].Select(x => x["display"].ToString())), authors = obj["artists"].Select(x => x["display"].ToString()).ToArray(), Json = obj, designType = new InternetP().DesignTypeFromInt(obj.IntValue("type") ?? 0), language = obj.StringValue("language") }; foreach (JToken tags in obj["tags"]) { Tag tag = new Tag(); if (tags["value"].ToString().Contains(":")) { tag.types = (Tag.Types)Enum.Parse(typeof(Tag.Types), tags["value"].ToString().Split(':')[0]); } else { tag.types = Tag.Types.tag; } tag.name = tags["display"].ToString(); h.tags.Add(tag); } return(h); }
public async void Parser(JObject jobject) { start(jobject["list"].Count()); foreach (JToken tk in jobject["list"]) { InternetP parser = new InternetP(url: $"https://cdn.hiyobi.me/data/json/{tk["id"]}_list.json"); JArray imgs = await parser.TryLoadJArray(); if (imgs == null) { continue; } Hitomi h = new Hitomi { id = tk["id"].ToString(), name = tk["title"].ToString(), type = type, page = imgs.Count, dir = $"https://hiyobi.me/reader/{tk["id"]}", thumb = ImageProcessor.LoadWebImage($"https://cdn.hiyobi.me/tn/{tk["id"]}.jpg"), thumbpath = $"https://cdn.hiyobi.me/tn/{tk["id"]}.jpg", files = imgs.ToList().Select(x => $"https://cdn.hiyobi.me/data/{tk["id"]}/{x["name"]}").ToArray(), author = string.Join(", ", tk["artists"].Select(x => x["display"].ToString())), authors = tk["artists"].Select(x => x["display"].ToString()).ToArray(), Json = tk//tk.ToString() }; foreach (JToken tags in tk["tags"]) { Tag tag = new Tag(); if (tags["value"].ToString().Contains(":")) { tag.types = (Tag.Types)Enum.Parse(typeof(Tag.Types), tags["value"].ToString().Split(':')[0]); } else { tag.types = Tag.Types.tag; } tag.name = tags["display"].ToString(); h.tags.Add(tag); } update(h, jobject["list"].ToList().IndexOf(tk), jobject["list"].Count()); } end(); }