Ejemplo n.º 1
0
        private static ExFavoriteList FromHtml(string htmlSource, ExFavoriteSortingMode sortingMode)
        {
            if (htmlSource == null)
            {
                return(null);
            }

            var          l            = new ExFavoriteList();
            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.OptionFixNestedTags = true;
            htmlDocument.LoadHtml(htmlSource);


            HtmlNodeCollection galleryNodes;

            try
            {
                var tableNode = htmlDocument.DocumentNode.SelectSingleNode("//*[@class='itg glt']");
                galleryNodes = tableNode.SelectNodes("//tr[./td/@class='gl1e']");
                foreach (var node in galleryNodes)
                {
                    l.Add(ExGallery.GetGalleryListItemFromNode(node));
                }

                l.PageCount         = ReadPageCount(htmlDocument);
                l.CurrentPageNumber = ReadCurrentPageNumber(htmlDocument);
            }
            catch (Exception ex)
            {
            }

            return(l);
        }
Ejemplo n.º 2
0
        private static ExFavoriteList FromHtml(string htmlSource, ExFavoriteSortingMode sortingMode)
        {
            if (htmlSource == null)
            {
                return(null);
            }

            var          l            = new ExFavoriteList();
            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.OptionFixNestedTags = true;
            htmlDocument.LoadHtml(htmlSource);

            try
            {
                HtmlNodeCollection favoriteItemNodes = htmlDocument.DocumentNode.SelectNodes("//tr[@class]");
                foreach (var node in favoriteItemNodes)
                {
                    l.Add(ExFavorite.FromHtmlNode(node));
                }

                l.PageCount         = ReadPageCount(htmlDocument);
                l.CurrentPageNumber = ReadCurrentPageNumber(htmlDocument);
            }
            catch (Exception ex)
            {
                throw new Exception("Cannot load favorite list html");
            }

            l.SortingMode = sortingMode;
            return(l);
        }
Ejemplo n.º 3
0
        public static async Task <ExFavoriteList> DownloadFavoritesAsync(int pagenumber)
        {
            try
            {
                // Get page html
                if (pagenumber == 1)
                {
                    var htmlStr = await ExClient.GetStringWithExCookie($"http://exhentai.org/favorites.php", "dm_l");

                    return(ExFavoriteList.FromHtml(htmlStr));
                }
                else
                {
                    var htmlStr = await ExClient.GetStringWithExCookie($"http://exhentai.org/favorites.php?page= {pagenumber - 1}");

                    return(ExFavoriteList.FromHtml(htmlStr));
                }


                //return await client.GetStringAsync(uri);
            }
            catch (Exception ex)
            {
                throw new Exception("Cannot download favorite list");
            }
        }
Ejemplo n.º 4
0
        public static async Task <ExFavoriteList> DownloadFavoritesAsync(int pagenumber, ExFavoriteSortingMode sortingMode)
        {
            try
            {
                // Get page html
                if (pagenumber == 1)
                {
                    var htmlStr = await ExClient.GetStringWithExCookie($"https://exhentai.org/favorites.php?inline_set={SORTING_STRING[(int)sortingMode]}-https://exhentai.org/favorites.php?inline_set-dm_e", $"");

                    return(ExFavoriteList.FromHtml(htmlStr, sortingMode));
                }
                else
                {
                    var htmlStr = await ExClient.GetStringWithExCookie($"https://exhentai.org/favorites.php?page={pagenumber - 1}&inline_set={SORTING_STRING[(int)sortingMode]}-dm_e", $"");

                    return(ExFavoriteList.FromHtml(htmlStr, sortingMode));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Cannot download favorite list");
            }
        }