Add Wuxia.City (Closes #39)
This commit is contained in:
@@ -42,6 +42,8 @@ Sources for [LNReader](https://github.com/rajarsheechatterjee/lnreader)
|
||||
| https://freenovel.me/ | :heavy_check_mark: |
|
||||
| https://1stkissnovel.love/ | :heavy_check_mark: |
|
||||
| https://daonovel.com/ | :heavy_check_mark: |
|
||||
| https://www.wuxia.blog/ | :heavy_check_mark: |
|
||||
| https://wuxia.city/ | :heavy_check_mark: |
|
||||
| https://syosetu.com | :heavy_check_mark: |
|
||||
| https://tunovelaligera.com/ | :heavy_check_mark: |
|
||||
| https://www.skynovels.net/ | :heavy_check_mark: |
|
||||
|
||||
@@ -47,6 +47,7 @@ app.use("/api/34/", require("./src/en/royalroad/RoyalRoad"));
|
||||
app.use("/api/35/", require("./src/en/scribblehub/ScribbleHub"));
|
||||
app.use("/api/37/", require("./src/en/lnmtl/LNMTL"));
|
||||
app.use("/api/48/", require("./src/en/wuxiablog/WuxiaBlog"));
|
||||
app.use("/api/49/", require("./src/en/wuxiacity/WuxiaCity"));
|
||||
|
||||
// Spanish
|
||||
app.use("/api/23/", require("./src/es/tunovelaligera/Tunovelaligera"));
|
||||
|
||||
+18
@@ -336,6 +336,24 @@ extensions = [
|
||||
sourceLanguage: "English",
|
||||
status: 1,
|
||||
},
|
||||
{
|
||||
sourceId: 48,
|
||||
sourceUrl: "https://www.wuxia.blog/",
|
||||
sourceName: "Wuxia.Blog",
|
||||
sourceCover:
|
||||
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/daonovel.png?raw=true",
|
||||
sourceLanguage: "English",
|
||||
status: 1,
|
||||
},
|
||||
{
|
||||
sourceId: 49,
|
||||
sourceUrl: "https://wuxia.city/",
|
||||
sourceName: "Wuxia.City",
|
||||
sourceCover:
|
||||
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/daonovel.png?raw=true",
|
||||
sourceLanguage: "English",
|
||||
status: 1,
|
||||
},
|
||||
|
||||
/**
|
||||
* Spanish
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
const express = require("express");
|
||||
const wuxiaCityScraper = require("./WuxiaCityScraper");
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get("/novels/", wuxiaCityScraper.novelsScraper);
|
||||
|
||||
router.get("/novel/:novelUrl", wuxiaCityScraper.novelScraper);
|
||||
|
||||
router.get("/novel/:novelUrl/:chapterUrl", wuxiaCityScraper.chapterScraper);
|
||||
|
||||
router.get("/search/", wuxiaCityScraper.searchScraper);
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,181 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const extensionId = 49;
|
||||
|
||||
const sourceName = "wuxia.city";
|
||||
|
||||
const baseUrl = "https://wuxia.city/";
|
||||
|
||||
const novelsScraper = async (req, res) => {
|
||||
let url = `${baseUrl}genre/all`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$(".section-item.card").each(function () {
|
||||
const novelName = $(this).find(".book-name").text();
|
||||
const novelCover = $(this).find("img").attr("src");
|
||||
const novelUrl = $(this).find("a").attr("href").replace("/book/", "");
|
||||
|
||||
const novel = {
|
||||
extensionId,
|
||||
novelName,
|
||||
novelCover,
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
res.json(novels);
|
||||
};
|
||||
|
||||
const novelScraper = async (req, res) => {
|
||||
const novelUrl = req.params.novelUrl;
|
||||
|
||||
const url = `${baseUrl}book/${novelUrl}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
let $ = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
extensionId,
|
||||
sourceName,
|
||||
sourceUrl: url,
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novel.novelName = $("h1.book-name").text();
|
||||
|
||||
novel.novelCover = $("div.book-img > img").attr("src");
|
||||
|
||||
novel["Author(s)"] = $("dl.author > dd").text();
|
||||
|
||||
novel["Genre(s)"] = $(".book-generes").text().trim();
|
||||
|
||||
novel.novelSummary = $(".book-synopsis")
|
||||
.text()
|
||||
.replace("Synopsis", "")
|
||||
.trim();
|
||||
|
||||
const chapterListUrl = `${baseUrl}book/${novelUrl}/chapter-list`;
|
||||
|
||||
const chaptersHtml = await fetch(chapterListUrl);
|
||||
const chapterHtmlToString = await chaptersHtml.text();
|
||||
|
||||
$ = cheerio.load(chapterHtmlToString);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$("ul.chapters > li").each(function () {
|
||||
const chapterName = $(this)
|
||||
.find(".chapter-name")
|
||||
.text()
|
||||
.trim()
|
||||
.replace(/\n/, " ");
|
||||
|
||||
let releaseDate = new Date();
|
||||
|
||||
let timeAgo = $(this).find(".chapter-time").text().match(/\d+/)[0];
|
||||
|
||||
if (timeAgo.includes("months ago")) {
|
||||
releaseDate.setMonth(releaseDate.getMonth() - timeAgo);
|
||||
}
|
||||
|
||||
if (timeAgo.includes("days ago")) {
|
||||
releaseDate.setDate(releaseDate.getDate() - timeAgo);
|
||||
}
|
||||
|
||||
const chapterUrl = $(this).find("a").attr("href").split("/").pop();
|
||||
|
||||
const chapter = {
|
||||
chapterName,
|
||||
releaseDate,
|
||||
chapterUrl,
|
||||
};
|
||||
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
|
||||
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}book/${novelUrl}/${chapterUrl}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
|
||||
let chapterName = $(".chapter-name").text();
|
||||
|
||||
let chapterText = $(".chapter-content").html();
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
let prevChapter = null;
|
||||
|
||||
const chapter = {
|
||||
extensionId,
|
||||
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 = [];
|
||||
|
||||
$(".section-item").each(function () {
|
||||
const novelName = $(this).find(".book-name").text().trim();
|
||||
const novelCover = $(this).find("img").attr("src");
|
||||
|
||||
let novelUrl = $(this).find("a").attr("href").replace("/book/", "");
|
||||
|
||||
const novel = {
|
||||
extensionId,
|
||||
novelName,
|
||||
novelCover,
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
res.json(novels);
|
||||
};
|
||||
|
||||
module.exports = wuxiCityScraper = {
|
||||
novelsScraper,
|
||||
novelScraper,
|
||||
chapterScraper,
|
||||
searchScraper,
|
||||
};
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
Reference in New Issue
Block a user