diff --git a/README.md b/README.md index 84ccadf..b6bf366 100644 --- a/README.md +++ b/README.md @@ -4,36 +4,37 @@ Sources for [LNReader](https://github.com/rajarsheechatterjee/lnreader) ## Sources -| Source | Status | -| ----------------------------- | :----------------: | -| BoxNovel | :heavy_check_mark: | -| ReadLightNovel | :heavy_check_mark: | -| FastNovel | :x: | -| ReadNovelFull | :heavy_check_mark: | -| MTLNovel | :heavy_check_mark: | -| NovelHall | :heavy_check_mark: | -| WuxiaWorld | :heavy_check_mark: | -| NovelFull | :heavy_check_mark: | -| NovelTrench | :heavy_check_mark: | -| VipNovel | :heavy_check_mark: | -| KissLightNovels | :heavy_check_mark: | -| https://wuxiaworldsite.co/ | :heavy_check_mark: | -| FreeWebNovel | :heavy_check_mark: | -| JPMTL | :heavy_check_mark: | -| LightNovelPub | :heavy_check_mark: | -| https://www.wuxiaworld.co/ | :heavy_check_mark: | -| TapRead | :heavy_check_mark: | -| https://www.novelupdates.cc/ | :heavy_check_mark: | -| https://m.readlightnovel.cc/ | :heavy_check_mark: | -| http://wuxiaworld.cloud/ | :heavy_check_mark: | -| https://foxaholic.com/ | :heavy_check_mark: | -| https://comrademao.com/ | :heavy_check_mark: | -| https://tunovelaligera.com/ | :heavy_check_mark: | -| 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: | -| https://hasutl.wordpress.com/ | :heavy_check_mark: | +| Source | Status | +| ---------------------------------------- | :----------------: | +| BoxNovel | :heavy_check_mark: | +| ReadLightNovel | :heavy_check_mark: | +| FastNovel | :x: | +| ReadNovelFull | :heavy_check_mark: | +| MTLNovel | :heavy_check_mark: | +| NovelHall | :heavy_check_mark: | +| WuxiaWorld | :heavy_check_mark: | +| NovelFull | :heavy_check_mark: | +| NovelTrench | :heavy_check_mark: | +| VipNovel | :heavy_check_mark: | +| KissLightNovels | :heavy_check_mark: | +| https://wuxiaworldsite.co/ | :heavy_check_mark: | +| FreeWebNovel | :heavy_check_mark: | +| JPMTL | :heavy_check_mark: | +| LightNovelPub | :heavy_check_mark: | +| https://www.wuxiaworld.co/ | :heavy_check_mark: | +| TapRead | :heavy_check_mark: | +| https://www.novelupdates.cc/ | :heavy_check_mark: | +| https://m.readlightnovel.cc/ | :heavy_check_mark: | +| http://wuxiaworld.cloud/ | :heavy_check_mark: | +| https://foxaholic.com/ | :heavy_check_mark: | +| https://comrademao.com/ | :heavy_check_mark: | +| https://tunovelaligera.com/ | :heavy_check_mark: | +| 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: | +| https://hasutl.wordpress.com/ | :heavy_check_mark: | +| https://oasistranslations.wordpress.com/ | :heavy_check_mark: | ## Setup locally diff --git a/index.js b/index.js index 2f86b32..96f433c 100644 --- a/index.js +++ b/index.js @@ -50,6 +50,7 @@ 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/yuukitls/YuukiTls")); app.use("/api/29/", require("./src/es/hasutl/Hasutl")); +app.use("/api/30/", require("./src/es/oasistranslations/OasisTranslations")); const PORT = process.env.PORT || 5000; diff --git a/sources.js b/sources.js index 69e8671..e5339c5 100644 --- a/sources.js +++ b/sources.js @@ -269,6 +269,15 @@ extensions = [ sourceLanguage: "Spanish", status: 1, }, + { + sourceId: 30, + sourceUrl: "https://oasistranslations.wordpress.com/", + sourceName: "Oasis Translations", + sourceCover: + "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/oasistranslations/icon.png?raw=true", + sourceLanguage: "Spanish", + status: 1, + }, ]; module.exports = extensions; diff --git a/src/es/oasistranslations/OasisTranslations.js b/src/es/oasistranslations/OasisTranslations.js new file mode 100644 index 0000000..a4568a4 --- /dev/null +++ b/src/es/oasistranslations/OasisTranslations.js @@ -0,0 +1,17 @@ +const express = require("express"); +const OasisTranslationsScraper = require("./OasisTranslationsScraper"); + +const router = express.Router(); + +router.get("/novels/", OasisTranslationsScraper.novelsScraper); + +router.get("/novel/:novelUrl", OasisTranslationsScraper.novelScraper); + +router.get( + "/novel/:novelUrl/:chapterUrl", + OasisTranslationsScraper.chapterScraper +); + +router.get("/search/", OasisTranslationsScraper.searchScraper); + +module.exports = router; diff --git a/src/es/oasistranslations/OasisTranslationsScraper.js b/src/es/oasistranslations/OasisTranslationsScraper.js new file mode 100644 index 0000000..b96c6e0 --- /dev/null +++ b/src/es/oasistranslations/OasisTranslationsScraper.js @@ -0,0 +1,213 @@ +const cheerio = require("cheerio"); +const fetch = require("node-fetch"); +const { htmlToText } = require("html-to-text"); +const { parseHtml } = require("../../helper"); + +const baseUrl = "https://oasistranslations.wordpress.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-1819") + .find(".sub-menu > li") + .each(function (result) { + const novelName = $(this).text(); + if (!novelName.match(/Activas|Finalizadas|Dropeadas/)) { + 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: 30, + 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 = 30; + + novel.sourceName = "Oasis Translations"; + + novel.sourceUrl = url; + + novel.novelUrl = novelUrl + "/"; + + novel.novelName = $("h1.entry-title") + .text() + .replace(/[\t\n]/g, "") + .trim(); + + novel.novelCover = $('img[loading="lazy"]').attr("src"); + + let details = $(".entry-content").find("h2").next().html(); + + details = details.match(/<\/strong>(.|\n)*?
/g); + details = details.map((detail) => + detail.replace(/|<\/strong>|
|:\s/g, "") + ); + + novel["Genre(s)"] = ""; + + novel["Author(s)"] = details[2]; + novel["Genre(s)"] = details[4].replace(/\s/g, ""); + novel["Artist(s)"] = details[3]; + + let novelSummary = $(".entry-content").find("h2").next().next().html(); + novel.novelSummary = htmlToText(novelSummary); + + let novelChapters = []; + + // if ($(".entry-content").find("li").length) { + $(".entry-content") + .find("a") + .each(function (result) { + let chapterUrl = $(this).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); + } + }); + // } 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; + + 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 = $("h1.entry-title").text(); + + $("div#jp-post-flair").remove(); + + let chapterText = $(".entry-content").html(); + chapterText = parseHtml(chapterText); + + let nextChapter = null; + let prevChapter = null; + + novelUrl = novelUrl + "/"; + chapterUrl = chapterUrl + "/"; + + const chapter = { + extensionId: 30, + 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-1819") + .find(".sub-menu > li") + .each(function (result) { + const novelName = $(this).text(); + if (!novelName.match(/Activas|Finalizadas|Dropeadas/)) { + 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: 30, + 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/oasistranslations/icon.png b/src/es/oasistranslations/icon.png new file mode 100644 index 0000000..b529d0d Binary files /dev/null and b/src/es/oasistranslations/icon.png differ