Exemplo n.º 1
0
        private void ProcessDoujin(NijieImage image, HtmlDocument doc)
        {
            image.IsDoujin = true;

            // member id
            var memberDivs = doc.DocumentNode.SelectNodes("//div[@id='dojin_left']//p[@class='text']//a");
            foreach (var item in memberDivs)
            {
                var href = item.Attributes["href"].Value;
                if (href.Contains("/members.php?id="))
                {
                    var split = href.Split('=');
                    image.Member = new NijieMember(Int32.Parse(split[1]), MemberMode.Doujin);
                    break;
                }
            }

            // parse doujin title
            var doujinTitleDiv = doc.DocumentNode.SelectSingleNode("//div[@id='dojin_header']//h2[@class='title']");
            image.Title = doujinTitleDiv.InnerText;

            // parse description
            var doujinDescription = doc.DocumentNode.SelectSingleNode("//p[@itemprop='description']");
            image.Description = doujinTitleDiv.InnerText;

            // created date
            var doujinCreated = doc.DocumentNode.SelectSingleNode("//div[@id='dojin_left']//span");
            image.WorkDate = DateTime.ParseExact(doujinCreated.InnerText, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);

            // main image
            var mainImage = doc.DocumentNode.SelectSingleNode("//div[@id='dojin_left']//p[@class='image']/a/img");
            image.MediumImageUrl = mainImage.Attributes["src"].Value;

            var bigImage = doc.DocumentNode.SelectSingleNode("//div[@id='dojin_left']//p[@class='image']/a");
            image.BigImageUrl = bigImage.Attributes["href"].Value;

            // tags
            var tags = doc.DocumentNode.SelectNodes("//ul[@id='tag']//span[@class='tag_name']/a");
            if (tags != null)
            {
                image.Tags = new List<NijieTag>();
                foreach (var item in tags)
                {
                    if (!String.IsNullOrWhiteSpace(item.InnerText))
                        image.Tags.Add(new NijieTag() { Name = item.InnerText });
                }
            }

            // pages
            image.IsManga = true;
            image.ImageUrls = new List<string>();
            image.MangaPages = new List<NijieMangaInfo>();
            int p = 1;
            image.ImageUrls.Add(image.BigImageUrl);
            var page = new NijieMangaInfo();
            page.Image = image;
            page.ImageId = image.ImageId;
            page.Page = p++;
            page.ImageUrl = image.BigImageUrl;
            image.MangaPages.Add(page);

            var subImages = doc.DocumentNode.SelectNodes("//div[@id='gallery_new']//ul[@id='thumbnail']//a");
            if (subImages != null && subImages.Count > 0)
            {
                foreach (var item in subImages)
                {
                    image.ImageUrls.Add(item.Attributes["href"].Value);

                    page = new NijieMangaInfo();
                    page.Image = image;
                    page.ImageId = image.ImageId;
                    page.Page = p++;
                    page.ImageUrl = item.Attributes["href"].Value;
                    image.MangaPages.Add(page);
                }
            }
        }
Exemplo n.º 2
0
        private void ParseImageLinks(NijieImage image, HtmlDocument doc)
        {
            var mediumImageLink = doc.DocumentNode.SelectSingleNode("//div[@id='gallery_open']//img[@class='mozamoza ngtag']");
            if (mediumImageLink != null)
                image.MediumImageUrl = mediumImageLink.Attributes["src"].Value;

            var bigImageLinks = doc.DocumentNode.SelectNodes("//div[@id='gallery_open']//a");
            if (bigImageLinks != null)
            {
                image.BigImageUrl = bigImageLinks[0].Attributes["href"].Value;
                if (bigImageLinks.Count > 1)
                {
                    image.IsManga = true;
                    image.ImageUrls = new List<string>();
                    image.MangaPages = new List<NijieMangaInfo>();
                    int p = 1;
                    foreach (var bigImage in bigImageLinks)
                    {
                        image.ImageUrls.Add(bigImage.Attributes["href"].Value);

                        var page = new NijieMangaInfo();
                        page.Image = image;
                        page.ImageId = image.ImageId;
                        page.Page = p++;
                        page.ImageUrl = bigImage.Attributes["href"].Value;
                        image.MangaPages.Add(page);
                    }
                }
                else
                {
                    image.IsManga = false;
                }
            }

            // check if image urls is using popups
            if (image.BigImageUrl.Contains("view_popup.php"))
            {
                image = ParseImagePopups(image);
            }
        }