private VisualElement CreateLevelSceneField(ChapterNode chapterNode) { var levelScenes = GameFrameworkSettings.Database.GetGameData <DefaultLevelCategoriesSO>(3).GetSceneNames(chapterNode.LevelScene.levelCategory).ToList(); if (levelScenes.Count == 0) { levelScenes = new List <string>() { "" } } ; PopupField <string> field = new PopupField <string>( "Level Scene", levelScenes, 0) { index = chapterNode.LevelScene.levelScene }; field.RegisterValueChangedCallback((v) => { owner.RegisterCompleteObjectUndo("Updated chapterNode levelScene"); var val = chapterNode.LevelScene; val.levelScene = field.index; chapterNode.LevelScene = val; }); return(field); }
private VisualElement CreateWorldField(ChapterNode chapterNode) { var worldNames = GameFrameworkSettings.Database.GetGameData <DefaultWorldsSO>(2).ArchetypeNames; worldNames = EditorUtilities.GetNoneSelectableFrom(worldNames); PopupField <string> field = new PopupField <string>( "World", worldNames.ToList(), 0) { index = chapterNode.WorldScene.world + 1 }; field.RegisterValueChangedCallback((v) => { owner.RegisterCompleteObjectUndo("Updated chapterNode world"); var val = chapterNode.WorldScene; val.world = field.index - 1; chapterNode.WorldScene = val; var veIdx = controlsContainer.IndexOf(_worldSceneField); controlsContainer.RemoveAt(veIdx); _worldSceneField = CreateWorldSceneField(chapterNode); controlsContainer.Insert(veIdx, _worldSceneField); }); return(field); }
private VisualElement CreateLevelCategoryField(ChapterNode chapterNode) { var levelNames = GameFrameworkSettings.Database.GetGameData <DefaultLevelCategoriesSO>(3).ArchetypeNames; levelNames = EditorUtilities.GetNoneSelectableFrom(levelNames); PopupField <string> field = new PopupField <string>( "Level Category", levelNames.ToList(), 0) { index = chapterNode.LevelScene.levelCategory + 1 }; field.RegisterValueChangedCallback((v) => { owner.RegisterCompleteObjectUndo("Updated chapterNode levelCategory"); var val = chapterNode.LevelScene; val.levelCategory = field.index - 1; chapterNode.LevelScene = val; var veIdx = controlsContainer.IndexOf(_levelSceneField); controlsContainer.RemoveAt(veIdx); _levelSceneField = CreateLevelSceneField(chapterNode); controlsContainer.Insert(veIdx, _levelSceneField); }); return(field); }
void Page2_www_ldks_cc(ref ChapterNode _node, int _index) { string _link = string.Format("https://www.ldks.cc{0}", PageLinkList[_index]); _link = _link.Replace(".html", "_2.html"); WebClient MyWebClient = new WebClient(); MyWebClient.Credentials = CredentialCache.DefaultCredentials; //获取或设置用于向Internet资源的请求进行身份验证的网络凭据 Byte[] pageData = MyWebClient.DownloadData(_link); //从指定网站下载数据 string pageHtml = Encoding.UTF8.GetString(pageData); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(pageHtml); HtmlAgilityPack.HtmlNode _n1 = doc.DocumentNode.SelectSingleNode("//div[@class='content']//h1"); _node._name2 = _n1.InnerText; HtmlAgilityPack.HtmlNode _n2 = doc.DocumentNode.SelectSingleNode("//div[@class='content']//div[@class='showtxt']"); _node._page2 = _n2.InnerText; _node.Repair(); ChapterList.Add(_node); ShowChapter_www_ldks_cc(ChapterList.Count - 1); }
public void LoadChapter(UserChapter userChapter) { //加载标题 ChapterNode cn = GameObject.Find("Bg").GetComponent <ChapterNode>(); ConfigManager cm = ConfigManager.GetInstance(); _chapter = cm.GetChapter(userChapter.ChapterId); cn.LoadData(_chapter, userChapter); Chapter chapter = ConfigManager.GetInstance().GetChapter(userChapter.ChapterId); //加载关卡按钮 for (int i = 0; i < _stageNodes.Length; i++) { if (i >= chapter.Stages.Count) { _stageNodes[i].LoadData(null, null); } else if (i >= userChapter.Stages.Count) { _stageNodes[i].LoadData(ConfigManager.GetInstance().GetStage(chapter.Stages[i].StageId), null); } else { Debug.Log("chapter.Stages[i].StageId=" + chapter.Stages[i].StageId); Debug.Log("userChapter.Stages[i]=" + userChapter.Stages[i]); _stageNodes[i].LoadData(ConfigManager.GetInstance().GetStage(chapter.Stages[i].StageId), userChapter.Stages[i]); } } }
private void CreateChapterTypeField(ChapterNode chapterNode) { EnumField field = new EnumField("Chapter Type", ChapterType.Play) { value = chapterNode.ChapterType }; field.RegisterValueChangedCallback((v) => { owner.RegisterCompleteObjectUndo("Updated chapterNode type"); chapterNode.ChapterType = (ChapterType)v.newValue; }); controlsContainer.Add(field); }
private void CreateTutorialActivednField(ChapterNode chapterNode) { Toggle field = new Toggle("Tutorial Actived?") { value = chapterNode.TutorialActived, }; field.RegisterValueChangedCallback((v) => { owner.RegisterCompleteObjectUndo("Updated chapterNode tutorialActived"); chapterNode.TutorialActived = v.newValue; }); controlsContainer.Add(field); }
private void CreateDescriptionField(ChapterNode chapterNode) { TextField field = new TextField("Description") { multiline = true, value = chapterNode.Description, }; field.RegisterValueChangedCallback((v) => { owner.RegisterCompleteObjectUndo("Updated chapterNode description"); chapterNode.Description = v.newValue; }); controlsContainer.Add(field); }
private void CreateTitleField(ChapterNode chapterNode) { TextField field = new TextField("Title") { multiline = false, value = chapterNode.Title, }; field.RegisterValueChangedCallback((v) => { owner.RegisterCompleteObjectUndo("Updated chapterNode title"); chapterNode.Title = v.newValue; }); controlsContainer.Add(field); }
public void setChapterNode(ChapterNode chapterNode) { this.id = chapterNode.id; this.courseID = chapterNode.courseID; this.contentName = chapterNode.contentName; this.parentID = chapterNode.parentID; this.siblingID = chapterNode.siblingID; this.content = chapterNode.content; this.exerciseTitle = chapterNode.exerciseTitle; this.exerciseVisible_1 = chapterNode.exerciseVisible_1; this.exerciseVisible_2 = chapterNode.exerciseVisible_2; this.exerciseDeadline_1 = chapterNode.exerciseDeadline_1; this.exerciseDeadline_2 = chapterNode.exerciseDeadline_2; this.exerciseTotal_1 = chapterNode.exerciseTotal_1; this.exerciseTotal_2 = chapterNode.exerciseTotal_2; }
public ResultEntity addChapter(ChapterNode chapterNode) { ResultEntity resultEntity = new ResultEntity(); if (courseService.getCourseInfoByID(chapterNode.courseID) == null) { resultEntity.setState(0); resultEntity.setMessage("不存在该课程!"); } else { resultEntity.setData(courseService.addChapter(chapterNode)); resultEntity.setState(resultEntity.getData() != null ? 1 : 0); } return(resultEntity); }
public void setTotalScore(int?chapterId, String type) { int type1 = 0; int type2 = 0; int type3 = 0; if (type.Equals("preview")) { type1 = 1; type3 = 2; type2 = 3; } else { type1 = 4; type3 = 5; type2 = 6; } //fragile List <Exercise> exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type1); List <Exercise> temp = new List <Exercise>(); temp.AddRange(exercises); exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type3); temp.AddRange(exercises); exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type2); temp.AddRange(exercises); int?total = 0; foreach (Exercise exercise in temp) { total += exercise.exercisePoint; } if (type.Equals("preview")) { //fragile ChapterNode chapterNode = ChapterContentApi.getByID(chapterId); chapterNode.exerciseTotal_1 = total; ChapterContentApi.insert(chapterNode); } else { ChapterNode chapterNode = ChapterContentApi.getByID(chapterId); chapterNode.exerciseTotal_2 = total; ChapterContentApi.insert(chapterNode); } }
public ResultEntity alertChapter(ChapterNode chapterNode) { ResultEntity resultEntity = new ResultEntity(); ChapterNode temp = courseService.getChapterByID(chapterNode.id); if (temp != null)//如果有该章节 { resultEntity.setData(courseService.addChapter(chapterNode)); resultEntity.setState(1); resultEntity.setMessage("修改成功!"); } else { resultEntity.setState(0); resultEntity.setMessage("该章节不存在!"); } return(resultEntity); }
public ResultEntity deleteChapter(int?chapterID) { ResultEntity resultEntity = new ResultEntity(); ChapterNode temp = courseService.getChapterByID(chapterID); if (temp != null) { CourseCatalog courseCatalog = new CourseCatalog(); courseCatalog.setChapterNode(temp); courseService.deleteChapter(courseCatalog); resultEntity.setState(courseService.getChapterByID(chapterID) == null ? 1 : 0); } else { resultEntity.setState(0); } resultEntity.setMessage(resultEntity.getState() == 1 ? "删除成功!" : "删除失败,该章节不存在!"); return(resultEntity); }
public ResultEntity alertChapterExerciseTitle(int?chapterID, String title) { ResultEntity resultEntity = new ResultEntity(); ChapterNode temp = courseService.getChapterByID(chapterID); if (temp != null)//如果有该章节 { temp.exerciseTitle = (title); resultEntity.setData(courseService.addChapter(temp)); resultEntity.setState(1); resultEntity.setMessage("修改成功!"); } else { resultEntity.setState(0); resultEntity.setMessage("该章节不存在!"); } return(resultEntity); }
public UnratedChapter(ChapterNode chapterNode, int?studentId) { this.chapterNode = chapterNode; this.studentId = studentId; }
public MangaObject ParseMangaObject(string Content) { HtmlDocument MangaObjectDocument = new HtmlDocument(); MangaObjectDocument.LoadHtml(Content); HtmlNode MangaNode = MangaObjectDocument.DocumentNode.SelectSingleNode(".//section[contains(@class, 'manga')]"); String Name = HtmlEntity.DeEntitize(MangaNode.SelectSingleNode(".//div/div[1]/h1/a").InnerText); Name = Name.Substring(0, Name.LastIndexOf(' ')); HtmlNode AlternateNamesNode = MangaNode.SelectSingleNode(".//div/table/tr/td[2]/table/tr[4]/td"); List <String> AlternateNames = (from AltName in HtmlEntity.DeEntitize(AlternateNamesNode.InnerText).Split(';') select AltName.Trim()).ToList(); List <String> Authors = (from Node in MangaNode.SelectNodes(".//div/table/tr/td[2]/table/tr[5]/td/a") select HtmlEntity.DeEntitize(Node.InnerText)).ToList(); List <String> Artists = (from Node in MangaNode.SelectNodes(".//div/table/tr/td[2]/table/tr[6]/td/a") select HtmlEntity.DeEntitize(Node.InnerText)).ToList(); List <String> Genres = (from Node in MangaNode.SelectNodes(".//div/table/tr/td[2]/table/tr[7]/td/a") select HtmlEntity.DeEntitize(Node.InnerText)).ToList(); // Detect type MangaObjectType MangaType = MangaObjectType.Unknown; String mType = MangaNode.SelectSingleNode(".//div/table/tr/td[2]/table/tr[8]/td").InnerText.ToLower(); if (mType.Contains("japanese manga")) { MangaType = MangaObjectType.Manga; } else if (mType.Contains("korean manhwa")) { MangaType = MangaObjectType.Manhwa; } // Get description String Description = HtmlEntity.DeEntitize(MangaNode.SelectSingleNode(".//div/p").InnerText); // Chapters List <ChapterObject> Chapters = new List <ChapterObject>(); foreach (HtmlNode ChapterVersionNode in MangaNode.SelectNodes(".//*[@id='list']/div[starts-with(@id, 'stream_')]")) { foreach (HtmlNode VolumeNode in ChapterVersionNode.SelectNodes(".//div[contains(@class, 'volume')]")) { UInt32 Volume = 0; HtmlNode VolumeNameNode = VolumeNode.SelectSingleNode(".//h4"); if (!Equals(VolumeNameNode, null)) { String[] idParts = VolumeNameNode.GetAttributeValue("id", "v-1-").Split('-'); UInt32.TryParse(idParts[2], out Volume); } foreach (HtmlNode ChapterNode in ChapterVersionNode.SelectNodes(".//div/ul/li")) { HtmlNode InfoNode = ChapterNode.SelectSingleNode(".//a"); String ChapterName = HtmlEntity.DeEntitize(InfoNode.InnerText), Url = InfoNode.GetAttributeValue("href", null); UInt32 Chapter = 0, SubChapter = 0; Match match = Regex.Match(ChapterName, @"(vol\.(?<Volume>\d+)\s)?ch\.(?<Chapter>\d+)(\.(?<SubChapter>\d+))?"); if (match.Success) { if (match.Groups["Volume"].Success) { UInt32.TryParse(match.Groups["Volume"].Value, out Volume); } if (match.Groups["Chapter"].Success) { UInt32.TryParse(match.Groups["Chapter"].Value, out Chapter); } if (match.Groups["SubChapter"].Success) { UInt32.TryParse(match.Groups["SubChapter"].Value, out SubChapter); } } if (Equals(Url, null)) { continue; } Url = String.Format("{0}{1}", ExtensionDescriptionAttribute.RootUrl, Url); ChapterObject NewChapterObject = new ChapterObject() { Name = ChapterName, Volume = Volume, Chapter = Chapter, SubChapter = SubChapter, Locations = { new LocationObject() { Enabled = true, ExtensionName = ExtensionDescriptionAttribute.Name, ExtensionLanguage = ExtensionDescriptionAttribute.Language, Url = Url } } }; ChapterObject ExistingChapterObject = Chapters.FirstOrDefault(o => { if (!Int32.Equals(o.Chapter, NewChapterObject.Chapter)) { return(false); } if (!Int32.Equals(o.SubChapter, NewChapterObject.SubChapter)) { return(false); } return(true); }); if (Equals(ExistingChapterObject, null)) { Chapters.Add(NewChapterObject); } else { ExistingChapterObject.Merge(NewChapterObject); } } } } Chapters = Chapters.OrderBy(c => c.Chapter).ThenBy(c => c.SubChapter).ThenBy(c => c.Volume).ToList(); return(new MangaObject() { Name = Name, AlternateNames = AlternateNames, Description = Description, Authors = Authors, Artists = Artists, Genres = Genres, MangaType = MangaType, Chapters = Chapters }); }
public MangaObject ParseMangaObject(string content) { if (content.ToLower().Contains("has been licensed, it is not available in MangaHere.".ToLower())) { return(null); } HtmlDocument MangaObjectDocument = new HtmlDocument(); MangaObjectDocument.LoadHtml(content); HtmlNode TitleNode = MangaObjectDocument.DocumentNode.SelectSingleNode("//h1[contains(@class,'title')]"), MangaDetailsNode = MangaObjectDocument.DocumentNode.SelectSingleNode("//div[contains(@class,'manga_detail')]"), MangaPropertiesNode = MangaDetailsNode.SelectSingleNode(".//div[1]"), MangaDesciptionNode = MangaObjectDocument.GetElementbyId("show"), AuthorsNode = MangaPropertiesNode.SelectSingleNode(".//ul/li[5]"), ArtistsNode = MangaPropertiesNode.SelectSingleNode(".//ul/li[6]"), GenresNode = MangaPropertiesNode.SelectSingleNode(".//ul/li[4]"); HtmlNodeCollection AuthorsNodeCollection = AuthorsNode.SelectNodes(".//a"), ArtistsNodeCollection = ArtistsNode.SelectNodes(".//a"); String Desciption = MangaDesciptionNode != null ? MangaDesciptionNode.FirstChild.InnerText : String.Empty, MangaName = HtmlEntity.DeEntitize(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(TitleNode.LastChild.InnerText.ToLower())); String[] AlternateNames = MangaPropertiesNode.SelectSingleNode(".//ul/li[3]").LastChild.InnerText.Split(new String[] { "; " }, StringSplitOptions.RemoveEmptyEntries), Authors = { }, Artists = { }, Genres = MangaPropertiesNode.SelectSingleNode(".//ul/li[4]").LastChild.InnerText.Split(new String[] { ", " }, StringSplitOptions.RemoveEmptyEntries); if (AuthorsNodeCollection != null) { Authors = (from HtmlNode AuthorNode in AuthorsNodeCollection select HtmlEntity.DeEntitize(AuthorNode.InnerText)).ToArray(); } if (ArtistsNodeCollection != null) { Artists = (from HtmlNode ArtistNode in ArtistsNodeCollection select HtmlEntity.DeEntitize(ArtistNode.InnerText)).ToArray(); } List <ChapterObject> Chapters = new List <ChapterObject>(); HtmlNodeCollection RawChapterList = MangaDetailsNode.SelectNodes(".//div[contains(@class,'detail_list')]/ul[1]/li"); foreach (HtmlNode ChapterNode in RawChapterList) { String volNode = ChapterNode.SelectSingleNode(".//span[1]/span").InnerText; String[] volChapSub = { (volNode != null && volNode.Length > 0) ? volNode.Substring(4).Trim() : "0" }; String ChapterTitle = ChapterNode.SelectSingleNode(".//span[1]/a").InnerText.Trim(); String ChapterNumber = ChapterTitle.Substring(ChapterTitle.LastIndexOf(' ') + 1).Trim(); volChapSub = volChapSub.Concat(ChapterNumber.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)).ToArray(); ChapterObject Chapter = new ChapterObject() { Name = ChapterTitle, Volume = UInt32.Parse(volChapSub[0]), Chapter = UInt32.Parse(volChapSub[1]), Locations = { new LocationObject() { ExtensionName = ExtensionDescriptionAttribute.Name, ExtensionLanguage = ExtensionDescriptionAttribute.Language, Url = ChapterNode.SelectSingleNode(".//span[1]/a").Attributes["href"].Value } }, Released = ChapterNode.SelectSingleNode(".//span[2]").InnerText.ToLower().Equals("today") ? DateTime.Today : (ChapterNode.SelectSingleNode(".//span[2]").InnerText.ToLower().Equals("yesterday") ? DateTime.Today.AddDays(-1) : DateTime.Parse(ChapterNode.SelectSingleNode(".//span[2]").InnerText)) }; if (volChapSub.Length == 3) { Chapter.SubChapter = UInt32.Parse(volChapSub[2]); } Chapters.Add(Chapter); } Chapters.Reverse(); String Cover = MangaPropertiesNode.SelectSingleNode(".//img[1]/@src").Attributes["src"].Value; Cover = Cover.Substring(0, Cover.LastIndexOf('?')); MangaObject MangaObj = new MangaObject() { Name = HtmlEntity.DeEntitize(MangaName), Description = HtmlEntity.DeEntitize(Desciption), AlternateNames = (from AltName in AlternateNames select HtmlEntity.DeEntitize(AltName)).ToList(), CoverLocations = { new LocationObject() { Url = Cover, ExtensionName = ExtensionDescriptionAttribute.Name, ExtensionLanguage = ExtensionDescriptionAttribute.Language } }, Authors = Authors.ToList(), Artists = Artists.ToList(), Genres = Genres.ToList(), Released = Chapters.First().Released, Chapters = Chapters }; MangaObj.AlternateNames.RemoveAll(an => an.ToLower().Equals("none")); MangaObj.Genres.RemoveAll(g => g.ToLower().Equals("none")); return(MangaObj); }
public static int?update(ChapterNode chapterNode) { return(Global.db.Updateable(chapterNode).ExecuteCommand()); }
public ChapterRelationEntity(ChapterNode chapterNode, List <ChapterNode> preChapterNodes, List <ChapterNode> subChapterNodes) { this.chapterNode = chapterNode; this.preChapterNodes = preChapterNodes; this.subChapterNodes = subChapterNodes; }
public MangaObject ParseMangaObject(string content) { HtmlDocument MangaObjectDocument = new HtmlDocument(); MangaObjectDocument.LoadHtml(content); HtmlNode InformationNode = MangaObjectDocument.DocumentNode.SelectSingleNode("//div[contains(@class,'ipsBox')]/div"); String Cover = InformationNode.SelectSingleNode(".//div[1]/img").Attributes["src"].Value; HtmlNode MangaProperties = InformationNode.SelectSingleNode(".//table[contains(@class,'ipb_table')]"), ChapterListing = MangaObjectDocument.DocumentNode.SelectSingleNode("//table[contains(@class,'chapters_list')]"); String MangaName = HtmlEntity.DeEntitize(MangaObjectDocument.DocumentNode.SelectSingleNode("//h1[contains(@class,'ipsType_pagetitle')]").InnerText.Trim()), MangaTypeProp = HtmlEntity.DeEntitize(MangaProperties.SelectSingleNode(".//tr[5]/td[2]").InnerText), Desciption = HtmlEntity.DeEntitize(MangaProperties.SelectSingleNode(".//tr[7]/td[2]").InnerText.Replace("<br>", "\n")); MangaObjectType MangaType = MangaObjectType.Unknown; FlowDirection PageFlowDirection = FlowDirection.RightToLeft; switch (MangaTypeProp.ToLower()) { default: MangaType = MangaObjectType.Unknown; PageFlowDirection = FlowDirection.RightToLeft; break; case "manga (japanese)": MangaType = MangaObjectType.Manga; PageFlowDirection = FlowDirection.RightToLeft; break; case "manhwa (korean)": MangaType = MangaObjectType.Manhwa; PageFlowDirection = FlowDirection.LeftToRight; break; case "manhua (chinese)": MangaType = MangaObjectType.Manhua; PageFlowDirection = FlowDirection.LeftToRight; break; } HtmlNodeCollection AlternateNameNodes = MangaProperties.SelectSingleNode(".//tr[1]/td[2]").SelectNodes(".//span"), GenreNodes = MangaProperties.SelectSingleNode(".//tr[4]/td[2]").SelectNodes(".//a/span"); String[] AlternateNames = { }, Authors = { HtmlEntity.DeEntitize(MangaProperties.SelectSingleNode(".//tr[2]/td[2]/a").InnerText) }, Artists = { HtmlEntity.DeEntitize(MangaProperties.SelectSingleNode(".//tr[3]/td[2]/a").InnerText) }, Genres = { }; if (AlternateNameNodes != null && AlternateNameNodes.Count > 0) { AlternateNames = (from HtmlNode AltNameNode in AlternateNameNodes select HtmlEntity.DeEntitize(AltNameNode.InnerText.Trim())).ToArray(); } if (GenreNodes != null && GenreNodes.Count > 0) { Genres = (from HtmlNode GenreNode in GenreNodes select HtmlEntity.DeEntitize(GenreNode.InnerText.Trim())).ToArray(); } List <ChapterObject> Chapters = new List <ChapterObject>(); HtmlNodeCollection ChapterNodes = ChapterListing.SelectNodes(String.Format(".//tr[contains(@class,'lang_{0} chapter_row')]", ExtensionDescriptionAttribute.Language)); if (ChapterNodes != null && ChapterNodes.Count > 0) { foreach (HtmlNode ChapterNode in ChapterNodes) { HtmlNode VolChapNameNode = ChapterNode.SelectSingleNode("td[1]/a"); Match VolChapMatch = Regex.Match(VolChapNameNode.InnerText, @"(Vol\.(?<Volume>\d+)\s)?(Ch\.(?<Chapter>\d+))(\.(?<SubChapter>\d+))?"); String ChapterName = VolChapNameNode.InnerText.Substring(VolChapMatch.Length + 2).Trim(), ReleaseData = ReleaseData = ChapterNode.SelectSingleNode("td[5]").InnerText; ChapterObject PrevChapter = Chapters.LastOrDefault(); UInt32 Volume = 0, Chapter = 0, SubChapter = 0; if (VolChapMatch.Groups["Volume"].Success) { UInt32.TryParse(VolChapMatch.Groups["Volume"].Value, out Volume); } if (VolChapMatch.Groups["Chapter"].Success) { UInt32.TryParse(VolChapMatch.Groups["Chapter"].Value, out Chapter); } if (VolChapMatch.Groups["SubChapter"].Success) { UInt32.TryParse(VolChapMatch.Groups["SubChapter"].Value, out SubChapter); } DateTime Released = DateTime.Now; if (ReleaseData.Contains("-")) { ReleaseData = ReleaseData.Split(new String[] { " - " }, StringSplitOptions.RemoveEmptyEntries)[0]; DateTime.TryParseExact(ReleaseData, "dd MMMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out Released); } else if (ReleaseData.EndsWith("ago")) { String[] ReleaseDataParts = ReleaseData.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); Double Offset = 1; if (!Double.TryParse(ReleaseDataParts[0], out Offset)) { Offset = 1; } Offset *= -1; switch (ReleaseDataParts[1].ToLower()) { default: case "seconds": Released = Released.AddSeconds(Offset); break; case "minutes": Released = Released.AddMinutes(Offset); break; case "hours": Released = Released.AddHours(Offset); break; case "days": Released = Released.AddDays(Offset); break; case "weeks": Released = Released.AddDays(7 * Offset); break; } } String ChapterUrl = VolChapNameNode.Attributes["href"].Value; String ChapterHash = ChapterUrl.Split('#').Last().Split('_').First(); ChapterUrl = String.Format("https://bato.to/areader?id={0}&p=1&supress_webtoon=t", ChapterHash); ChapterObject chapterObject = new ChapterObject() { Name = HtmlEntity.DeEntitize(ChapterName), Volume = Volume, Chapter = Chapter, SubChapter = SubChapter, Released = Released, Locations = { new LocationObject() { ExtensionName = ExtensionDescriptionAttribute.Name, ExtensionLanguage = ExtensionDescriptionAttribute.Language, Url = ChapterUrl } } }; if (!Chapters.Any(o => o.Chapter == chapterObject.Chapter && ((Int32)o.SubChapter - chapterObject.SubChapter).InRange(-4, 4))) { Chapters.Add(chapterObject); } else { Chapters.Find(o => o.Chapter == chapterObject.Chapter && ((Int32)o.SubChapter - chapterObject.SubChapter).InRange(-4, 4)).Merge(chapterObject); } } } Chapters.Reverse(); Double Rating = -1; try { HtmlNode RatingNode = MangaObjectDocument.DocumentNode.SelectSingleNode("//div[contains(@class,'rating')]"); String RatingText = new String(RatingNode.InnerText.Trim().Substring(1, 4).Where(IsValidRatingChar).ToArray()); Double.TryParse(RatingText, out Rating); } catch { } return(new MangaObject() { Name = MangaName, MangaType = MangaType, PageFlowDirection = PageFlowDirection, Description = HtmlEntity.DeEntitize(Desciption), AlternateNames = AlternateNames.ToList(), CoverLocations = { new LocationObject() { Url = Cover, ExtensionName = ExtensionDescriptionAttribute.Name, ExtensionLanguage = ExtensionDescriptionAttribute.Language } }, Authors = Authors.ToList(), Artists = Artists.ToList(), Genres = Genres.ToList(), Released = (Chapters.FirstOrDefault() ?? new ChapterObject()).Released, Chapters = Chapters, Rating = Rating }); }
void GetList_www_biquge_info(string _html) { ChapterList.Clear(); PageLinkList.Clear(); listBox1.Items.Clear(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(_html); HtmlAgilityPack.HtmlNode _n = doc.DocumentNode.SelectSingleNode("//div[@class='box_con']//div[@id='list']"); //textBox1.Text = _n.InnerHtml; HtmlAgilityPack.HtmlDocument doc2 = new HtmlAgilityPack.HtmlDocument(); doc2.LoadHtml(_n.InnerHtml); HtmlAgilityPack.HtmlNodeCollection _n2 = doc2.DocumentNode.SelectNodes("//dd"); bool _begin = false; foreach (HtmlAgilityPack.HtmlNode _node in _n2) { string _ht = _node.OuterHtml; // if (_ht.IndexOf("上架感言") >= 0) // { // continue; // } if (_ht.IndexOf("0001 赔我一条裤子") >= 0) { _begin = true; } if (!_begin) { continue; } if (_ht.IndexOf("=\"") > 0 && _ht.IndexOf("\">") > 0) { int _s1 = _ht.IndexOf("href="); int _e1 = _ht.IndexOf("\" title"); char[] _link = new char[_e1 - _s1 - 6]; _ht.CopyTo(_s1 + 6, _link, 0, _e1 - _s1 - 6); string _link_str = new string(_link); PageLinkList.Add(_link_str); string _listtxt = string.Format("{0} [{1}]", _node.InnerText, _link_str); ChapterNode _chapterNode = new ChapterNode(); _chapterNode._name1 = _node.InnerText; ChapterList.Add(_chapterNode); int _idx = listBox1.Items.Add(_listtxt); //Page1_www_biquge_info(_idx); } } }
public MangaObject ParseMangaObject(String content) { HtmlDocument MangaObjectDocument = new HtmlDocument(); MangaObjectDocument.LoadHtml(content); String MangaCoverPrime = MangaObjectDocument.GetElementbyId("mangaimg").SelectSingleNode(".//img").Attributes["src"].Value; Regex MangaCoverRegex = new Regex(@"(\d+)\.jpg"); Int32 MangaCoverInt = Int32.Parse(MangaCoverRegex.Match(MangaCoverPrime).Groups[1].Value); List <LocationObject> Covers = new List <LocationObject>(); for (Int32 mcI = 0; mcI <= MangaCoverInt; ++mcI) { Covers.Add(new LocationObject() { Url = MangaCoverRegex.Replace(MangaCoverPrime, String.Format("{0}.jpg", mcI)), ExtensionName = ExtensionDescriptionAttribute.Name, ExtensionLanguage = ExtensionDescriptionAttribute.Language }); } Covers.TrimExcess(); HtmlNode MangaProperties = MangaObjectDocument.GetElementbyId("mangaproperties").SelectSingleNode(".//table"), ChapterListing = MangaObjectDocument.GetElementbyId("listing"), MangaDesciption = MangaObjectDocument.GetElementbyId("readmangasum").SelectSingleNode(".//p"); String MangaName = HtmlEntity.DeEntitize(MangaProperties.SelectSingleNode(".//tr[1]/td[2]/h2").InnerText), ReadDirection = MangaProperties.SelectSingleNode(".//tr[7]/td[2]").InnerText, ReleaseYear = Regex.Match(MangaProperties.SelectSingleNode(".//tr[3]/td[2]").InnerText, @"\d+").Value, Release = String.Format("01/01/{0}", String.IsNullOrWhiteSpace(ReleaseYear) ? "0001" : ReleaseYear), Desciption = MangaDesciption != null ? MangaDesciption.InnerText : String.Empty; MangaObjectType MangaType = MangaObjectType.Unknown; FlowDirection PageFlowDirection = FlowDirection.RightToLeft; switch (ReadDirection.ToLower()) { default: MangaType = MangaObjectType.Unknown; PageFlowDirection = FlowDirection.RightToLeft; break; case "right to left": MangaType = MangaObjectType.Manga; PageFlowDirection = FlowDirection.RightToLeft; break; case "left to right": MangaType = MangaObjectType.Manhwa; PageFlowDirection = FlowDirection.LeftToRight; break; } String[] AlternateNames = MangaProperties.SelectSingleNode(".//tr[2]/td[2]").InnerText.Split(new String[] { ", " }, StringSplitOptions.RemoveEmptyEntries), Authors = MangaProperties.SelectSingleNode(".//tr[5]/td[2]").InnerText.Split(new String[] { ", " }, StringSplitOptions.RemoveEmptyEntries), Artists = MangaProperties.SelectSingleNode(".//tr[6]/td[2]").InnerText.Split(new String[] { ", " }, StringSplitOptions.RemoveEmptyEntries), Genres = (from HtmlNode GenreNode in MangaProperties.SelectSingleNode(".//tr[8]/td[2]").SelectNodes(".//span[contains(@class,'genretags')]") select HtmlEntity.DeEntitize(GenreNode.InnerText)).ToArray(); ChapterObject[] Chapters = (from HtmlNode ChapterNode in ChapterListing.SelectNodes(".//tr[not(contains(@class,'table_head'))]") select new ChapterObject() { Name = HtmlEntity.DeEntitize(ChapterNode.SelectSingleNode(".//td[1]").LastChild.InnerText.Substring(3).Trim()), Chapter = UInt32.Parse(ChapterNode.SelectSingleNode(".//td[1]/a").InnerText.Substring(ChapterNode.SelectSingleNode(".//td[1]/a").InnerText.LastIndexOf(' ') + 1)), Locations = { new LocationObject() { ExtensionName = ExtensionDescriptionAttribute.Name, ExtensionLanguage = ExtensionDescriptionAttribute.Language, Url = String.Format("{0}{1}", ExtensionDescriptionAttribute.RootUrl, ChapterNode.SelectSingleNode(".//td[1]/a").Attributes["href"].Value) } }, Released = DateTime.Parse(ChapterNode.SelectSingleNode(".//td[2]").InnerText) }).ToArray(); return(new MangaObject() { Name = HtmlEntity.DeEntitize(MangaName), MangaType = MangaType, PageFlowDirection = PageFlowDirection, Description = HtmlEntity.DeEntitize(Desciption), AlternateNames = AlternateNames.ToList(), CoverLocations = Covers, Authors = (from Author in Authors select HtmlEntity.DeEntitize(Author)).ToList(), Artists = (from Artist in Artists select HtmlEntity.DeEntitize(Artist)).ToList(), Genres = Genres.ToList(), Released = DateTime.Parse(Release), Chapters = Chapters.ToList() }); }
public static int?insert(ChapterNode chapterNode) { return(chapterNode.id != null?Global.db.Saveable <ChapterNode>(chapterNode).ExecuteCommand() : Global.db.Insertable(chapterNode).ExecuteCommand()); }