Add Novela Wuxia (Closes #33)
This commit is contained in:
@@ -35,6 +35,7 @@ Sources for [LNReader](https://github.com/rajarsheechatterjee/lnreader)
|
|||||||
| https://yuukitls.com/ | :heavy_check_mark: |
|
| https://yuukitls.com/ | :heavy_check_mark: |
|
||||||
| https://hasutl.wordpress.com/ | :heavy_check_mark: |
|
| https://hasutl.wordpress.com/ | :heavy_check_mark: |
|
||||||
| https://oasistranslations.wordpress.com/ | :heavy_check_mark: |
|
| https://oasistranslations.wordpress.com/ | :heavy_check_mark: |
|
||||||
|
| http://www.novelawuxia.com/ | :heavy_check_mark: |
|
||||||
|
|
||||||
## Setup locally
|
## Setup locally
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ app.use("/api/26/", require("./src/es/novelasligera/NovelasLigera"));
|
|||||||
app.use("/api/28/", require("./src/es/yuukitls/YuukiTls"));
|
app.use("/api/28/", require("./src/es/yuukitls/YuukiTls"));
|
||||||
app.use("/api/29/", require("./src/es/hasutl/Hasutl"));
|
app.use("/api/29/", require("./src/es/hasutl/Hasutl"));
|
||||||
app.use("/api/30/", require("./src/es/oasistranslations/OasisTranslations"));
|
app.use("/api/30/", require("./src/es/oasistranslations/OasisTranslations"));
|
||||||
|
app.use("/api/31/", require("./src/es/novelawuxia/NovelaWuxia"));
|
||||||
|
|
||||||
const PORT = process.env.PORT || 5000;
|
const PORT = process.env.PORT || 5000;
|
||||||
|
|
||||||
|
|||||||
@@ -278,6 +278,15 @@ extensions = [
|
|||||||
sourceLanguage: "Spanish",
|
sourceLanguage: "Spanish",
|
||||||
status: 1,
|
status: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
sourceId: 31,
|
||||||
|
sourceUrl: "http://www.novelawuxia.com/",
|
||||||
|
sourceName: "Novela Wuxia",
|
||||||
|
sourceCover:
|
||||||
|
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/novelawuxia/icon.png?raw=true",
|
||||||
|
sourceLanguage: "Spanish",
|
||||||
|
status: 1,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = extensions;
|
module.exports = extensions;
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
const express = require("express");
|
||||||
|
const NovelaWuxiaScraper = require("./NovelaWuxiaScraper");
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.get("/novels/", NovelaWuxiaScraper.novelsScraper);
|
||||||
|
|
||||||
|
router.get("/novel/:novelUrl", NovelaWuxiaScraper.novelScraper);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
"/novel/:novelUrl/:year/:month/:chapterUrl",
|
||||||
|
NovelaWuxiaScraper.chapterScraper
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get("/search/", NovelaWuxiaScraper.searchScraper);
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
const cheerio = require("cheerio");
|
||||||
|
const fetch = require("node-fetch");
|
||||||
|
const { htmlToText } = require("html-to-text");
|
||||||
|
const { parseHtml } = require("../../helper");
|
||||||
|
|
||||||
|
const baseUrl = "http://www.novelawuxia.com/";
|
||||||
|
|
||||||
|
function getNovelName(y) {
|
||||||
|
return y.replace(/-/g, " ").replace(/(?:^|\s)\S/g, (a) => a.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
const novelsScraper = async (req, res) => {
|
||||||
|
let url = baseUrl + "p/todas-las-novelas.html";
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novels = [];
|
||||||
|
|
||||||
|
$(".post-body.entry-content")
|
||||||
|
.find("a")
|
||||||
|
.each(function (result) {
|
||||||
|
let novelName = $(this)
|
||||||
|
.attr("href")
|
||||||
|
.split("/")
|
||||||
|
.pop()
|
||||||
|
.replace(".html", "");
|
||||||
|
novelName = getNovelName(novelName);
|
||||||
|
const novelCover = $(this).find("img").attr("src");
|
||||||
|
|
||||||
|
let novelUrl = $(this).attr("href");
|
||||||
|
novelUrl = novelUrl.replace(`${baseUrl}p/`, "") + "/";
|
||||||
|
|
||||||
|
const novel = {
|
||||||
|
extensionId: 31,
|
||||||
|
novelName,
|
||||||
|
novelCover,
|
||||||
|
novelUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
novels.push(novel);
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(novels);
|
||||||
|
};
|
||||||
|
|
||||||
|
const novelScraper = async (req, res) => {
|
||||||
|
const novelUrl = req.params.novelUrl;
|
||||||
|
const url = `${baseUrl}p/${novelUrl}`;
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novel = {};
|
||||||
|
|
||||||
|
novel.extensionId = 31;
|
||||||
|
|
||||||
|
novel.sourceName = "Novela Wuxia";
|
||||||
|
|
||||||
|
novel.sourceUrl = url;
|
||||||
|
|
||||||
|
novel.novelUrl = `${novelUrl}/`;
|
||||||
|
|
||||||
|
novel.novelName = $("h1.post-title").text().trim();
|
||||||
|
|
||||||
|
novel.novelCover = $(`img[title="${novel.novelName}"]`).attr("src");
|
||||||
|
|
||||||
|
$(".col-6.col-sm-6 > b").each(function (result) {
|
||||||
|
const detailName = $(this).text();
|
||||||
|
const detail = $(this)[0].nextSibling.nodeValue.trim();
|
||||||
|
|
||||||
|
if (detailName.includes("Autor")) {
|
||||||
|
novel["Author(s)"] = detail.replace("Autor:", "");
|
||||||
|
}
|
||||||
|
if (detailName.includes("Ilustrador")) {
|
||||||
|
novel["Artist(s)"] = detail.replace("Ilustrador: ", "");
|
||||||
|
}
|
||||||
|
if (detailName.includes("Estatus")) {
|
||||||
|
novel.Status = detail.replace("Estatus: ", "");
|
||||||
|
}
|
||||||
|
if (detailName.includes("Géneros:")) {
|
||||||
|
novel["Genres(s)"] = detail
|
||||||
|
.replace("Géneros: ", "")
|
||||||
|
.replace(/,\s/g, ",");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('div[style="text-align: center;"]').each(function (result) {
|
||||||
|
const detailName = $(this).text();
|
||||||
|
|
||||||
|
if (detailName.includes("Sinopsis")) {
|
||||||
|
novel.novelSummary = $(this)
|
||||||
|
.next()
|
||||||
|
.text()
|
||||||
|
.replace("Sinopsis", "")
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let novelChapters = [];
|
||||||
|
|
||||||
|
$(
|
||||||
|
'div[style="-webkit-text-stroke-width: 0px; color: black; font-family: "times new roman"; font-size: medium; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: center; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"]'
|
||||||
|
)
|
||||||
|
.find("a")
|
||||||
|
.each(function (res) {
|
||||||
|
const chapterName = $(this).text();
|
||||||
|
const chapterUrl = $(this).attr("href").replace(baseUrl, "");
|
||||||
|
const releaseDate = null;
|
||||||
|
|
||||||
|
const chapter = { chapterName, releaseDate, chapterUrl };
|
||||||
|
|
||||||
|
novelChapters.push(chapter);
|
||||||
|
});
|
||||||
|
|
||||||
|
novel.novelChapters = novelChapters;
|
||||||
|
|
||||||
|
res.json(novel);
|
||||||
|
};
|
||||||
|
|
||||||
|
const chapterScraper = async (req, res) => {
|
||||||
|
let novelUrl = req.params.novelUrl;
|
||||||
|
let year = req.params.year;
|
||||||
|
let month = req.params.month;
|
||||||
|
let chapterUrl = req.params.chapterUrl;
|
||||||
|
|
||||||
|
const url = `${baseUrl}${year}/${month}/${chapterUrl}`;
|
||||||
|
|
||||||
|
console.log(url);
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let chapterName = $("h1.post-title").text().trim();
|
||||||
|
|
||||||
|
let chapterText = $(".post-body.entry-content").html();
|
||||||
|
chapterText = parseHtml(chapterText);
|
||||||
|
|
||||||
|
let nextChapter = null;
|
||||||
|
let prevChapter = null;
|
||||||
|
|
||||||
|
novelUrl = novelUrl + "/";
|
||||||
|
chapterUrl = chapterUrl + "/";
|
||||||
|
|
||||||
|
const chapter = {
|
||||||
|
extensionId: 31,
|
||||||
|
novelUrl,
|
||||||
|
chapterUrl,
|
||||||
|
chapterName,
|
||||||
|
chapterText,
|
||||||
|
nextChapter,
|
||||||
|
prevChapter,
|
||||||
|
};
|
||||||
|
|
||||||
|
res.json(chapter);
|
||||||
|
};
|
||||||
|
|
||||||
|
const searchScraper = async (req, res) => {
|
||||||
|
const searchTerm = req.query.s;
|
||||||
|
|
||||||
|
const url = `${baseUrl}search?q=${searchTerm}`;
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novels = [];
|
||||||
|
|
||||||
|
$(".date-outer").each(function (result) {
|
||||||
|
let novelName = $(this)
|
||||||
|
.find("a")
|
||||||
|
.attr("href")
|
||||||
|
.split("/")
|
||||||
|
.pop()
|
||||||
|
.replace(/-capitulo(.*?).html/, "");
|
||||||
|
|
||||||
|
const novelUrl = novelName + ".html/";
|
||||||
|
|
||||||
|
novelName = getNovelName(novelName);
|
||||||
|
|
||||||
|
const exists = novels.some((novel) => novel.novelName === novelName);
|
||||||
|
|
||||||
|
if (!exists) {
|
||||||
|
const novelCover = null;
|
||||||
|
const novel = {
|
||||||
|
extensionId: 31,
|
||||||
|
novelName,
|
||||||
|
novelCover,
|
||||||
|
novelUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
novels.push(novel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(novels);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = vipNovelScraper = {
|
||||||
|
novelsScraper,
|
||||||
|
novelScraper,
|
||||||
|
chapterScraper,
|
||||||
|
searchScraper,
|
||||||
|
};
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
Reference in New Issue
Block a user