Example #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);
        }
Example #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);
        }
Example #3
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");
            }
        }