Skip to content

Commit

Permalink
Fix next chapter mode on some Blogspot sites.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitch528 committed Mar 10, 2016
1 parent c0e70f2 commit 0875ea6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions WebNovelConverter/Sources/BlogspotSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public class BlogspotSource : WebNovelSource

protected readonly List<string> NextChapterNames = new List<string>
{
"Next Chapter"
"Next Chapter",
"Next"
};

protected readonly List<string> BloatClasses = new List<string>
Expand Down Expand Up @@ -101,8 +102,9 @@ public override async Task<WebNovelChapter> GetChapterAsync(
IElement nextChapterElement = (from e in rootElement?.Descendents<IElement>() ?? new List<IElement>()
where e.LocalName == "a"
let text = e.Text()
from name in NextChapterNames
where text.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0
let a = NextChapterNames.FirstOrDefault(p => text.IndexOf(p, StringComparison.OrdinalIgnoreCase) >= 0)
where a != null
orderby NextChapterNames.IndexOf(a)
select e).FirstOrDefault();

if (nextChapterElement != null)
Expand Down
5 changes: 3 additions & 2 deletions WebNovelConverter/Sources/WordPressSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ public override async Task<WebNovelChapter> GetChapterAsync(ChapterLink link,
IElement nextChapterElement = (from e in rootElement.Descendents<IElement>() ?? new List<IElement>()
where e.LocalName == "a"
let text = e.Text()
where NextChapterNames.Any(p => text.IndexOf(p, StringComparison.OrdinalIgnoreCase) >= 0)
|| (e.HasAttribute("rel") && e.GetAttribute("rel") == "next")
let a = NextChapterNames.FirstOrDefault(p => text.IndexOf(p, StringComparison.OrdinalIgnoreCase) >= 0)
where a != null || (e.HasAttribute("rel") && e.GetAttribute("rel") == "next")
orderby NextChapterNames.IndexOf(a)
select e).FirstOrDefault();

WebNovelChapter chapter = new WebNovelChapter();
Expand Down

0 comments on commit 0875ea6

Please sign in to comment.