Add Tunovelaligera
This commit is contained in:
@@ -27,6 +27,7 @@ Sources for [LNReader](https://github.com/rajarsheechatterjee/lnreader)
|
|||||||
| https://m.readlightnovel.cc/ | :heavy_check_mark: |
|
| https://m.readlightnovel.cc/ | :heavy_check_mark: |
|
||||||
| http://wuxiaworld.cloud/ | :heavy_check_mark: |
|
| http://wuxiaworld.cloud/ | :heavy_check_mark: |
|
||||||
| https://foxaholic.com/ | :heavy_check_mark: |
|
| https://foxaholic.com/ | :heavy_check_mark: |
|
||||||
|
| https://tunovelaligera.com/ | :heavy_check_mark: |
|
||||||
|
|
||||||
## Setup locally
|
## Setup locally
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ app.get("/", (req, res) =>
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// English
|
||||||
app.get("/api/", (req, res) => res.json(sources));
|
app.get("/api/", (req, res) => res.json(sources));
|
||||||
app.use("/api/1/", require("./src/en/boxnovel/BoxNovel"));
|
app.use("/api/1/", require("./src/en/boxnovel/BoxNovel"));
|
||||||
app.use("/api/2/", require("./src/en/readlightnovel/ReadLightNovel"));
|
app.use("/api/2/", require("./src/en/readlightnovel/ReadLightNovel"));
|
||||||
@@ -41,6 +42,9 @@ app.use("/api/20/", require("./src/en/wuxiaworldcloud/WuxiaWorldCloud"));
|
|||||||
app.use("/api/21/", require("./src/en/woopread/WoopRead"));
|
app.use("/api/21/", require("./src/en/woopread/WoopRead"));
|
||||||
app.use("/api/22/", require("./src/en/foxaholic/Foxaholic"));
|
app.use("/api/22/", require("./src/en/foxaholic/Foxaholic"));
|
||||||
|
|
||||||
|
// Spanish
|
||||||
|
app.use("/api/23/", require("./src/es/tunovelaligera/Tunovelaligera"));
|
||||||
|
|
||||||
const PORT = process.env.PORT || 5000;
|
const PORT = process.env.PORT || 5000;
|
||||||
|
|
||||||
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
|
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
|
||||||
|
|||||||
@@ -197,6 +197,15 @@ extensions = [
|
|||||||
sourceLanguage: "English",
|
sourceLanguage: "English",
|
||||||
status: 1,
|
status: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
sourceId: 23,
|
||||||
|
sourceUrl: "https://tunovelaligera.com/",
|
||||||
|
sourceName: "Tunovelaligera",
|
||||||
|
sourceCover:
|
||||||
|
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/tunovelaligera/icon.png?raw=true",
|
||||||
|
sourceLanguage: "Spanish",
|
||||||
|
status: 1,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = extensions;
|
module.exports = extensions;
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
const express = require("express");
|
||||||
|
const tunovelaligeraScraper = require("./TunovelaligeraScraper");
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.get("/novels/", tunovelaligeraScraper.novelsScraper);
|
||||||
|
|
||||||
|
router.get("/novel/:novelUrl", tunovelaligeraScraper.novelScraper);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
"/novel/:novelUrl/:chapterUrl",
|
||||||
|
tunovelaligeraScraper.chapterScraper
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get("/search/", tunovelaligeraScraper.searchScraper);
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
@@ -0,0 +1,231 @@
|
|||||||
|
const cheerio = require("cheerio");
|
||||||
|
const fetch = require("node-fetch");
|
||||||
|
const { htmlToText } = require("html-to-text");
|
||||||
|
const { parseHtml } = require("../../helper");
|
||||||
|
const FormData = require("form-data");
|
||||||
|
|
||||||
|
const baseUrl = "https://tunovelaligera.com/";
|
||||||
|
|
||||||
|
const novelsScraper = async (req, res) => {
|
||||||
|
let url = baseUrl + "mejores-novelas-originales/";
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novels = [];
|
||||||
|
|
||||||
|
$(".page-item-detail").each(function (result) {
|
||||||
|
const novelName = $(this).find(".h5 > a").text();
|
||||||
|
const novelCover = $(this).find("img").attr("src");
|
||||||
|
|
||||||
|
let novelUrl = $(this).find(".h5 > a").attr("href").split("/")[4];
|
||||||
|
novelUrl += "/";
|
||||||
|
|
||||||
|
const novel = {
|
||||||
|
extensionId: 23,
|
||||||
|
novelName,
|
||||||
|
novelCover,
|
||||||
|
novelUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
novels.push(novel);
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(novels);
|
||||||
|
};
|
||||||
|
|
||||||
|
const novelScraper = async (req, res) => {
|
||||||
|
const novelUrl = req.params.novelUrl;
|
||||||
|
const url = `${baseUrl}novelas/${novelUrl}/`;
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novel = {};
|
||||||
|
|
||||||
|
novel.extensionId = 23;
|
||||||
|
|
||||||
|
novel.sourceName = "Tunovelaligera";
|
||||||
|
|
||||||
|
novel.sourceUrl = url;
|
||||||
|
|
||||||
|
novel.novelUrl = novelUrl + "/";
|
||||||
|
|
||||||
|
novel.novelName = $("h1.titulo-novela")
|
||||||
|
.text()
|
||||||
|
.replace(/[\t\n]/g, "")
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
novel.novelCover = $(".summary_image > a > img").attr("src");
|
||||||
|
|
||||||
|
$(".post-content_item").each(function (result) {
|
||||||
|
detailName = $(this)
|
||||||
|
.find(".summary-heading > h5")
|
||||||
|
.text()
|
||||||
|
.replace(/[\t\n]/g, "")
|
||||||
|
.trim();
|
||||||
|
detail = $(this)
|
||||||
|
.find(".summary-content")
|
||||||
|
.text()
|
||||||
|
.replace(/[\t\n]/g, "")
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
novel[detailName] = detail;
|
||||||
|
});
|
||||||
|
|
||||||
|
novel["Genre(s)"] = novel.Generos.replace(/, /g, ",");
|
||||||
|
novel["Author(s)"] = novel.Autores;
|
||||||
|
novel.Status = novel.Estado;
|
||||||
|
novel.Status = null;
|
||||||
|
|
||||||
|
novel["Artist(s)"] = novel["Artista(s)"];
|
||||||
|
|
||||||
|
delete novel.Genre;
|
||||||
|
delete novel["Artista(s)"];
|
||||||
|
delete novel.Autores;
|
||||||
|
delete novel.Estado;
|
||||||
|
|
||||||
|
let novelSummary = "";
|
||||||
|
|
||||||
|
$(".summary__content")
|
||||||
|
.find("p")
|
||||||
|
.each(function () {
|
||||||
|
novelSummary += $(this).html();
|
||||||
|
});
|
||||||
|
|
||||||
|
novel.novelSummary = htmlToText(novelSummary);
|
||||||
|
|
||||||
|
let novelChapters = [];
|
||||||
|
|
||||||
|
const novelId = $(".wp-manga-action-button").attr("data-post");
|
||||||
|
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append("action", "manga_get_chapters");
|
||||||
|
formData.append("manga", novelId);
|
||||||
|
|
||||||
|
const data = await fetch(
|
||||||
|
"https://tunovelaligera.com/wp-admin/admin-ajax.php",
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const text = await data.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(text);
|
||||||
|
|
||||||
|
$(".wp-manga-chapter").each(function (result) {
|
||||||
|
chapterName = $(this)
|
||||||
|
.find("a")
|
||||||
|
.text()
|
||||||
|
.replace(/[\t\n]/g, "")
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
releaseDate = $(this).find("span").text().trim();
|
||||||
|
|
||||||
|
chapterUrl = $(this).find("a").attr("href").split("/");
|
||||||
|
|
||||||
|
chapterUrl[6]
|
||||||
|
? (chapterUrl = chapterUrl[5] + "/" + chapterUrl[6])
|
||||||
|
: (chapterUrl = chapterUrl[5]);
|
||||||
|
|
||||||
|
novelChapters.push({ chapterName, releaseDate, chapterUrl });
|
||||||
|
});
|
||||||
|
|
||||||
|
novel.novelChapters = novelChapters.reverse();
|
||||||
|
|
||||||
|
res.json(novel);
|
||||||
|
};
|
||||||
|
|
||||||
|
const chapterScraper = async (req, res) => {
|
||||||
|
let novelUrl = req.params.novelUrl;
|
||||||
|
let chapterUrl = req.params.chapterUrl;
|
||||||
|
|
||||||
|
const url = `${baseUrl}novelas/${novelUrl}/${chapterUrl}`;
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let chapterName = $("h1#chapter-heading").text();
|
||||||
|
|
||||||
|
let chapterText = $(".text-left").html();
|
||||||
|
chapterText = parseHtml(chapterText);
|
||||||
|
|
||||||
|
let nextChapter = null;
|
||||||
|
|
||||||
|
if ($(".nav-next").length) {
|
||||||
|
nextChapter = $(".nav-next")
|
||||||
|
.find("a")
|
||||||
|
.attr("href")
|
||||||
|
.replace(baseUrl + "novelas/" + novelUrl + "/", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
let prevChapter = null;
|
||||||
|
|
||||||
|
if ($(".nav-previous").length) {
|
||||||
|
prevChapter = $(".nav-previous")
|
||||||
|
.find("a")
|
||||||
|
.attr("href")
|
||||||
|
.replace(baseUrl + "novelas/" + novelUrl + "/", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
novelUrl = novelUrl + "/";
|
||||||
|
chapterUrl = chapterUrl + "/";
|
||||||
|
|
||||||
|
const chapter = {
|
||||||
|
extensionId: 23,
|
||||||
|
novelUrl,
|
||||||
|
chapterUrl,
|
||||||
|
chapterName,
|
||||||
|
chapterText,
|
||||||
|
nextChapter,
|
||||||
|
prevChapter,
|
||||||
|
};
|
||||||
|
|
||||||
|
res.json(chapter);
|
||||||
|
};
|
||||||
|
|
||||||
|
const searchScraper = async (req, res) => {
|
||||||
|
const searchTerm = req.query.s;
|
||||||
|
|
||||||
|
const url = `${baseUrl}?s=${searchTerm}&post_type=wp-manga`;
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novels = [];
|
||||||
|
|
||||||
|
$(".c-tabs-item__content").each(function (result) {
|
||||||
|
const novelName = $(this).find(".h4 > a").text();
|
||||||
|
const novelCover = $(this).find("img").attr("src");
|
||||||
|
|
||||||
|
let novelUrl = $(this).find(".h4 > a").attr("href");
|
||||||
|
novelUrl = novelUrl.replace(`${baseUrl}novelas/`, "");
|
||||||
|
|
||||||
|
const novel = {
|
||||||
|
extensionId: 23,
|
||||||
|
novelName,
|
||||||
|
novelCover,
|
||||||
|
novelUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
novels.push(novel);
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(novels);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = tunovelaligeraScraper = {
|
||||||
|
novelsScraper,
|
||||||
|
novelScraper,
|
||||||
|
chapterScraper,
|
||||||
|
searchScraper,
|
||||||
|
};
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 75 KiB |
Reference in New Issue
Block a user