コード例 #1
0
 private IAsyncOperation <LoadItemsResult <Gallery> > loadCore(bool reIn)
 {
     return(AsyncInfo.Run(async token =>
     {
         var doc = await Client.Current.HttpClient.GetDocumentAsync(DomainProvider.Eh.RootUri);
         var pp = doc.GetElementbyId("pp");
         if (pp is null) // Disabled popular
         {
             if (reIn)
             {
                 return LoadItemsResult.Empty <Gallery>();
             }
             else
             {
                 await DomainProvider.Eh.Settings.FetchAsync();
                 await DomainProvider.Eh.Settings.SendAsync();
                 return await loadCore(true);
             }
         }
         var nodes = (from div in pp.Elements("div")
                      where div.HasClass("id1")
                      select div).ToList();
         var ginfo = nodes.Select(n =>
         {
             var link = n.Descendants("a").First().GetAttribute("href", default(Uri));
             return GalleryInfo.Parse(link);
         }).ToList();
         var galleries = await Gallery.FetchGalleriesAsync(ginfo);
         for (var i = 0; i < ginfo.Count; i++)
         {
             handleAdditionalInfo(nodes[i], galleries[i]);
         }
         return LoadItemsResult.Create(0, galleries);
     }));
 }
コード例 #2
0
        internal void Analyze(HtmlDocument doc)
        {
            var gdd        = doc.GetElementbyId("gdd");
            var parentNode = gdd.FirstChild.ChildNodes[1].Descendants("a").FirstOrDefault();

            if (parentNode != null)
            {
                ParentInfo = GalleryInfo.Parse(parentNode.GetAttribute("href", default(Uri)));
            }

            var descendantsNode = doc.GetElementbyId("gnd");

            if (descendantsNode != null)
            {
                var count       = descendantsNode.ChildNodes.Count / 3;
                var descendants = new RevisionInfo[count];
                for (var i = 0; i < descendants.Length; i++)
                {
                    var aNode    = descendantsNode.ChildNodes[i * 3 + 1];
                    var textNode = descendantsNode.ChildNodes[i * 3 + 2];
                    var link     = aNode.GetAttribute("href", default(Uri));
                    var dto      = DateTimeOffset.ParseExact(textNode.GetInnerText(), "', added' yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AllowWhiteSpaces);
                    descendants[i] = new RevisionInfo(GalleryInfo.Parse(link), dto);
                }
                DescendantsInfo = descendants;
            }
            else
            {
                DescendantsInfo = Array.Empty <RevisionInfo>();
            }
        }
コード例 #3
0
        internal TaggingRecord(HtmlNode trNode)
        {
            var td = trNode.Elements("td").ToList();

            Tag   = Tag.Parse(td[1].GetInnerText());
            Score = int.Parse(td[2].GetInnerText());
            var uri = td[3].Element("a").GetAttribute("href", default(Uri));

            GalleryInfo = GalleryInfo.Parse(uri);
            Timestamp   = DateTimeOffset.Parse(td[4].GetInnerText(), null, System.Globalization.DateTimeStyles.AssumeUniversal);
        }
コード例 #4
0
        internal TaggingRecord(HtmlNode trNode)
        {
            var td = trNode.Elements("td").ToList();

            Tag   = Tag.Parse(td[0].InnerText.DeEntitize());
            Score = int.Parse(td[1].InnerText.DeEntitize());
            var uri = new Uri(td[2].Element("a").GetAttributeValue("href", "").DeEntitize());

            GalleryInfo = GalleryInfo.Parse(uri);
            Timestamp   = DateTimeOffset.Parse(td[3].InnerText.DeEntitize(), null, System.Globalization.DateTimeStyles.AssumeUniversal);
            UsageCount  = long.Parse(td[4].InnerText.DeEntitize());
            IsBlocked   = td[5].InnerText.DeEntitize() == "B";
            IsSlaved    = td[6].InnerText.DeEntitize() == "S";
        }
コード例 #5
0
        internal RevisionCollection(Gallery owner, HtmlDocument doc)
        {
            this.Owner = owner;
            var gdd        = doc.GetElementbyId("gdd");
            var parentNode = gdd.FirstChild.ChildNodes[1].Descendants("a").FirstOrDefault();

            if (parentNode != null)
            {
                this.ParentInfo = GalleryInfo.Parse(new Uri(parentNode.GetAttributeValue("href", "").DeEntitize()));
            }
            var descendantsNode = doc.GetElementbyId("gnd");

            if (descendantsNode != null)
            {
                var count       = descendantsNode.ChildNodes.Count / 3;
                var descendants = new(DateTimeOffset UpdatedTime, GalleryInfo Gallery)[count];
コード例 #6
0
 protected override IAsyncOperation <IEnumerable <Gallery> > LoadMoreItemsImplementAsync(int count)
 {
     return(AsyncInfo.Run <IEnumerable <Gallery> >(async token =>
     {
         var doc = await Client.Current.HttpClient.GetDocumentAsync(UriProvider.Eh.RootUri);
         var pp = doc.GetElementbyId("pp");
         var nodes = (from div in pp.Elements("div")
                      where div.GetAttributeValue("class", "") == "id1"
                      select div).ToList();
         var ginfo = nodes.Select(n =>
         {
             var link = n.Descendants("a").First().GetAttributeValue("href", "").DeEntitize();
             return GalleryInfo.Parse(new Uri(link));
         }).ToList();
         var galleries = await Gallery.FetchGalleriesAsync(ginfo);
         for (var i = 0; i < ginfo.Count; i++)
         {
             handleAdditionalInfo(nodes[i], galleries[i]);
         }
         return galleries;
     }));
 }
コード例 #7
0
        protected override IAsyncOperation <LoadItemsResult <Gallery> > LoadItemsAsync(int count)
        {
            var page = Count / 50;

            return(AsyncInfo.Run(async token =>
            {
                var uri = new Uri($"https://e-hentai.org/toplist.php?tl={(int)Toplist}&p={page}");
                var doctask = Client.Current.HttpClient.GetDocumentAsync(uri);
                token.Register(doctask.Cancel);
                var doc = await doctask;
                token.ThrowIfCancellationRequested();
                var records = doc.DocumentNode.SelectNodes("//table[@class='itg']/tr[position()>1]/td[5]/div/div[3]/a/@href").ToList();
                var gr = new List <GalleryInfo>(records.Count);
                foreach (var item in records)
                {
                    var guri = item.GetAttribute("href", DomainProvider.Eh.RootUri, null);
                    gr.Add(GalleryInfo.Parse(guri));
                }
                var galleries = await Gallery.FetchGalleriesAsync(gr);
                return LoadItemsResult.Create(page * 50, galleries);
            }));
        }