Exemplo n.º 1
0
        void ParseCharacterNode(HtmlNode characterNode, Novel novel)
        {
            if (characterNode.Descendants("td").Count() < 2) return;//border
            Character character = new Character();
            NovelCharacterInfo novelCharacterInfo = new NovelCharacterInfo();
            novelCharacterInfo.Character = character;

            //IMAGE
            var imageNode = characterNode.Descendants("td").First();
            var imageTag = imageNode.Descendants("img").FirstOrDefault();
            if (imageTag != null)
            {
                var image = new NovelImage() { ImageType = NovelImageType.Character, UrlPath = imageTag.GetchuImgValue() };
                novelCharacterInfo.Image = image;
                novel.Images.Add(image);
            }

            //INFO
            var infoNode = imageNode.NextSibling("td");
            ParseCharacterInfo(infoNode, novelCharacterInfo);

            //DETAILED IMAGE
            var detailedImageNode = infoNode.NextSibling("td");
            if (detailedImageNode != null)
            {
                var detailedImageTag = detailedImageNode.Descendants("img").FirstOrDefault();
                if (detailedImageTag != null)
                {
                    var detailedImage = new NovelImage() { ImageType = NovelImageType.DetailedCharacter, UrlPath = detailedImageTag.GetchuImgValue() };
                    novelCharacterInfo.DetailedImage = detailedImage;
                    novel.Images.Add(detailedImage);
                }
            }
            novel.CharacterInfos.Add(novelCharacterInfo);
        }
Exemplo n.º 2
0
        void ParseCharactersContent(HtmlNode node, Novel novel)
        {
            foreach (var characterNode in node.Descendants("div").Where(w => w.HasClass("chardetails")))
            {
                Character character = new Character();
                NovelCharacterInfo novelCharacterInfo = new NovelCharacterInfo();
                novelCharacterInfo.Character = character;
                var imageNode = characterNode.Descendants("img").FirstOrDefault();
                if (imageNode != null)
                {
                    var image = new NovelImage() { ImageType = NovelImageType.Character, UrlPath = imageNode.Attributes["src"].Value };
                    novelCharacterInfo.Image = image;
                    novel.Images.Add(image);
                }

                var detailsTable = characterNode.Descendants("table").FirstOrDefault();

                //Parse Name
                var headerWithName = detailsTable.FirstChild;

                var engNameNode = headerWithName.Descendants("a").FirstOrDefault();
                if (engNameNode != null) character.EngName = engNameNode.InnerText;

                var japNameNode = headerWithName.Descendants("b").FirstOrDefault();
                if (japNameNode != null) character.JapName = japNameNode.InnerText;

                var sexNode = headerWithName.Descendants("acronym").FirstOrDefault();
                if (sexNode != null) character.Sex = GetSex(sexNode.Attributes["title"].Value);

                //Parse Sizes
                var measureRow = detailsTable.Descendants("td").FirstOrDefault(w => w.InnerText == "Measurements");
                if (measureRow != null)
                {
                    var measureNode = measureRow.NextSibling;
                    if (measureNode != null)
                    {
                        var sizes = new Sizes();
                        var measureValue = measureNode.InnerText;
                        var match = Regex.Match(measureValue, MeasurePattern);
                        if (match.Success)
                        {
                            sizes.Bust = match.Groups[1].Value.ToNullableInt();
                            sizes.Waist = match.Groups[2].Value.ToNullableInt();
                            sizes.Hip = match.Groups[3].Value.ToNullableInt();

                        }
                        character.Sizes = sizes;
                    }
                }
                novel.CharacterInfos.Add(novelCharacterInfo);
            }
        }
Exemplo n.º 3
0
        void ParseCharacterInfo(HtmlNode characterNode, NovelCharacterInfo characterInfo)
        {
            var nameNode = characterNode.Descendants("charalist").FirstOrDefault();
            if (nameNode != null)
            {
                characterInfo.Character.JapName = nameNode.InnerText;
            }
            else
            {
                nameNode = characterNode.Descendants("h2").FirstOrDefault(w=>w.HasClass("chara-name"));
                if (nameNode != null)
                {
                    characterInfo.Character.JapName = nameNode.InnerText;
                }

            }

            var descriptionNode = characterNode.Descendants("dd").FirstOrDefault();
            if (descriptionNode != null)
            {
                Sizes sizes = CommonParser.ParseSizesText(characterNode.InnerText);
                if (sizes != null)
                {
                    characterInfo.Character.Sizes = sizes;
                }
                characterInfo.Description = characterNode.InnerText;
            }
        }