1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2025-12-09 09:53:30 +01:00

Improve Prechapter author note detection

This commit is contained in:
Alex Raubach 2018-09-27 13:48:33 -04:00
parent a9dfdb5dd3
commit 1ff009f893

View file

@ -55,9 +55,8 @@ class RoyalRoad(Site):
author_note = soup.find_all('div', class_='author-note-portlet')
if len(author_note) is 1:
# The first child div of portlet-body is either the chapter content or an author note
first_div = soup.find('div', class_='portlet-body').find('div', recursive=False)
if first_div and ('author-note-portlet' in first_div['class']):
# Find the parent of chapter-content and check if the author's note is the first child div
if 'author-note-portlet' in soup.find('div', class_='chapter-content').parent.find('div')['class']:
content = author_note[0].prettify() + '<hr/>' + content
else: # The author note must be after the chapter content
content = content + '<hr/>' + author_note[0].prettify()