YuukiTls: Fix chapters and novelCover
This commit is contained in:
@@ -62,7 +62,7 @@ const novelScraper = async (req, res) => {
|
|||||||
.replace(/[\t\n]/g, "")
|
.replace(/[\t\n]/g, "")
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
novel.novelCover = $(".entry-content > div > img").attr("src");
|
novel.novelCover = $('img[loading="lazy"]').attr("src");
|
||||||
|
|
||||||
$(".entry-content")
|
$(".entry-content")
|
||||||
.find("div")
|
.find("div")
|
||||||
@@ -93,23 +93,43 @@ const novelScraper = async (req, res) => {
|
|||||||
|
|
||||||
let novelChapters = [];
|
let novelChapters = [];
|
||||||
|
|
||||||
$(".entry-content")
|
if ($(".entry-content").find("li").length) {
|
||||||
.find("li")
|
$(".entry-content")
|
||||||
.each(function (result) {
|
.find("li")
|
||||||
let chapterUrl = $(this).find("a").attr("href");
|
.each(function (result) {
|
||||||
|
let chapterUrl = $(this).find("a").attr("href");
|
||||||
|
|
||||||
if (chapterUrl && chapterUrl.includes(baseUrl)) {
|
if (chapterUrl && chapterUrl.includes(baseUrl)) {
|
||||||
const chapterName = $(this).text();
|
const chapterName = $(this).text();
|
||||||
const releaseDate = null;
|
const releaseDate = null;
|
||||||
|
|
||||||
chapterUrl = chapterUrl.split("/");
|
chapterUrl = chapterUrl.split("/");
|
||||||
chapterUrl = chapterUrl[chapterUrl.length - 2] + "/";
|
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;
|
novel.novelChapters = novelChapters;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user