From 387b2b036de3b2b4d88fcd8f97b4b463d8b282ef Mon Sep 17 00:00:00 2001 From: HeliosLHC <6173500+HeliosLHC@users.noreply.github.com> Date: Sat, 19 Aug 2023 23:38:40 -0400 Subject: [PATCH] support single chapter volumes --- sources/en/q/qidianunderground.py | 33 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/sources/en/q/qidianunderground.py b/sources/en/q/qidianunderground.py index db2d78cf6..b4a067e72 100644 --- a/sources/en/q/qidianunderground.py +++ b/sources/en/q/qidianunderground.py @@ -71,17 +71,32 @@ def read_novel_info(self): data = self.get_json(self.novel_url) for vol_id, item in enumerate(data, 1): - start_ch, final_ch = re.findall(r"(\d+) - (\d+)", item["Text"])[0] - self.volumes.append( - { - "id": vol_id, - "title": "Chapters %s - %s" % (start_ch, final_ch), - } - ) - for j in range(int(start_ch), int(final_ch) + 1): + if "-" in item["Text"]: + start_ch, final_ch = re.findall(r"(\d+) - (\d+)", item["Text"])[0] + self.volumes.append( + { + "id": vol_id, + "title": "Chapters %s - %s" % (start_ch, final_ch), + } + ) + for j in range(int(start_ch), int(final_ch) + 1): + self.chapters.append( + { + "id": j, + "volume": vol_id, + "url": item["Href"], + } + ) + else: + self.volumes.append( + { + "id": vol_id, + "title": "Chapters %s" % (item["Text"]), + } + ) self.chapters.append( { - "id": j, + "id": int(item["Text"]), "volume": vol_id, "url": item["Href"], }