From 4e9f66224443ed427eb9e4073557244db1cae4e7 Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Thu, 3 Jun 2021 14:17:27 +0530 Subject: [PATCH] YuukiTls: Fix chapters and novelCover --- src/es/yukitls/YuukiTlsScraper.js | 48 ++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/src/es/yukitls/YuukiTlsScraper.js b/src/es/yukitls/YuukiTlsScraper.js index 05dfc00..dd9e179 100644 --- a/src/es/yukitls/YuukiTlsScraper.js +++ b/src/es/yukitls/YuukiTlsScraper.js @@ -62,7 +62,7 @@ const novelScraper = async (req, res) => { .replace(/[\t\n]/g, "") .trim(); - novel.novelCover = $(".entry-content > div > img").attr("src"); + novel.novelCover = $('img[loading="lazy"]').attr("src"); $(".entry-content") .find("div") @@ -93,23 +93,43 @@ const novelScraper = async (req, res) => { let novelChapters = []; - $(".entry-content") - .find("li") - .each(function (result) { - let chapterUrl = $(this).find("a").attr("href"); + if ($(".entry-content").find("li").length) { + $(".entry-content") + .find("li") + .each(function (result) { + let chapterUrl = $(this).find("a").attr("href"); - if (chapterUrl && chapterUrl.includes(baseUrl)) { - const chapterName = $(this).text(); - const releaseDate = null; + if (chapterUrl && chapterUrl.includes(baseUrl)) { + const chapterName = $(this).text(); + const releaseDate = null; - chapterUrl = chapterUrl.split("/"); - chapterUrl = chapterUrl[chapterUrl.length - 2] + "/"; + chapterUrl = chapterUrl.split("/"); + chapterUrl = chapterUrl[chapterUrl.length - 2] + "/"; - const chapter = { chapterName, releaseDate, chapterUrl }; + const chapter = { chapterName, releaseDate, chapterUrl }; - novelChapters.push(chapter); - } - }); + novelChapters.push(chapter); + } + }); + } else { + $(".entry-content") + .find("p") + .each(function (result) { + let chapterUrl = $(this).find("a").attr("href"); + + if (chapterUrl && chapterUrl.includes(baseUrl)) { + const chapterName = $(this).text(); + const releaseDate = null; + + chapterUrl = chapterUrl.split("/"); + chapterUrl = chapterUrl[chapterUrl.length - 2] + "/"; + + const chapter = { chapterName, releaseDate, chapterUrl }; + + novelChapters.push(chapter); + } + }); + } novel.novelChapters = novelChapters;