public static async Task <Series> GetSeriesAsync(string sid) { //http://xs.dmzj.com/2014/index.shtml var uri = new Uri(Domain + sid + "/index.shtml"); HtmlDocument doc = await GetHtmlDocumentAsync(uri); Series ser = new Series(); ser.Provider = "dmzj"; ser.Id = sid; var root = doc.DocumentNode; // .novel_cover var cover = root.Descendants().First(node => node.HasClass("novel_cover")); // .novel_cover_text var info = cover.NextSiblingClass("novel_cover_text"); // .download_rtx var volumns = root.Descendants("div").Where(div => div.HasClass("download_rtx")); cover = cover.Descendants("img").First(); ser.CoverImageUri = cover.GetAttributeValue("src", ""); ser.Id = sid; ser.Title = cover.GetAttributeValue("title", "#"); int vno = 0; ser.Volumes = volumns.Select(vnode => { var vol = new Volume(); vol.CoverImageUri = ser.CoverImageUri; vol.ParentSeriesId = sid; vol.VolumeNo = vno++; var vtitle = vnode.Element("ol").Element("li").LastChild.InnerText; vol.Label = ExtractLabel(vtitle); vol.Title = RemoveLabel(vtitle); vol.Id = vnode.Element("ol").Descendants("a").First().GetAttributeValue("id", ""); int cno = 0; vol.Chapters = vnode.Element("ul").Elements("li").Select( cnode => { var chpt = new ChapterProperties(); cnode = cnode.Element("a"); chpt.Title = cnode.GetAttributeValue("title", "##"); var cid = cnode.GetAttributeValue("href", ""); cid = cid.Substring(cid.LastIndexOf('/') + 1); cid = cid.Substring(0, cid.Length - ".sthml".Length); chpt.Id = cid; chpt.ParentVolumeId = vol.Id; chpt.ParentSeriesId = ser.Id; chpt.ChapterNo = cno++; return(chpt); } ).ToList(); return(vol); }).ToList(); return(ser); }
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; }
public static bool IsIllustrationChapter(ChapterProperties chpt) { return(chpt.Title.Contains("插画") || chpt.Title.Contains("插图")); }