diff --git a/README.md b/README.md index 41c813c..7a85e42 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Sources for [LNReader](https://github.com/rajarsheechatterjee/lnreader) | https://www.skynovels.net/ | :heavy_check_mark: | | https://einherjarproject.net/ | :heavy_check_mark: | | https://novelasligera.com/ | :heavy_check_mark: | +| https://yuukitls.com/ | :heavy_check_mark: | ## Setup locally diff --git a/index.js b/index.js index 719f1ee..751c0a0 100644 --- a/index.js +++ b/index.js @@ -48,6 +48,7 @@ app.use("/api/23/", require("./src/es/tunovelaligera/Tunovelaligera")); app.use("/api/24/", require("./src/es/skynovels/Skynovels")); app.use("/api/25/", require("./src/es/einherjarproject/EinherjarProject")); app.use("/api/26/", require("./src/es/novelasligera/NovelasLigera")); +app.use("/api/28/", require("./src/es/yukitls/YuukiTls")); const PORT = process.env.PORT || 5000; diff --git a/sources.js b/sources.js index 85c7ca3..899ab47 100644 --- a/sources.js +++ b/sources.js @@ -251,6 +251,15 @@ extensions = [ sourceLanguage: "Spanish", status: 1, }, + { + sourceId: 28, + sourceUrl: "https://yuukitls.com/", + sourceName: "YuukiTls", + sourceCover: + "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/yuukitls/icon.png?raw=true", + sourceLanguage: "Spanish", + status: 1, + }, ]; module.exports = extensions; diff --git a/src/es/yukitls/YuukiTls.js b/src/es/yukitls/YuukiTls.js new file mode 100644 index 0000000..c70745b --- /dev/null +++ b/src/es/yukitls/YuukiTls.js @@ -0,0 +1,14 @@ +const express = require("express"); +const YuukiTlsScraper = require("./YuukiTlsScraper"); + +const router = express.Router(); + +router.get("/novels/", YuukiTlsScraper.novelsScraper); + +router.get("/novel/:novelUrl", YuukiTlsScraper.novelScraper); + +router.get("/novel/:novelUrl/:chapterUrl", YuukiTlsScraper.chapterScraper); + +router.get("/search/", YuukiTlsScraper.searchScraper); + +module.exports = router; diff --git a/src/es/yukitls/YuukiTlsScraper.js b/src/es/yukitls/YuukiTlsScraper.js new file mode 100644 index 0000000..05dfc00 --- /dev/null +++ b/src/es/yukitls/YuukiTlsScraper.js @@ -0,0 +1,199 @@ +const cheerio = require("cheerio"); +const fetch = require("node-fetch"); +const { htmlToText } = require("html-to-text"); +const { parseHtml } = require("../../helper"); + +const baseUrl = "https://yuukitls.com/"; + +const novelsScraper = async (req, res) => { + let url = baseUrl; + + const result = await fetch(url); + const body = await result.text(); + + $ = cheerio.load(body); + + let novels = []; + + $(".menu-item-2869") + .find(".menu-item.menu-item-type-post_type.menu-item-object-post") + .each(function (result) { + const novelName = $(this).text(); + const novelCover = $(this).find("img").attr("src"); + + let novelUrl = $(this).find("a").attr("href"); + novelUrl = novelUrl.split("/"); + novelUrl = novelUrl[novelUrl.length - 2] + "/"; + + const novel = { + extensionId: 28, + novelName, + novelCover, + novelUrl, + }; + + novels.push(novel); + }); + + res.json(novels); +}; + +const novelScraper = async (req, res) => { + const novelUrl = req.params.novelUrl; + const url = `${baseUrl}${novelUrl}/`; + + const result = await fetch(url); + const body = await result.text(); + + $ = cheerio.load(body); + + let novel = {}; + + novel.extensionId = 28; + + novel.sourceName = "YuukiTls"; + + novel.sourceUrl = url; + + novel.novelUrl = novelUrl + "/"; + + novel.novelName = $("h1.entry-title") + .text() + .replace(/[\t\n]/g, "") + .trim(); + + novel.novelCover = $(".entry-content > div > img").attr("src"); + + $(".entry-content") + .find("div") + .each(function (result) { + if ($(this).text().includes("Escritor:")) { + novel["Author(s)"] = $(this) + .text() + .replace("Escritor: ", "") + .trim(); + } + if ($(this).text().includes("Ilustrador:")) { + novel["Artist(s)"] = $(this) + .text() + .replace("Ilustrador: ", "") + .trim(); + } + + if ($(this).text().includes("Género:")) { + novel["Genre(s)"] = $(this) + .text() + .replace(/Género: |\s/g, ""); + } + + if ($(this).text().includes("Sinopsis:")) { + novel.novelSummary = $(this).next().text(); + } + }); + + let novelChapters = []; + + $(".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; + + chapterUrl = chapterUrl.split("/"); + chapterUrl = chapterUrl[chapterUrl.length - 2] + "/"; + + 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 chapterUrl = req.params.chapterUrl; + + const url = `${baseUrl}/${novelUrl}/${chapterUrl}`; + + const result = await fetch(url); + const body = await result.text(); + + $ = cheerio.load(body); + + let chapterName = $("h3").text(); + + let chapterText = $(".entry-content").html(); + chapterText = parseHtml(chapterText); + + let nextChapter = null; + let prevChapter = null; + + novelUrl = novelUrl + "/"; + chapterUrl = chapterUrl + "/"; + + const chapter = { + extensionId: 28, + novelUrl, + chapterUrl, + chapterName, + chapterText, + nextChapter, + prevChapter, + }; + + res.json(chapter); +}; + +const searchScraper = async (req, res) => { + let searchTerm = req.query.s; + searchTerm = searchTerm.toLowerCase(); + + let url = baseUrl; + + const result = await fetch(url); + const body = await result.text(); + + $ = cheerio.load(body); + + let novels = []; + + $(".menu-item-2869") + .find(".menu-item.menu-item-type-post_type.menu-item-object-post") + .each(function (result) { + const novelName = $(this).text(); + const novelCover = $(this).find("img").attr("src"); + + let novelUrl = $(this).find("a").attr("href"); + novelUrl = novelUrl.split("/"); + novelUrl = novelUrl[novelUrl.length - 2] + "/"; + + const novel = { + extensionId: 28, + novelName, + novelCover, + novelUrl, + }; + + novels.push(novel); + }); + + novels = novels.filter((novel) => + novel.novelName.toLowerCase().includes(searchTerm) + ); + + res.json(novels); +}; + +module.exports = vipNovelScraper = { + novelsScraper, + novelScraper, + chapterScraper, + searchScraper, +}; diff --git a/src/es/yukitls/icon.png b/src/es/yukitls/icon.png new file mode 100644 index 0000000..301be42 Binary files /dev/null and b/src/es/yukitls/icon.png differ