diff --git a/README.md b/README.md index 6a81991..75b1b2d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Sources for [LNReader](https://github.com/rajarsheechatterjee/lnreader) | ---------------------------------------- | :----------------: | | BoxNovel | :heavy_check_mark: | | ReadLightNovel | :heavy_check_mark: | -| FastNovel | :x: | +| FastNovel | :heavy_check_mark: | | ReadNovelFull | :heavy_check_mark: | | MTLNovel | :heavy_check_mark: | | NovelHall | :heavy_check_mark: | @@ -28,6 +28,7 @@ Sources for [LNReader](https://github.com/rajarsheechatterjee/lnreader) | http://wuxiaworld.cloud/ | :heavy_check_mark: | | https://foxaholic.com/ | :heavy_check_mark: | | https://comrademao.com/ | :heavy_check_mark: | +| https://www.novelpassion.com/ | :heavy_check_mark: | | https://tunovelaligera.com/ | :heavy_check_mark: | | https://www.skynovels.net/ | :heavy_check_mark: | | https://einherjarproject.net/ | :heavy_check_mark: | diff --git a/index.js b/index.js index 07a9815..57bb964 100644 --- a/index.js +++ b/index.js @@ -52,6 +52,7 @@ 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")); app.use("/api/31/", require("./src/es/novelawuxia/NovelaWuxia")); +app.use("/api/33/", require("./src/en/novelpassion/NovelPassion")); const PORT = process.env.PORT || 5000; diff --git a/sources.js b/sources.js index 62a2cc1..bdcbfbc 100644 --- a/sources.js +++ b/sources.js @@ -210,6 +210,15 @@ extensions = [ sourceLanguage: "English", status: 1, }, + { + sourceId: 27, + sourceUrl: "https://www.novelpassion.com/", + sourceName: "NovelPassion", + sourceCover: + "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/novelpassion/icon.png?raw=true", + sourceLanguage: "English", + status: 1, + }, /** * Spanish diff --git a/src/en/novelpassion/NovelPassion.js b/src/en/novelpassion/NovelPassion.js new file mode 100644 index 0000000..9c9027c --- /dev/null +++ b/src/en/novelpassion/NovelPassion.js @@ -0,0 +1,14 @@ +const express = require("express"); +const NovelPassionScraper = require("./NovelPassionScraper"); + +const router = express.Router(); + +router.get("/novels/", NovelPassionScraper.novelsScraper); + +router.get("/novel/:novelUrl", NovelPassionScraper.novelScraper); + +router.get("/novel/:novelUrl/:chapterUrl", NovelPassionScraper.chapterScraper); + +router.get("/search/", NovelPassionScraper.searchScraper); + +module.exports = router; diff --git a/src/en/novelpassion/NovelPassionScraper.js b/src/en/novelpassion/NovelPassionScraper.js new file mode 100644 index 0000000..103e946 --- /dev/null +++ b/src/en/novelpassion/NovelPassionScraper.js @@ -0,0 +1,186 @@ +const cheerio = require("cheerio"); +const fetch = require("node-fetch"); +const { htmlToText } = require("html-to-text"); +const { parseHtml } = require("../../helper"); + +const baseUrl = "https://www.novelpassion.com/"; + +const novelsScraper = async (req, res) => { + let url = baseUrl + "category/all?p=1&s=1&f=4"; + + const result = await fetch(url); + const body = await result.text(); + + $ = cheerio.load(body); + + let novels = []; + + $("div.j_bookList.lis-mn.ddc") + .find("li") + .each(function (result) { + const novelName = $(this).find("h3").text(); + const novelCover = + "https://www.novelpassion.com" + + $(this).find("img").attr("src"); + + let novelUrl = $(this).find("div.pr > a").attr("href"); + novelUrl = novelUrl.replace("/novel/", ""); + + const novel = { + extensionId: 33, + novelName, + novelCover, + novelUrl, + }; + + novels.push(novel); + }); + + res.json(novels); +}; + +const novelScraper = async (req, res) => { + const novelUrl = req.params.novelUrl; + const url = baseUrl + "novel/" + novelUrl; + + const result = await fetch(url); + const body = await result.text(); + + $ = cheerio.load(body); + + let novel = {}; + + novel.extensionId = 33; + + novel.sourceName = "NovelPassion"; + + novel.sourceUrl = url; + + novel.novelUrl = novelUrl; + + novelName = $("h2.mh").text(); + novel.novelName = novelName; + + novel.novelCover = $("#thumbnail > img").attr("src"); + + let novelSummary = $("div.j_synopsis").html(); + novel.novelSummary = htmlToText(novelSummary); + + $("address.lh20.m14.pr").each(function (result) { + detailName = $(this).find("p.ell.dib.vam").text().trim(); + + detail = $(this).find("div.dns").text().trim(); + + switch (detailName) { + case "Categories:": + novel["Genre(s)"] = detail.trim().replace(/ - /g, ","); + break; + case "Author:": + novel["Author(s)"] = detail.trim().replace(/ - /g, ", "); + break; + case "Status:": + novel.Status = detail.trim(); + break; + } + }); + + let novelChapters = []; + + $(".content-list") + .find("li") + .each(function (result) { + const chapterName = $(this).find("span.sp1").text(); + + const releaseDate = $(this).find("i.sp2").text(); + + const chapterUrl = $(this) + .find("a") + .attr("href") + .replace("/novel/" + novelUrl + "/", ""); + + novelChapters.push({ + chapterName, + releaseDate, + chapterUrl, + }); + }); + + novel.novelChapters = novelChapters; + + res.json(novel); +}; + +const chapterScraper = async (req, res) => { + let novelUrl = req.params.novelUrl; + let chapterUrl = req.params.chapterUrl; + + const url = `${baseUrl}novel/${novelUrl}/${chapterUrl}`; + + const result = await fetch(url); + const body = await result.text(); + + $ = cheerio.load(body); + + let chapterName = $("div.cha-content").find("strong").text(); + + let chapterText = $("div.cha-content").html(); + chapterText = parseHtml(chapterText); + + let nextChapter = null; + let prevChapter = null; + + const chapter = { + extensionId: 33, + novelUrl, + chapterUrl, + chapterName, + chapterText, + nextChapter, + prevChapter, + }; + + res.json(chapter); +}; + +const searchScraper = async (req, res) => { + const searchTerm = req.query.s; + + const url = baseUrl + "search?keyword=" + searchTerm; + + const result = await fetch(url); + const body = await result.text(); + + $ = cheerio.load(body); + + let novels = []; + + $("div.j_bookList.lis-mn.ddc") + .find("li") + .each(function (result) { + const novelName = $(this).find("h3").text(); + const novelCover = + "https://www.novelpassion.com" + + $(this).find("img").attr("src"); + + let novelUrl = $(this).find("div.pr > a").attr("href"); + novelUrl = novelUrl.replace("/novel/", ""); + + const novel = { + extensionId: 33, + novelName, + novelCover, + novelUrl, + }; + + novels.push(novel); + }); + + res.json(novels); +}; + +module.exports = vipNovelScraper = { + novelsScraper, + novelScraper, + chapterScraper, + searchScraper, +}; diff --git a/src/en/novelpassion/icon.png b/src/en/novelpassion/icon.png new file mode 100644 index 0000000..51b5028 Binary files /dev/null and b/src/en/novelpassion/icon.png differ