private void Mark(bool toggle = true) { if (!IsSavedGallery) { return; } if (toggle) { Seen = !Seen; } else { Seen = true; } if (Seen) { if (!HistoryController.CheckHistory(Link)) { HistoryController.History.Insert(0, new HistoryModel { Date = DateTime.Now, Title = Title, Link = Link, Site = Site }); } } else { HistoryController.History.RemoveAll(h => h.Link == Link); } HistoryController.Save(); }
public FavoritesViewModel() { Instance = this; FavoriteItems = new ReadOnlyObservableCollection <HentaiModel>(Favorites); foreach (var hentaiModel in Favorites) { if (hentaiModel.Site == "ExHentai.org") { var client = new RestClient { UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.70 Safari/537.36", Encoding = Encoding.UTF8, Timeout = 60000, BaseUrl = new Uri(hentaiModel.ThumbnailLink), CookieContainer = ExHentai.GetCookies() }; var imgbytes = client.Execute(new RestRequest()); try { var img = ExHentai.BytesToBitmapImage(imgbytes.RawBytes); hentaiModel.Img = img; } catch { //ignore } } else { hentaiModel.Img = hentaiModel.ThumbnailLink; } hentaiModel.Seen = HistoryController.CheckHistory(hentaiModel.Link); } }
public static async Task <List <HentaiModel> > GetLatestAsync(string url) { var document = await ParseHtmlStringAsync(await GetHtmlStringAsync(url)); var hents = new List <HentaiModel>(); var classes = document.All.Where(c => c.LocalName == "a" && c.ClassList.Contains("cover")); //var a = classes.Where(x => x.OuterHtml == "img"); foreach (var element in classes) { var img = await ParseHtmlStringAsync(element.InnerHtml); var i = img.All.FirstOrDefault( ii => ii.LocalName == "img" && ii.HasAttribute("data-src") && ii.GetAttribute("data-src").StartsWith("https://t.nhentai.net/galleries/")) ?.GetAttribute("data-src") ?? $"https:{img.Images[0].Source.Replace("about:", string.Empty)}"; var title = img.All.FirstOrDefault(t => t.LocalName == "div" && t.ClassList.Contains("caption")) ?.TextContent; try { hents.Add(new HentaiModel { Title = title, Link = $"https://nhentai.net{element.GetAttribute("href").Replace("about:", string.Empty)}", Img = i, ThumbnailLink = i, Site = "nHentai.net", Seen = HistoryController.CheckHistory( $"https://nhentai.net{element.GetAttribute("href").Replace("about:", string.Empty)}") }); } catch (Exception) { // hmm } } return(hents); }
public static async Task <List <HentaiModel> > GetLatestAsync(string url) { var client = new RestClient { UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.70 Safari/537.36", Encoding = Encoding.UTF8, Timeout = 60000, BaseUrl = new Uri(url), CookieContainer = GetCookies() }; var response = await GetHtmlStringAsync(client); var document = await ParseHtmlStringAsync(response); var hents = new List <HentaiModel>(); var classes = document.All.Where(c => c.LocalName == "div" && c.ClassList.Contains("id1")); //var a = classes.Where(x => x.OuterHtml == "img"); foreach (var element in classes) { var id3 = element.Children.First(d => d.LocalName == "div" && d.ClassList.Contains("id3")); var atag = await ParseHtmlStringAsync(id3.InnerHtml); client.BaseUrl = new Uri(atag.Images[0].Source); var imgfromb = await client.ExecuteGetTaskAsync(new RestRequest()); var image = BytesToBitmapImage(imgfromb.RawBytes); hents.Add(new HentaiModel { Title = atag.Images[0].Title, Link = atag.Links[0].GetAttribute("href"), Img = image, ThumbnailLink = atag.Images[0].Source, Site = "ExHentai.org", Seen = HistoryController.CheckHistory(atag.Links[0].GetAttribute("href")) }); //await Task.Delay(50); } return(hents); }
public static async Task <List <HentaiModel> > GetLatestAsync(string url) { var document = await ParseHtmlStringAsync(await GetHtmlStringAsync(url)); var hents = new List <HentaiModel>(); var classes = document.All.Where(c => c.LocalName == "a" && c.ClassList.Contains("thumb-pururin")); //var a = classes.Where(x => x.OuterHtml == "img"); foreach (var element in classes) { var img = element.Children.First(i => i.LocalName == "img").GetAttribute("src"); hents.Add(new HentaiModel { Title = element.TextContent.Trim('\n').Trim(), Link = element.GetAttribute("href"), Img = BytesToBitmapImage(await _httpClient.GetByteArrayAsync(img)), ThumbnailLink = img, Site = "Pururin.us", Seen = HistoryController.CheckHistory(img) }); } return(hents); }
public static async Task <List <HentaiModel> > GetLatestAsync(string url) { var document = await ParseHtmlStringAsync(await GetHtmlStringAsync(url)); var hents = new List <HentaiModel>(); var classes = document.All.Where(c => c.LocalName == "a" && c.ClassList.Contains("entry-thumb")); //var a = classes.Where(x => x.OuterHtml == "img"); foreach (var element in classes) { var img = await ParseHtmlStringAsync(element.InnerHtml); var title = element.GetAttribute("title").Split(new[] { '"' }, StringSplitOptions.RemoveEmptyEntries)[1]; hents.Add(new HentaiModel { Title = title, Link = element.GetAttribute("href"), Img = new Uri(img.Images[0].Source), ThumbnailLink = img.Images[0].Source, Site = "Hentai.cafe", Seen = HistoryController.CheckHistory(element.GetAttribute("href")) }); } return(hents); }