From c3ef17038500ffc53bf925a4c5e60d2acdea8a18 Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Sat, 3 Jul 2021 16:31:55 +0530 Subject: [PATCH] Lightnovelpub: Fix chapterUrl --- src/sources/en/lightnovelpub.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/sources/en/lightnovelpub.js b/src/sources/en/lightnovelpub.js index f08ea08e..1ee592fb 100644 --- a/src/sources/en/lightnovelpub.js +++ b/src/sources/en/lightnovelpub.js @@ -113,22 +113,18 @@ const parseNovelAndChapters = async (novelUrl) => { let novelChapters = []; - let firstChapterNo, totalChapters; - - totalChapters = $(".header-stats > span").first().text().match(/\d+/)[0]; - firstChapterNo = $(".chapter-no").first().text().match(/\d+/)[0]; - - for (let i = firstChapterNo; i <= totalChapters; i++) { - const chapterName = "Chapter " + i; - - const releaseDate = null; - - const chapterUrl = "chapter-" + i; + $("ul.chapter-list > li").each(function (result) { + const chapterName = $(this).find(".chapter-title").text().trim(); + const releaseDate = $(this).find("time").text().trim(); + const chapterUrl = $(this) + .find("a") + .attr("href") + .replace(`/novel/${novelUrl}/`, ""); const chapter = { chapterName, releaseDate, chapterUrl }; novelChapters.push(chapter); - } + }); novel.chapters = novelChapters;