Almost english sources (#709)

* fix: LightNovelPub

* fix: novelpub -> lightnovelworld

* still broken, wuxiaworld keep html in js variables

* fix: NovelsOnline

* fix: novelhole -> novelhall

* fix: novelfull

* fix: mtl reader

* refactor: mtlnovel

* temporary fix: lightnovelupdates

* still cant work

* cant work

* cant parseNovel and chapters: Wuxiaworld
This commit is contained in:
nyagami
2024-01-21 21:21:35 +07:00
committed by GitHub
parent 5aecd7b282
commit 2830ae68dd
39 changed files with 4227 additions and 2020 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ var fetch_1 = require("@libs/fetch");
var NovelFull = /** @class */ (function () {
function NovelFull() {
this.id = "NF.me";
this.name = "NovelFull";
this.name = "NovelFullMe";
this.site = "https://novelfull.me/";
this.version = "1.0.0";
this.icon = "src/en/novelfullme/icon.png";
+161
View File
@@ -0,0 +1,161 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var NovelsOnline = /** @class */ (function () {
function NovelsOnline() {
this.id = "NO.net";
this.name = "novelsOnline";
this.site = "https://novelsonline.net";
this.icon = "src/coverNotAvailable.jpg";
this.version = "1.0.0";
}
NovelsOnline.prototype.popularNovels = function (pageNo, options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, []]; /** TO DO */
});
});
};
NovelsOnline.prototype.parseNovelAndChapters = function (novelUrl) {
return __awaiter(this, void 0, void 0, function () {
var novel, result, $;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
novel = {
url: novelUrl,
chapters: [],
};
return [4 /*yield*/, (0, fetch_1.fetchApi)(novelUrl).then(function (res) { return res.text(); })];
case 1:
result = _a.sent();
$ = (0, cheerio_1.load)(result);
novel.name = $("h1").text();
novel.cover = $(".novel-cover").find("a > img").attr("src");
novel.author = $("div.novel-details > div:nth-child(5) > div.novel-detail-body")
.find("li")
.map(function (_, el) { return $(el).text(); })
.get()
.join(", ");
novel.genres = $("div.novel-details > div:nth-child(2) > div.novel-detail-body")
.find("li")
.map(function (_, el) { return $(el).text(); })
.get()
.join(",");
novel.summary = $("div.novel-right > div > div:nth-child(1) > div.novel-detail-body").text();
novel.chapters = $("ul.chapter-chs > li > a")
.map(function (_, el) {
var chapterUrl = $(el).attr("href");
var chapterName = $(el).text();
return {
name: chapterName,
releaseTime: "",
url: chapterUrl,
};
})
.get();
return [2 /*return*/, novel];
}
});
});
};
NovelsOnline.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var result, loadedCheerio, chapterText;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterUrl).then(function (res) { return res.text(); })];
case 1:
result = _a.sent();
loadedCheerio = (0, cheerio_1.load)(result);
chapterText = loadedCheerio("#contentall").html() || "";
return [2 /*return*/, chapterText];
}
});
});
};
NovelsOnline.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var result, $, headers;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, fetch_1.fetchApi)("https://novelsonline.net/sResults.php", {
headers: {
Accept: "*/*",
"Accept-Language": "pl,en-US;q=0.7,en;q=0.3",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
},
method: "POST",
body: "q=" + encodeURIComponent(searchTerm),
}).then(function (res) { return res.text(); })];
case 1:
result = _a.sent();
$ = (0, cheerio_1.load)(result);
headers = $("li");
return [2 /*return*/, headers
.map(function (i, h) {
var novelName = $(h).text();
var novelUrl = $(h).find("a").attr("href");
var novelCover = $(h).find("img").attr("src");
if (!novelUrl) {
return null;
}
return {
name: novelName,
cover: novelCover,
url: novelUrl,
};
})
.get()
.filter(function (sr) { return sr !== null; })];
}
});
});
};
NovelsOnline.prototype.fetchImage = function (url) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, (0, fetch_1.fetchFile)(url)];
});
});
};
return NovelsOnline;
}());
exports.default = new NovelsOnline();
+219
View File
@@ -0,0 +1,219 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var LightNovelPub = /** @class */ (function () {
function LightNovelPub() {
this.id = "lightnovelpub";
this.name = "LightNovelPub";
this.version = "1.0.0";
this.icon = "src/en/lightnovelpub/icon.png";
this.site = "https://www.lightnovelpub.com/";
this.baseUrl = this.site;
this.headers = {
Accept: "application/json",
"Content-Type": "application/json",
};
}
LightNovelPub.prototype.popularNovels = function (pageNo, options) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novels;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "browse/all/popular/all/").concat(pageNo);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio(".novel-item.ads").remove();
loadedCheerio(".novel-item").each(function (idx, ele) {
var _a;
var novelName = loadedCheerio(ele)
.find(".novel-title")
.text()
.trim();
var novelCover = loadedCheerio(ele).find("img").attr("data-src");
var novelUrl = _this.baseUrl +
((_a = loadedCheerio(ele)
.find(".novel-title > a")
.attr("href")) === null || _a === void 0 ? void 0 : _a.substring(1));
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
LightNovelPub.prototype.parseNovelAndChapters = function (novelUrl) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novel, delay, chapterListUrl, chapterListBody, loadedChapterList, lastNumber, lastChapterUrl, chapterUrlPrefix, chapters, i;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
url = novelUrl;
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _b.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novel = {
url: url,
chapters: [],
};
novel.name = loadedCheerio("h1.novel-title").text().trim();
novel.cover = loadedCheerio("figure.cover > img").attr("data-src");
novel.genres = "";
loadedCheerio(".categories > ul > li > a").each(function () {
novel.genres += loadedCheerio(this).text() + ",";
});
novel.genres = novel.genres.slice(0, -1);
loadedCheerio("div.header-stats > span").each(function () {
if (loadedCheerio(this).find("small").text() === "Status") {
novel.status = loadedCheerio(this).find("strong").text();
}
});
novel.author = loadedCheerio(".author > a > span").text();
novel.summary = loadedCheerio(".summary > .content").text().trim();
delay = function (ms) { return new Promise(function (res) { return setTimeout(res, ms); }); };
return [4 /*yield*/, delay(1000)];
case 2:
_b.sent();
chapterListUrl = novelUrl + '/chapters?chorder=desc';
return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterListUrl).then(function (r) { return r.text(); })];
case 3:
chapterListBody = _b.sent();
loadedChapterList = (0, cheerio_1.load)(chapterListBody);
lastNumber = parseInt((_a = loadedChapterList('ul.chapter-list > li:nth-child(1)').attr('data-chapterno')) !== null && _a !== void 0 ? _a : '0');
lastChapterUrl = loadedChapterList('ul.chapter-list > li:nth-child(1) > a').attr('href');
if (lastChapterUrl) {
chapterUrlPrefix = this.baseUrl + lastChapterUrl.split('/').slice(1, -1).join('/');
chapters = [];
for (i = 1; i <= lastNumber; i++) {
chapters.push({
chapterNumber: i,
name: 'Chapter ' + i,
url: chapterUrlPrefix + '/chapter-' + i,
});
}
novel.chapters = chapters;
}
return [2 /*return*/, novel];
}
});
});
};
LightNovelPub.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var body, loadedCheerio, chapterText;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterUrl).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
chapterText = loadedCheerio("#chapter-container").html() || '';
return [2 /*return*/, chapterText];
}
});
});
};
LightNovelPub.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var url, link, response, token, verifytoken, formData, body, loadedCheerio, novels, results;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "lnsearchlive");
link = "".concat(this.baseUrl, "search");
return [4 /*yield*/, (0, fetch_1.fetchApi)(link).then(function (r) { return r.text(); })];
case 1:
response = _a.sent();
token = (0, cheerio_1.load)(response);
verifytoken = token("#novelSearchForm > input").attr("value");
formData = new FormData();
formData.append("inputContent", searchTerm);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url, {
method: "POST",
headers: { LNRequestVerifyToken: verifytoken },
body: formData,
}).then(function (r) { return r.text(); })];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
results = JSON.parse(loadedCheerio("body").text());
loadedCheerio = (0, cheerio_1.load)(results.resultview);
loadedCheerio(".novel-item").each(function (idx, ele) {
var _a;
var novelName = loadedCheerio(ele)
.find("h4.novel-title")
.text()
.trim();
var novelCover = loadedCheerio(ele).find("img").attr("src");
var novelUrl = _this.baseUrl + ((_a = loadedCheerio(ele).find("a").attr("href")) === null || _a === void 0 ? void 0 : _a.substring(1));
novels.push({
name: novelName,
url: novelUrl,
cover: novelCover,
});
});
return [2 /*return*/, novels];
}
});
});
};
LightNovelPub.prototype.fetchImage = function (url) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, (0, fetch_1.fetchFile)(url, { headers: this.headers })];
});
});
};
return LightNovelPub;
}());
exports.default = new LightNovelPub();
+200
View File
@@ -0,0 +1,200 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var LightNovelUpdates = /** @class */ (function () {
function LightNovelUpdates() {
this.id = "LightNovelUpdates";
this.name = "Light Novel Updates";
this.version = "1.0.0";
this.icon = "src/en/lightnovelupdates/icon.png";
this.site = "https://www.lightnovelupdates.com/";
this.baseUrl = this.site;
}
LightNovelUpdates.prototype.popularNovels = function (pageNo, options) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "novel/page/").concat(pageNo, "/?m_orderby=rating");
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio(".page-item-detail").each(function () {
var novelName = loadedCheerio(this).find(".h5 > a").text();
var novelCover = loadedCheerio(this).find("img").attr("src");
var novelUrl = loadedCheerio(this).find(".h5 > a").attr("href");
if (!novelUrl)
return;
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
LightNovelUpdates.prototype.parseNovelAndChapters = function (novelUrl) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novel, chapter, novelId, formData, data, text;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = novelUrl;
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novel = {
url: url,
chapters: [],
};
novel.name = loadedCheerio(".post-title > h1").text().trim();
novel.cover =
loadedCheerio(".summary_image > a > img").attr("src") || undefined;
loadedCheerio(".post-content_item").each(function () {
var detailName = loadedCheerio(this)
.find(".summary-heading > h5")
.text()
.trim();
var detail = loadedCheerio(this)
.find(".summary-content")
.text()
.trim();
switch (detailName) {
case "Genre(s)":
novel.genres = detail.trim().replace(/[\t\n]/g, ",");
break;
case "Author(s)":
novel.author = detail.trim();
break;
case "Status":
novel.status = detail.replace(/G/g, "g");
break;
}
});
novel.summary = loadedCheerio("div.summary__content").text();
chapter = [];
novelId = loadedCheerio(".rating-post-id").attr("value");
formData = new FormData();
formData.append("action", "manga_get_chapters");
formData.append("manga", novelId);
return [4 /*yield*/, (0, fetch_1.fetchApi)("https://www.lightnovelupdates.com/wp-admin/admin-ajax.php", {
method: "POST",
body: formData,
})];
case 2:
data = _a.sent();
return [4 /*yield*/, data.text()];
case 3:
text = _a.sent();
loadedCheerio = (0, cheerio_1.load)(text);
loadedCheerio(".wp-manga-chapter").each(function () {
var chapterName = loadedCheerio(this).find("a").text().trim();
var releaseDate = loadedCheerio(this).find("span").text().trim();
var chapterUrl = loadedCheerio(this).find("a").attr("href");
if (!chapterUrl)
return;
chapter.push({
name: chapterName,
releaseTime: releaseDate,
url: chapterUrl,
});
});
novel.chapters = chapter.reverse();
return [2 /*return*/, novel];
}
});
});
};
LightNovelUpdates.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var chapterText;
return __generator(this, function (_a) {
chapterText = 'unable to load';
return [2 /*return*/, chapterText];
});
});
};
LightNovelUpdates.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "?s=").concat(searchTerm, "&post_type=wp-manga&m_orderby=rating");
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio(".c-tabs-item__content").each(function () {
var novelName = loadedCheerio(this).find(".h4 > a").text();
var novelCover = loadedCheerio(this).find("img").attr("src");
var novelUrl = loadedCheerio(this).find(".h4 > a").attr("href");
if (!novelUrl)
return;
novels.push({
url: novelUrl,
name: novelName,
cover: novelCover,
});
});
return [2 /*return*/, novels];
}
});
});
};
LightNovelUpdates.prototype.fetchImage = function (url) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, (0, fetch_1.fetchFile)(url)];
});
});
};
return LightNovelUpdates;
}());
exports.default = new LightNovelUpdates();
+219
View File
@@ -0,0 +1,219 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var LightNovelWorld = /** @class */ (function () {
function LightNovelWorld() {
this.id = "lightnovelworld";
this.name = "LightNovelWorld";
this.site = "https://www.webnovelworld.org/";
this.version = "1.0.0";
this.icon = "src/en/lightnovelworld/icon.png";
this.baseUrl = this.site;
this.headers = {
Accept: "application/json",
"Content-Type": "application/json",
};
}
LightNovelWorld.prototype.popularNovels = function (pageNo, options) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novels;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "browse/all/popular/all/").concat(pageNo);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio(".novel-item.ads").remove();
loadedCheerio(".novel-item").each(function (idx, ele) {
var _a;
var novelName = loadedCheerio(ele)
.find(".novel-title")
.text()
.trim();
var novelCover = loadedCheerio(ele).find("img").attr("data-src");
var novelUrl = _this.baseUrl +
((_a = loadedCheerio(ele)
.find(".novel-title > a")
.attr("href")) === null || _a === void 0 ? void 0 : _a.substring(1));
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
LightNovelWorld.prototype.parseNovelAndChapters = function (novelUrl) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novel, delay, chapterListUrl, chapterListBody, loadedChapterList, lastNumber, lastChapterUrl, chapterUrlPrefix, chapters, i;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
url = novelUrl;
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _b.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novel = {
url: url,
chapters: [],
};
novel.name = loadedCheerio("h1.novel-title").text().trim();
novel.cover = loadedCheerio("figure.cover > img").attr("data-src");
novel.genres = "";
loadedCheerio(".categories > ul > li > a").each(function () {
novel.genres += loadedCheerio(this).text() + ",";
});
novel.genres = novel.genres.slice(0, -1);
loadedCheerio("div.header-stats > span").each(function () {
if (loadedCheerio(this).find("small").text() === "Status") {
novel.status = loadedCheerio(this).find("strong").text();
}
});
novel.author = loadedCheerio(".author > a > span").text();
novel.summary = loadedCheerio(".summary > .content").text().trim();
delay = function (ms) { return new Promise(function (res) { return setTimeout(res, ms); }); };
return [4 /*yield*/, delay(1000)];
case 2:
_b.sent();
chapterListUrl = novelUrl + '/chapters?chorder=desc';
return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterListUrl).then(function (r) { return r.text(); })];
case 3:
chapterListBody = _b.sent();
loadedChapterList = (0, cheerio_1.load)(chapterListBody);
lastNumber = parseInt((_a = loadedChapterList('ul.chapter-list > li:nth-child(1)').attr('data-chapterno')) !== null && _a !== void 0 ? _a : '0');
lastChapterUrl = loadedChapterList('ul.chapter-list > li:nth-child(1) > a').attr('href');
if (lastChapterUrl) {
chapterUrlPrefix = this.baseUrl + lastChapterUrl.split('/').slice(1, -1).join('/');
chapters = [];
for (i = 1; i <= lastNumber; i++) {
chapters.push({
chapterNumber: i,
name: 'Chapter ' + i,
url: chapterUrlPrefix + '/chapter-' + i,
});
}
novel.chapters = chapters;
}
return [2 /*return*/, novel];
}
});
});
};
LightNovelWorld.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var body, loadedCheerio, chapterText;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterUrl).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
chapterText = loadedCheerio("#chapter-container").html() || '';
return [2 /*return*/, chapterText];
}
});
});
};
LightNovelWorld.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var url, link, response, token, verifytoken, formData, body, loadedCheerio, novels, results;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "lnsearchlive");
link = "".concat(this.baseUrl, "search");
return [4 /*yield*/, (0, fetch_1.fetchApi)(link).then(function (r) { return r.text(); })];
case 1:
response = _a.sent();
token = (0, cheerio_1.load)(response);
verifytoken = token("#novelSearchForm > input").attr("value");
formData = new FormData();
formData.append("inputContent", searchTerm);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url, {
method: "POST",
headers: { LNRequestVerifyToken: verifytoken },
body: formData,
}).then(function (r) { return r.text(); })];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
results = JSON.parse(loadedCheerio("body").text());
loadedCheerio = (0, cheerio_1.load)(results.resultview);
loadedCheerio(".novel-item").each(function (idx, ele) {
var _a;
var novelName = loadedCheerio(ele)
.find("h4.novel-title")
.text()
.trim();
var novelCover = loadedCheerio(ele).find("img").attr("src");
var novelUrl = _this.baseUrl + ((_a = loadedCheerio(ele).find("a").attr("href")) === null || _a === void 0 ? void 0 : _a.substring(1));
novels.push({
name: novelName,
url: novelUrl,
cover: novelCover,
});
});
return [2 /*return*/, novels];
}
});
});
};
LightNovelWorld.prototype.fetchImage = function (url) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, (0, fetch_1.fetchFile)(url, { headers: this.headers })];
});
});
};
return LightNovelWorld;
}());
exports.default = new LightNovelWorld();
+208
View File
@@ -0,0 +1,208 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var MTLNovel = /** @class */ (function () {
function MTLNovel() {
this.id = "mtlnovel";
this.name = "MTL Novel";
this.version = "1.0.0";
this.icon = "src/en/mtlnovel/icon.png";
this.site = "https://www.mtlnovel.com/";
this.baseUrl = this.site;
}
MTLNovel.prototype.popularNovels = function (pageNo, options) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "alltime-rank/page/").concat(pageNo);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (result) { return result.text(); })];
case 1:
body = _a.sent();
console.log(body);
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio("div.box.wide").each(function () {
var novelName = loadedCheerio(this)
.find("a.list-title")
.text()
.slice(4);
var novelCover = loadedCheerio(this).find("amp-img").attr("src");
var novelUrl = loadedCheerio(this).find("a.list-title").attr("href");
if (!novelUrl)
return;
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
MTLNovel.prototype.parseNovelAndChapters = function (novelUrl) {
return __awaiter(this, void 0, void 0, function () {
function getChapters() {
return __awaiter(this, void 0, void 0, function () {
var listResult, listBody, chapter;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fetch(chapterListUrl)];
case 1:
listResult = _a.sent();
return [4 /*yield*/, listResult.text()];
case 2:
listBody = _a.sent();
loadedCheerio = (0, cheerio_1.load)(listBody);
chapter = [];
loadedCheerio("div.ch-list")
.find("a.ch-link")
.each(function () {
var chapterName = loadedCheerio(this)
.text()
.replace("~ ", "");
var releaseDate = null;
var chapterUrl = loadedCheerio(this).attr("href");
if (chapterUrl) {
chapter.push({
url: chapterUrl,
name: chapterName,
releaseTime: releaseDate,
});
}
});
return [2 /*return*/, chapter.reverse()];
}
});
});
}
var url, headers, body, loadedCheerio, novel, chapterListUrl, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
url = novelUrl;
headers = {
Referer: "".concat(this.baseUrl, "alltime-rank/"),
};
return [4 /*yield*/, (0, fetch_1.fetchApi)(url, {
method: "GET",
headers: headers,
}).then(function (result) { return result.text(); })];
case 1:
body = _b.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novel = {
url: url,
chapters: [],
};
novel.name = loadedCheerio("h1.entry-title").text();
novel.cover = loadedCheerio(".nov-head > amp-img").attr("src");
novel.summary = loadedCheerio("div.desc > h2").next().text().trim();
novel.author = loadedCheerio("#author").text();
novel.status = loadedCheerio("#status").text();
novel.genres = loadedCheerio("#genre").text().replace(/\s+/g, "");
chapterListUrl = url + "chapter-list/";
_a = novel;
return [4 /*yield*/, getChapters()];
case 2:
_a.chapters = _b.sent();
return [2 /*return*/, novel];
}
});
});
};
MTLNovel.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var body, loadedCheerio, chapterText;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterUrl).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
chapterText = loadedCheerio("div.par").html() || '';
return [2 /*return*/, chapterText];
}
});
});
};
MTLNovel.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var searchUrl, res, result, novels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
searchUrl = this.baseUrl +
"wp-admin/admin-ajax.php?action=autosuggest&q=" +
searchTerm +
"&__amp_source_origin=https%3A%2F%2Fwww.mtlnovel.com";
return [4 /*yield*/, fetch(searchUrl)];
case 1:
res = _a.sent();
return [4 /*yield*/, res.json()];
case 2:
result = _a.sent();
novels = [];
result.items[0].results.map(function (item) {
var novelName = item.title.replace(/<\/?strong>/g, "");
var novelCover = item.thumbnail;
var novelUrl = item.permalink.replace("https://www.mtlnovel.com/", "");
var novel = { name: novelName, cover: novelCover, url: novelUrl };
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
MTLNovel.prototype.fetchImage = function (url) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, (0, fetch_1.fetchFile)(url)];
});
});
};
return MTLNovel;
}());
exports.default = new MTLNovel();
+177
View File
@@ -0,0 +1,177 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var MTLReader = /** @class */ (function () {
function MTLReader() {
this.id = "mtlreader";
this.name = "MTL Reader";
this.version = "1.0.0";
this.icon = "src/en/mtlreader/icon.png";
this.site = "https://mtlreader.com/";
this.baseUrl = this.site;
}
MTLReader.prototype.popularNovels = function (pageNo, options) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "novels?page=").concat(pageNo);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio(".col-md-4.col-sm-4").each(function () {
var novelName = loadedCheerio(this).find("h5").text();
var novelCover = loadedCheerio(this).find("img").attr("src");
var novelUrl = loadedCheerio(this).find("h5 > a").attr("href");
if (!novelUrl)
return;
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
MTLReader.prototype.parseNovelAndChapters = function (novelUrl) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novel, chapter;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = novelUrl;
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novel = {
url: url,
chapters: [],
};
novel.name = loadedCheerio(".agent-title").text().trim();
novel.cover = loadedCheerio(".agent-p-img > img").attr("src");
novel.summary = loadedCheerio("#editdescription").text().trim();
novel.author = loadedCheerio("i.fa-user")
.parent()
.text()
.replace("Author: ", "")
.trim();
chapter = [];
loadedCheerio("tr.spaceUnder").each(function () {
var chapterName = loadedCheerio(this).find("a").text().trim();
var releaseDate = null;
var chapterUrl = loadedCheerio(this).find("a").attr("href");
if (!chapterUrl)
return;
chapter.push({
name: chapterName,
releaseTime: releaseDate,
url: chapterUrl,
});
});
novel.chapters = chapter;
return [2 /*return*/, novel];
}
});
});
};
MTLReader.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var body, loadedCheerio, chapterText;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterUrl).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
loadedCheerio(".container ins,script,p.mtlreader").remove();
chapterText = loadedCheerio(".container").html() || '';
return [2 /*return*/, chapterText];
}
});
});
};
MTLReader.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "search?input=").concat(searchTerm);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio(".col-md-4.col-sm-4").each(function () {
var novelName = loadedCheerio(this).find("h5").text();
var novelCover = loadedCheerio(this).find("img").attr("src");
var novelUrl = loadedCheerio(this).find("h5 > a").attr("href");
if (!novelUrl)
return;
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
MTLReader.prototype.fetchImage = function (url) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, (0, fetch_1.fetchFile)(url)];
});
});
};
return MTLReader;
}());
exports.default = new MTLReader();
+227
View File
@@ -0,0 +1,227 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var NovelFull = /** @class */ (function () {
function NovelFull() {
this.id = "novelfull";
this.name = "NovelFull";
this.version = "1.0.0";
this.icon = "src/en/novelfull/icon.png";
this.site = "https://novelfull.com/";
this.baseUrl = this.site;
}
NovelFull.prototype.popularNovels = function (pageNo, options) {
return __awaiter(this, void 0, void 0, function () {
var url, result, body, loadedCheerio, novels;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "most-popular?page=").concat(pageNo);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio(".col-truyen-main .list-truyen .row").each(function (idx, ele) {
var _a, _b;
var novelName = loadedCheerio(ele)
.find("h3.truyen-title > a")
.text();
var novelCover = _this.baseUrl + ((_a = loadedCheerio(ele).find("img").attr("src")) === null || _a === void 0 ? void 0 : _a.slice(1));
var novelUrl = _this.baseUrl +
((_b = loadedCheerio(ele)
.find("h3.truyen-title > a")
.attr("href")) === null || _b === void 0 ? void 0 : _b.slice(1));
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
NovelFull.prototype.parseNovelAndChapters = function (novelUrl) {
return __awaiter(this, void 0, void 0, function () {
function getChapters(id, baseUrl) {
return __awaiter(this, void 0, void 0, function () {
var chapterListUrl, data, chapterlist, chapter;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
chapterListUrl = baseUrl + "ajax/chapter-option?novelId=" + id;
return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterListUrl)];
case 1:
data = _a.sent();
return [4 /*yield*/, data.text()];
case 2:
chapterlist = _a.sent();
loadedCheerio = (0, cheerio_1.load)(chapterlist);
chapter = [];
loadedCheerio("select > option").each(function () {
var _a;
var chapterName = loadedCheerio(this).text();
var releaseDate = null;
var chapterUrl = baseUrl + ((_a = loadedCheerio(this).attr("value")) === null || _a === void 0 ? void 0 : _a.slice(1));
chapter.push({
name: chapterName,
releaseTime: releaseDate,
url: chapterUrl,
});
});
return [2 /*return*/, chapter];
}
});
});
}
var url, result, body, loadedCheerio, novel, novelId, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
url = novelUrl;
return [4 /*yield*/, (0, fetch_1.fetchApi)(url)];
case 1:
result = _b.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _b.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novel = {
url: url,
chapters: [],
};
novel.name = loadedCheerio("div.book > img").attr("alt");
novel.cover = this.baseUrl + loadedCheerio("div.book > img").attr("src");
novel.summary = loadedCheerio("div.desc-text").text().trim();
novel.author = loadedCheerio('h3:contains("Author")')
.parent()
.contents()
.text()
.replace("Author:", "");
novel.genres = loadedCheerio('h3:contains("Genre")')
.siblings()
.map(function (i, el) { return loadedCheerio(el).text(); })
.toArray()
.join(",");
novel.status = loadedCheerio('h3:contains("Status")').next().text();
novelId = loadedCheerio("#rating").attr("data-novel-id");
_a = novel;
return [4 /*yield*/, getChapters(novelId, this.baseUrl)];
case 3:
_a.chapters = _b.sent();
return [2 /*return*/, novel];
}
});
});
};
NovelFull.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var result, body, loadedCheerio, chapterText;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterUrl)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
loadedCheerio("#chapter-content div.ads").remove();
chapterText = loadedCheerio("#chapter-content").html() || '';
return [2 /*return*/, chapterText];
}
});
});
};
NovelFull.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var searchUrl, result, body, loadedCheerio, novels;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
searchUrl = "".concat(this.baseUrl, "search?keyword=").concat(searchTerm);
return [4 /*yield*/, (0, fetch_1.fetchApi)(searchUrl)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio(".col-truyen-main .list-truyen .row").each(function (idx, ele) {
var _a, _b;
var novelName = loadedCheerio(ele)
.find("h3.truyen-title > a")
.text();
var novelCover = _this.baseUrl + ((_a = loadedCheerio(ele).find("img").attr("src")) === null || _a === void 0 ? void 0 : _a.slice(1));
var novelUrl = _this.baseUrl +
((_b = loadedCheerio(ele)
.find("h3.truyen-title > a")
.attr("href")) === null || _b === void 0 ? void 0 : _b.slice(1));
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
NovelFull.prototype.fetchImage = function (url) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, (0, fetch_1.fetchFile)(url)];
});
});
};
return NovelFull;
}());
exports.default = new NovelFull();
+183
View File
@@ -0,0 +1,183 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var NovelHall = /** @class */ (function () {
function NovelHall() {
this.id = "novelhold";
this.name = "Novel Hall";
this.version = "1.0.0";
this.icon = "src/en/novelhall/icon.png";
this.site = "https://novelhall.com/";
this.baseUrl = this.site;
}
NovelHall.prototype.popularNovels = function (pageNo, options) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novels;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "all2022-").concat(pageNo, ".html");
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio("li.btm").each(function (idx, ele) {
var novelName = loadedCheerio(ele).text().trim();
var novelUrl = _this.baseUrl + loadedCheerio(ele).find("a").attr("href");
var novel = {
name: novelName,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
NovelHall.prototype.parseNovelAndChapters = function (novelUrl) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novel, chapter;
var _this = this;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
url = novelUrl;
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _b.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novel = {
url: url,
chapters: [],
};
novel.name = loadedCheerio(".booknav2 > h1").text();
novel.cover = loadedCheerio('meta[property="og:image"]').attr("content");
novel.summary = loadedCheerio(".navtxt").text().trim();
novel.author = loadedCheerio('p:contains("Author")')
.text()
.replace("Author:", "")
.trim();
novel.status = loadedCheerio('p:contains("Status")')
.text()
.replace("Status:", "")
.replace("Active", "Ongoing")
.trim();
novel.genres = (_a = loadedCheerio('p:contains("Genre")')
.text()) === null || _a === void 0 ? void 0 : _a.replace("Genre:", "").trim();
chapter = [];
loadedCheerio("#morelist ul > li").each(function (idx, ele) {
var chapterName = loadedCheerio(ele).find("a").text().trim();
var releaseDate = null;
var chapterUrl = _this.baseUrl + loadedCheerio(ele).find("a").attr("href");
chapter.push({
name: chapterName,
releaseTime: releaseDate,
url: chapterUrl,
});
});
novel.chapters = chapter;
return [2 /*return*/, novel];
}
});
});
};
NovelHall.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var body, loadedCheerio, chapterText;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterUrl).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
chapterText = loadedCheerio(".content").html() || '';
return [2 /*return*/, chapterText];
}
});
});
};
NovelHall.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var url, body, loadedCheerio, novels;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "".concat(this.baseUrl, "index.php?s=so&module=book&keyword=").concat(searchTerm);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url).then(function (r) { return r.text(); })];
case 1:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio("#article_list_content > li").each(function (idx, ele) {
var _a;
var novelName = loadedCheerio(ele)
.find("h3")
.text()
.replace(/\t+/g, "")
.replace(/\n/g, " ");
var novelCover = loadedCheerio(ele).find("img").attr("data-src");
var novelUrl = _this.baseUrl + ((_a = loadedCheerio(ele).find("a").attr("href")) === null || _a === void 0 ? void 0 : _a.slice(1));
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
NovelHall.prototype.fetchImage = function (url) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, (0, fetch_1.fetchFile)(url)];
});
});
};
return NovelHall;
}());
exports.default = new NovelHall();
+467
View File
@@ -0,0 +1,467 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var filterInputs_1 = require("@libs/filterInputs");
var NovelUpdates = /** @class */ (function () {
function NovelUpdates() {
this.id = "novelupdates";
this.name = "Novel Updates";
this.version = "0.5.0";
this.icon = "src/en/novelupdates/icon.png";
this.site = "https://www.novelupdates.com/";
this.baseUrl = this.site;
this.filters = {
sort: {
label: "Sort Results By",
type: filterInputs_1.FilterTypes.Picker,
options: [
{ label: "Last Updated", value: "sdate" },
{ label: "Rating", value: "srate" },
{ label: "Rank", value: "srank" },
{ label: "Reviews", value: "sreview" },
{ label: "Chapters", value: "srel" },
{ label: "Title", value: "abc" },
{ label: "Readers", value: "sread" },
{ label: "Frequency", value: "sfrel" },
],
value: "sdate",
},
order: {
label: "Order",
type: filterInputs_1.FilterTypes.Picker,
options: [
{ label: "Descending", value: "desc" },
{ label: "Ascending", value: "asc" },
],
value: "asc"
},
storyStatus: {
label: "Story Status (Translation)",
type: filterInputs_1.FilterTypes.Picker,
options: [
{ label: "All", value: "" },
{ label: "Completed", value: "2" },
{ label: "Ongoing", value: "3" },
{ label: "Hiatus", value: "4" },
],
value: ""
},
language: {
label: "Language",
options: [
{ label: "Chinese", value: "495" },
{ label: "Filipino", value: "9181" },
{ label: "Indonesian", value: "9179" },
{ label: "Japanese", value: "496" },
{ label: "Khmer", value: "18657" },
{ label: "Korean", value: "497" },
{ label: "Malaysian", value: "9183" },
{ label: "Thai", value: "9954" },
{ label: "Vietnamese", value: "9177" },
],
type: filterInputs_1.FilterTypes.Picker,
value: ""
},
novelType: {
label: "Novel Type",
type: filterInputs_1.FilterTypes.CheckboxGroup,
value: [],
options: [
{ label: "Light Novel", value: "2443" },
{ label: "Published Novel", value: "26874" },
{ label: "Web Novel", value: "2444" },
]
},
genres: {
label: "Genres",
type: filterInputs_1.FilterTypes.CheckboxGroup,
value: [],
options: [
{ label: "Action", value: "8" },
{ label: "Adult", value: "280" },
{ label: "Adventure", value: "13" },
{ label: "Comedy", value: "17" },
{ label: "Drama", value: "9" },
{ label: "Ecchi", value: "292" },
{ label: "Fantasy", value: "5" },
{ label: "Gender Bender", value: "168" },
{ label: "Harem", value: "3" },
{ label: "Historical", value: "330" },
{ label: "Horror", value: "343" },
{ label: "Josei", value: "324" },
{ label: "Martial Arts", value: "14" },
{ label: "Mature", value: "4" },
{ label: "Mecha", value: "10" },
{ label: "Mystery", value: "245" },
{ label: "Psychoical", value: "486" },
{ label: "Romance", value: "15" },
{ label: "School Life", value: "6" },
{ label: "Sci-fi", value: "11" },
{ label: "Seinen", value: "18" },
{ label: "Shoujo", value: "157" },
{ label: "Shoujo Ai", value: "851" },
{ label: "Shounen", value: "12" },
{ label: "Shounen Ai", value: "1692" },
{ label: "Slice of Life", value: "7" },
{ label: "Smut", value: "281" },
{ label: "Sports", value: "1357" },
{ label: "Supernatural", value: "16" },
{ label: "Tragedy", value: "132" },
{ label: "Wuxia", value: "479" },
{ label: "Xianxia", value: "480" },
{ label: "Xuanhuan", value: "3954" },
{ label: "Yaoi", value: "560" },
{ label: "Yuri", value: "922" },
]
}
};
}
NovelUpdates.prototype.getPopularNovelsUrl = function (page, _a) {
var _b, _c, _d;
var showLatestNovels = _a.showLatestNovels, filters = _a.filters;
var url = "".concat(this.baseUrl).concat(filters
? "series-finder"
: showLatestNovels
? "latest-series"
: "series-ranking", "/");
if (!filters) {
url += "?rank=week";
}
else {
url += "?sf=1";
}
if (filters) {
if (Array.isArray(filters.novelType) && ((_b = filters.novelType) === null || _b === void 0 ? void 0 : _b.length)) {
url += "&nt=" + (filters === null || filters === void 0 ? void 0 : filters.novelType.join(","));
}
if (Array.isArray(filters.genres) && ((_c = filters.genres) === null || _c === void 0 ? void 0 : _c.length)) {
url += "&gi=" + (filters === null || filters === void 0 ? void 0 : filters.genres.join(",")) + "&mgi=and";
}
if (Array.isArray(filters.language) && ((_d = filters.language) === null || _d === void 0 ? void 0 : _d.length)) {
url += "&org=" + (filters === null || filters === void 0 ? void 0 : filters.language.join(","));
}
if (filters.storyStatus) {
url += "&ss=" + (filters === null || filters === void 0 ? void 0 : filters.storyStatus);
}
}
if (!(filters === null || filters === void 0 ? void 0 : filters.sort)) {
url += "&sort=" + "sdate";
}
else {
url += "&sort=" + (filters === null || filters === void 0 ? void 0 : filters.sort);
}
if (!(filters === null || filters === void 0 ? void 0 : filters.order)) {
url += "&order=" + "desc";
}
else {
url += "&order=" + (filters === null || filters === void 0 ? void 0 : filters.order);
}
return url;
};
NovelUpdates.prototype.popularNovels = function (pageNo, _a) {
var showLatestNovels = _a.showLatestNovels, filters = _a.filters;
return __awaiter(this, void 0, void 0, function () {
var url, result, body, loadedCheerio, novels;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
url = this.getPopularNovelsUrl(pageNo, { showLatestNovels: showLatestNovels, filters: filters });
return [4 /*yield*/, (0, fetch_1.fetchApi)(url)];
case 1:
result = _b.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _b.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio("div.search_main_box_nu").each(function (idx, ele) {
var novelCover = loadedCheerio(ele).find("img").attr("src");
var novelName = loadedCheerio(ele).find(".search_title > a").text();
var novelUrl = loadedCheerio(ele)
.find(".search_title > a")
.attr("href");
if (!novelUrl)
return;
var novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return [2 /*return*/, novels];
}
});
});
};
NovelUpdates.prototype.parseNovelAndChapters = function (novelUrl) {
return __awaiter(this, void 0, void 0, function () {
var url, result, body, loadedCheerio, novel, type, summary, chapter, novelId, formData, link, text;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = novelUrl;
return [4 /*yield*/, (0, fetch_1.fetchApi)(url)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novel = {
url: url,
chapters: [],
};
novel.name = loadedCheerio(".seriestitlenu").text();
novel.cover = loadedCheerio(".seriesimg > img").attr("src");
novel.author = loadedCheerio("#showauthors").text().trim();
novel.genres = loadedCheerio("#seriesgenre")
.children("a")
.map(function (i, el) { return loadedCheerio(el).text(); })
.toArray()
.join(",");
novel.status = loadedCheerio("#editstatus").text().includes("Ongoing")
? "Ongoing"
: "Completed";
type = loadedCheerio("#showtype").text().trim();
summary = loadedCheerio("#editdescription").text().trim();
novel.summary = summary + "\n\nType: ".concat(type);
chapter = [];
novelId = loadedCheerio("input#mypostid").attr("value");
formData = new FormData();
formData.append("action", "nd_getchapters");
formData.append("mygrr", "0");
formData.append("mypostid", novelId);
link = "https://www.novelupdates.com/wp-admin/admin-ajax.php";
return [4 /*yield*/, (0, fetch_1.fetchApi)(link, {
method: "POST",
body: formData,
}).then(function (data) { return data.text(); })];
case 3:
text = _a.sent();
loadedCheerio = (0, cheerio_1.load)(text);
loadedCheerio("li.sp_li_chp").each(function () {
var chapterName = loadedCheerio(this).text().trim();
var releaseDate = null;
var chapterUrl = "https:" +
loadedCheerio(this).find("a").first().next().attr("href");
chapter.push({
name: chapterName,
releaseTime: releaseDate,
url: chapterUrl,
});
});
novel.chapters = chapter.reverse();
return [2 /*return*/, novel];
}
});
});
};
NovelUpdates.prototype.getLocation = function (href) {
var match = href.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
return match && "".concat(match[1], "//").concat(match[3]);
};
NovelUpdates.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var chapterText, result, body, loadedCheerio, isWuxiaWorld, isBlogspot, isTumblr, isWattpad, isLightNovelsTls, isiNovelTranslation, isTravisTranslation, isWordPressStr, isWordPress, isRainOfSnow, isWebNovel, isHostedNovel, isScribbleHub, bloatClasses, tags;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
chapterText = "";
return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterUrl)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
isWuxiaWorld = chapterUrl.toLowerCase().includes("wuxiaworld");
isBlogspot = chapterUrl.toLowerCase().includes("blogspot");
isTumblr = chapterUrl.toLowerCase().includes("tumblr");
isWattpad = chapterUrl.toLowerCase().includes("wattpad");
isLightNovelsTls = chapterUrl
.toLowerCase()
.includes("lightnovelstranslations");
isiNovelTranslation = chapterUrl
.toLowerCase()
.includes("inoveltranslation");
isTravisTranslation = chapterUrl
.toLowerCase()
.includes("travistranslations");
isWordPressStr = loadedCheerio('meta[name="generator"]').attr("content") ||
loadedCheerio("footer").text();
isWordPress = false;
if (isWordPressStr) {
isWordPress =
isWordPressStr.toLowerCase().includes("wordpress") ||
isWordPressStr.includes("Site Kit by Google") ||
loadedCheerio(".powered-by")
.text()
.toLowerCase()
.includes("wordpress");
}
isRainOfSnow = chapterUrl.toLowerCase().includes("rainofsnow");
isWebNovel = chapterUrl.toLowerCase().includes("webnovel");
isHostedNovel = chapterUrl.toLowerCase().includes("hostednovel");
isScribbleHub = chapterUrl.toLowerCase().includes("scribblehub");
if (isWuxiaWorld) {
chapterText = loadedCheerio("#chapter-content").html();
}
else if (isRainOfSnow) {
chapterText = loadedCheerio("div.content").html();
}
else if (isTumblr) {
chapterText = loadedCheerio(".post").html();
}
else if (isBlogspot) {
loadedCheerio(".post-share-buttons").remove();
chapterText = loadedCheerio(".entry-content").html();
}
else if (isHostedNovel) {
chapterText = loadedCheerio(".chapter").html();
}
else if (isScribbleHub) {
chapterText = loadedCheerio("div.chp_raw").html();
}
else if (isWattpad) {
chapterText = loadedCheerio(".container pre").html();
}
else if (isTravisTranslation) {
chapterText = loadedCheerio(".reader-content").html();
}
else if (isLightNovelsTls) {
chapterText = loadedCheerio(".text_story").html();
}
else if (isiNovelTranslation) {
chapterText = loadedCheerio(".chakra-skeleton").html();
}
else if (isWordPress) {
bloatClasses = [
".c-ads",
"#madara-comments",
"#comments",
".content-comments",
".sharedaddy",
".wp-dark-mode-switcher",
".wp-next-post-navi",
".wp-block-buttons",
".wp-block-columns",
".post-cats",
".sidebar",
".author-avatar",
".ezoic-ad",
];
bloatClasses.map(function (tag) { return loadedCheerio(tag).remove(); });
chapterText =
loadedCheerio(".entry-content").html() ||
loadedCheerio(".single_post").html() ||
loadedCheerio(".post-entry").html() ||
loadedCheerio(".main-content").html() ||
loadedCheerio("article.post").html() ||
loadedCheerio(".content").html() ||
loadedCheerio("#content").html() ||
loadedCheerio(".page-body").html() ||
loadedCheerio(".td-page-content").html();
}
else if (isWebNovel) {
chapterText = loadedCheerio(".cha-words").html();
if (!chapterText) {
chapterText = loadedCheerio("._content").html();
}
}
else {
tags = ["nav", "header", "footer", ".hidden"];
tags.map(function (tag) { return loadedCheerio(tag).remove(); });
chapterText = loadedCheerio("body").html();
}
if (chapterText) {
/**
* Convert relative urls to absolute
*/
chapterText = chapterText.replace(/href="\//g, "href=\"".concat(this.getLocation(chapterUrl), "/"));
}
return [2 /*return*/, chapterText];
}
});
});
};
NovelUpdates.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var url, result, body, loadedCheerio, novels;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "https://www.novelupdates.com/?s=" +
searchTerm +
"&post_type=seriesplans";
return [4 /*yield*/, (0, fetch_1.fetchApi)(url)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novels = [];
loadedCheerio("div.search_main_box_nu").each(function () {
var _a;
var novelCover = loadedCheerio(this).find("img").attr("src");
var novelName = loadedCheerio(this).find(".search_title > a").text();
var novelUrl = (_a = loadedCheerio(this)
.find(".search_title > a")
.attr("href")) === null || _a === void 0 ? void 0 : _a.split("/")[4];
if (!novelUrl)
return;
novels.push({
name: novelName,
url: novelUrl,
cover: novelCover,
});
});
return [2 /*return*/, novels];
}
});
});
};
NovelUpdates.prototype.fetchImage = function (url) {
return (0, fetch_1.fetchFile)(url);
};
return NovelUpdates;
}());
exports.default = new NovelUpdates();
+192
View File
@@ -0,0 +1,192 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var cheerio_1 = require("cheerio");
var fetch_1 = require("@libs/fetch");
var WuxiaWorld = /** @class */ (function () {
function WuxiaWorld() {
this.id = "wuxiaworld";
this.name = "Wuxia World";
this.icon = "src/en/wuxiaworld/icon.png";
this.site = "https://www.wuxiaworld.com/";
this.version = "0.5.0";
this.baseUrl = this.site;
}
WuxiaWorld.prototype.popularNovels = function (pageNo, options) {
return __awaiter(this, void 0, void 0, function () {
var link, result, data, novels;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
link = "".concat(this.baseUrl, "api/novels");
return [4 /*yield*/, fetch(link)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.json()];
case 2:
data = _a.sent();
novels = [];
data.items.map(function (novel) {
var name = novel.name;
var cover = novel.coverUrl;
var url = _this.baseUrl + "novel/" + novel.slug + "/";
novels.push({
name: name,
cover: cover,
url: url,
});
});
return [2 /*return*/, novels];
}
});
});
};
WuxiaWorld.prototype.parseNovelAndChapters = function (novelUrl) {
return __awaiter(this, void 0, void 0, function () {
var url, result, body, loadedCheerio, novel, genres, chapter;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = novelUrl;
return [4 /*yield*/, (0, fetch_1.fetchApi)(url)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
novel = {
url: url,
chapters: [],
};
novel.name = loadedCheerio("h1.line-clamp-2").text();
novel.cover = loadedCheerio("img.absolute").attr("src");
novel.summary = loadedCheerio("div.flex-col:nth-child(4) > div > div > span > span")
.text()
.trim();
novel.author = loadedCheerio("div.MuiGrid-container > div > div > div")
.filter(function () {
return loadedCheerio(this).text().trim() === "Author:";
})
.next()
.text();
genres = [];
loadedCheerio("a.MuiLink-underlineNone").each(function () {
genres.push(loadedCheerio(this).find("div > div").text());
});
novel.genres = genres.join(",");
novel.status = loadedCheerio("div.font-set-b10")
.text();
chapter = [];
loadedCheerio("div.border-b.border-gray-line-base").each(function (idx, ele) {
var _a;
var name = loadedCheerio(ele)
.find("a > div > div > div > span")
.text();
var releaseTime = loadedCheerio(ele)
.find("a > div > div > div > div > span")
.text();
var url = (_a = loadedCheerio(ele).find("a").attr("href")) === null || _a === void 0 ? void 0 : _a.slice(1);
url = "".concat(_this.baseUrl).concat(url);
chapter.push({ name: name, releaseTime: releaseTime, url: url });
});
novel.chapters = chapter;
return [2 /*return*/, novel];
}
});
});
};
WuxiaWorld.prototype.parseChapter = function (chapterUrl) {
return __awaiter(this, void 0, void 0, function () {
var result, body, loadedCheerio, chapterText;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, fetch_1.fetchApi)(chapterUrl)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.text()];
case 2:
body = _a.sent();
loadedCheerio = (0, cheerio_1.load)(body);
loadedCheerio(".chapter-nav").remove();
loadedCheerio("#chapter-content > script").remove();
chapterText = loadedCheerio("#chapter-content").html() || '';
return [2 /*return*/, chapterText];
}
});
});
};
WuxiaWorld.prototype.searchNovels = function (searchTerm, pageNo) {
return __awaiter(this, void 0, void 0, function () {
var searchUrl, url, result, data, novels;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
searchUrl = "https://www.wuxiaworld.com/api/novels/search?query=";
url = "".concat(searchUrl).concat(searchTerm);
return [4 /*yield*/, (0, fetch_1.fetchApi)(url)];
case 1:
result = _a.sent();
return [4 /*yield*/, result.json()];
case 2:
data = _a.sent();
novels = [];
data.items.map(function (novel) {
var name = novel.name;
var cover = novel.coverUrl;
var url = _this.baseUrl + "novel/" + novel.slug + "/";
novels.push({
name: name,
url: url,
cover: cover,
});
});
return [2 /*return*/, novels];
}
});
});
};
WuxiaWorld.prototype.fetchImage = function (url) {
return (0, fetch_1.fetchFile)(url);
};
return WuxiaWorld;
}());
exports.default = new WuxiaWorld();