From 1ff009f89394bc8cb7da8b7aeccce79c5944a97b Mon Sep 17 00:00:00 2001 From: Alex Raubach Date: Thu, 27 Sep 2018 13:48:33 -0400 Subject: [PATCH] Improve Prechapter author note detection --- sites/royalroad.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sites/royalroad.py b/sites/royalroad.py index 00eb684..c29a2fc 100644 --- a/sites/royalroad.py +++ b/sites/royalroad.py @@ -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() + '
' + content else: # The author note must be after the chapter content content = content + '
' + author_note[0].prettify()