Skip to content

Commit

Permalink
修复单章节文章,保存首页信息
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed May 25, 2020
1 parent b4748c5 commit d1362bb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
43 changes: 34 additions & 9 deletions Novel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ private void getUserDetail()
userDetail += " "+tb.SelectSingleNode("./tr[" + (isWriter ? "8" : "7") + "]//div/span").InnerText;
}

private string stripEmpty(string input)
{
return input.Replace("\n", "").Replace("\r", "").
Replace(" ", "");
}

public bool getIndex(int novelid){
this.novelid = novelid;
setPrompt("下载首页中……", Color.Orange);
Expand Down Expand Up @@ -282,8 +288,7 @@ public bool getIndex(int novelid){
this.author = hnc[0].SelectSingleNode("a").InnerText;
continue;
}
this.descriptions += n.InnerText.Replace("\n", "").Replace("\r", "").
Replace(" ", "").Replace(":", ":") + "\n";
this.descriptions += stripEmpty(n.InnerText).Replace(":", ":") + "\n";
}
//chapters
HtmlNodeCollection chaps = root.SelectNodes("//div[@style='padding-left:10px']/a");
Expand All @@ -296,8 +301,18 @@ public bool getIndex(int novelid){
}
else
{
this.name = root.SelectSingleNode("//span[@itemprop='articleSection']").InnerText;
this.author = root.SelectSingleNode("//span[@itemprop='author']").InnerText;
var nameElem = root.SelectSingleNode("//span[@itemprop='articleSection']");
if (nameElem == null)
{
nameElem = root.SelectSingleNode("//span[@class='bigtext']");
}
this.name = stripEmpty(nameElem.InnerText);
var authorElem = root.SelectSingleNode("//span[@itemprop='author']");
if(authorElem == null)
{
authorElem = root.SelectSingleNode("//td[@class='noveltitle']/a");
}
this.author = authorElem.InnerText;
hnc = root.SelectNodes("//ul[@class='rightul']/li");
for (int idx=0;idx<8;idx++)
{
Expand All @@ -317,13 +332,19 @@ public bool getIndex(int novelid){
}
this.descriptions += root.SelectSingleNode("//div[@class='smallreadbody']/div[@id='novelintro']").InnerText;
HtmlNodeCollection chaps = root.SelectNodes("//table[@class='cytable']/tbody/tr[@itemtype='http://schema.org/Chapter']");
this.chapterCount = chaps.Count;
foreach (HtmlNode c in chaps)
if(chaps != null)
{
foreach (HtmlNode c in chaps)
{
if (c.InnerHtml.IndexOf("onebook_vip") != -1)
vipChapters.Add(int.Parse(c.SelectSingleNode("./td[1]").InnerText.Trim()));
}
this.chapterCount = chaps.Count;
} else
{
if (c.InnerHtml.IndexOf("onebook_vip") != -1)
vipChapters.Add(int.Parse(c.SelectSingleNode("./td[1]").InnerText.Trim()));
// 没有独立章节
this.chapterCount = 1;
}
this.chapterCount = chaps.Count;
}
isFinnished = descriptions.IndexOf("连载中") == -1;
setPrompt("首页分析完成,可以开始了");
Expand Down Expand Up @@ -409,6 +430,10 @@ public void saveChapter(Chapter chpt, bool split)

FileStream fs = new FileStream(savepath, FileMode.Append, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
if(chpt.chapterIndex == 1)
{
sw.WriteLine(this.descriptions + "\r\n");
}
sw.WriteLine(chpt.ToString() + "\r\n");
sw.Close();
fs.Close();
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.4")]
[assembly: AssemblyFileVersion("1.2.4")]
[assembly: AssemblyVersion("1.2.5")]
[assembly: AssemblyFileVersion("1.2.5")]

0 comments on commit d1362bb

Please sign in to comment.