From 6895a0eb61ebd3a7cd738c908fd700205240d6b4 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Fri, 31 Mar 2023 23:51:27 -0500 Subject: [PATCH] AO3 single-chapter story bugs --- sites/ao3.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sites/ao3.py b/sites/ao3.py index 10b8441..b672e06 100644 --- a/sites/ao3.py +++ b/sites/ao3.py @@ -58,7 +58,10 @@ class ArchiveOfOurOwn(Site): # Fetch the chapter list as well because it contains info that's not in the full work nav_soup = self._soup(f'https://archiveofourown.org/works/{workid}/navigate') - chapters = soup.find_all(id=re.compile(r"chapter-\d+")) + chapters = soup.select('#chapters > div') + if len(chapters) == 1: + # in a single-chapter story the #chapters div is actually the chapter + chapters = [soup.find(id='chapters').parent] for index, chapter in enumerate(nav_soup.select('#main ol[role="navigation"] li')): link = chapter.find('a')