Esempio n. 1
0
 private static WorkChapter AdaptChapter(HtmlNode node)
 {
     var preface     = node.QuerySelector("div#workskin div.preface");
     var chapter     = node.QuerySelector("div#workskin div.chapter");
     var details     = node.QuerySelector("div.wrapper dl.work");
     var words       = details.QuerySelector("dd.stats dl.stats dd.words");
     var kudos       = details.QuerySelector("dd.stats dl.stats dd.kudos");
     var comments    = details.QuerySelector("dd.stats dl.stats dd.comments");
     var workChapter = new WorkChapter
     {
         ChapterTitle   = chapter.QuerySelector("div.chapter h3.title a")?.InnerText,
         ChapterSummary = Sanitizer.TextSanitizer(preface.QuerySelector("div.summary blockquote p")?.InnerText),
         ChapterNotes   = Sanitizer.TextSanitizer(chapter.QuerySelector("div.chapter div.notes p")?.InnerText),
         WorkDetails    = new WorkIndexing
         {
             Author = preface.QuerySelector("h3.heading a").InnerText,
             Title  = Sanitizer.TextSanitizer(preface.QuerySelector("h2.title").InnerText),
             WorkId = int.Parse(Sanitizer.ChapterToIdSanitizer(chapter
                                                               .QuerySelector("div.chapter h3.title a")
                                                               .Attributes["href"].Value)),
             Fandom = Sanitizer.ListToListSanitizer(details
                                                    .QuerySelectorAll("dd.fandom ul.commas li").Select(el => el.QuerySelector("a").InnerText)
                                                    .ToList()),
             Relationships = Sanitizer.ListToListSanitizer(details
                                                           .QuerySelectorAll("dd.relationship ul.commas li").Select(el => el.QuerySelector("a").InnerText)
                                                           .ToList()),
             Characters = Sanitizer.ListToListSanitizer(details
                                                        .QuerySelectorAll("dd.character ul.commas li")
                                                        .Select(el => el.QuerySelector("a").InnerText).ToList()),
             Category = Sanitizer.ListToListSanitizer(details.QuerySelectorAll("dd.category ul.commas li")
                                                      .Select(el => el.QuerySelector("a").InnerText).ToList()),
             Tags = Sanitizer.ListToListSanitizer(details
                                                  .QuerySelectorAll("dd.tags ul.commas li")
                                                  .Select(el => el.QuerySelector("a").InnerText).ToList()),
             Language = Sanitizer.LineSpaceSanitizer(details.QuerySelector("dd.language").InnerText),
             Words    = int.Parse(words is null ? "0" : Sanitizer.NumberSanitizer(words.InnerText)),
             Comments = int.Parse(comments is null ? "0" : Sanitizer.NumberSanitizer(comments.InnerText)),
             Kudos    = int.Parse(kudos is null ? "0" : Sanitizer.NumberSanitizer(kudos.InnerText))
         },