Foxaholic: Fix novelUrl & chapterUrl

This commit is contained in:
Rajarshee Chatterjee
2021-05-31 09:28:11 +05:30
parent 20cc94f77f
commit 787dde7469
+18 -15
View File
@@ -19,8 +19,8 @@ const novelsScraper = async (req, res) => {
const novelName = $(this).find(".h5 > a").text(); const novelName = $(this).find(".h5 > a").text();
const novelCover = $(this).find("img").attr("data-src"); const novelCover = $(this).find("img").attr("data-src");
let novelUrl = $(this).find(".h5 > a").attr("href"); let novelUrl = $(this).find(".h5 > a").attr("href").split("/")[4];
novelUrl = novelUrl.replace(`${baseUrl}novel/`, ""); novelUrl += "/";
const novel = { const novel = {
extensionId: 22, extensionId: 22,
@@ -115,7 +115,11 @@ const novelScraper = async (req, res) => {
releaseDate = $(this).find("span").text().trim(); releaseDate = $(this).find("span").text().trim();
chapterUrl = $(this).find("a").attr("href").replace(url, ""); chapterUrl = $(this).find("a").attr("href").split("/");
chapterUrl[6]
? (chapterUrl = chapterUrl[5] + "/" + chapterUrl[6])
: (chapterUrl = chapterUrl[5]);
novelChapters.push({ chapterName, releaseDate, chapterUrl }); novelChapters.push({ chapterName, releaseDate, chapterUrl });
}); });
@@ -152,23 +156,23 @@ const chapterScraper = async (req, res) => {
let nextChapter = null; let nextChapter = null;
if ($(".nav-next").length) { if ($(".nav-next").length) {
nextChapter = $(".nav-next") nextChapter = $(".nav-next").find("a").attr("href").split("/");
.find("a") nextChapter[6]
.attr("href") ? (nextChapter = nextChapter[5] + "/" + nextChapter[6])
.replace(baseUrl + "novel/" + novelUrl + "/", ""); : (nextChapter = nextChapter[5]);
} }
let prevChapter = null; let prevChapter = null;
if ($(".nav-previous").length) { if ($(".nav-previous").length) {
prevChapter = $(".nav-previous") prevChapter = $(".nav-previous").find("a").attr("href").split("/");
.find("a") prevChapter[6]
.attr("href") ? (prevChapter = prevChapter[5] + "/" + prevChapter[6])
.replace(baseUrl + "novel/" + novelUrl + "/", ""); : (prevChapter = prevChapter[5]);
} }
novelUrl += "/"; novelUrl += "/";
chapterUrl = optionalUrl + chapterUrl + "/"; chapterUrl = optionalUrl + chapterUrl;
const chapter = { const chapter = {
extensionId: 22, extensionId: 22,
@@ -199,9 +203,8 @@ const searchScraper = async (req, res) => {
const novelName = $(this).find(".h4 > a").text(); const novelName = $(this).find(".h4 > a").text();
const novelCover = $(this).find("img").attr("data-src"); const novelCover = $(this).find("img").attr("data-src");
let novelUrl = $(this).find(".h4 > a").attr("href"); let novelUrl = $(this).find(".h4 > a").attr("href").split("/")[4];
novelUrl = novelUrl.replace(`${baseUrl}novel/`, ""); novelUrl += "/";
const novel = { const novel = {
extensionId: 22, extensionId: 22,
novelName, novelName,