private static Volume ParseBookItemNode(HtmlNode volNode) { var vol = new Volume(); vol.Id = RetriveId(volNode.Descendants("a").First().Attributes["href"].Value); vol.Title = WebUtility.HtmlDecode(volNode.ChildNodes.FindFirst("h3").InnerText); vol.Label = ExtractLabel(vol.Title); vol.Title = RemoveLabel(vol.Title); vol.CoverImageUri = AbsoluteUrl(volNode.Descendants("img").First().Attributes["src"].Value); vol.Chapters = (from chaptersNode in volNode.ChildNodes.First(node => node.HasClass("linovel-chapter-list")).Descendants("a") select new ChapterProperties { Id = RetriveId(chaptersNode.Attributes["href"].Value), Title = RemoveLabel(WebUtility.HtmlDecode(chaptersNode.InnerText)), }).ToList(); return vol; }
static Volume ParseVolumeSection(HtmlNode section) { Volume volume = new Volume(); volume.CoverImageUri = section.FirstChildClass("cover").Element("img").GetAttributeValue("src", string.Empty); volume.Title = WebUtility.HtmlDecode(section.FirstChildClass("info").InnerText); volume.Label = ExtractLabel(volume.Title); volume.Title = RemoveLabel(volume.Title); volume.Chapters = section.Element("ul").Elements("li").Select(li => { var cpt = new ChapterProperties(); var a = li.Element("a"); var pos = ParseIDFromReadLink(a.GetAttributeValue("href", String.Empty)); cpt.Id = pos.ChapterId; cpt.ParentVolumeId = pos.VolumeId; cpt.ParentSeriesId = pos.SeriesId; cpt.Title = a.InnerText; return cpt; }).ToList(); if (volume.Chapters.Count > 0) { volume.Id = volume.Chapters[0].ParentVolumeId; volume.ParentSeriesId = volume.Chapters[0].ParentSeriesId; } for (int chapterIdx = 0; chapterIdx < volume.Chapters.Count; chapterIdx++) { var chapter = volume.Chapters[chapterIdx]; chapter.ChapterNo = chapterIdx; //chapter.ParentVolumeId = vol.Id; chapter.ParentVolumeId = volume.Id; if (chapterIdx > 0) { //chapter.PrevChapter = vol.Chapters[chapterIdx - 1]; chapter.PrevChapterId = volume.Chapters[chapterIdx - 1].Id; } if (chapterIdx < volume.Chapters.Count - 1) { //chapter.NextChapter = vol.Chapters[chapterIdx + 1]; chapter.NextChapterId = volume.Chapters[chapterIdx + 1].Id; } } return volume; }