fc52a6e665
* fix * test * sync * nitromanga -> madara * test wuxiaworld * xm * add chapterNumber * fix chapterNumber > 0 * test filters * nice * tunovelaligera -> madara * Squashed commit of the following: commit4c7bee5855Author: nyagami <hoangquan05112002@gmail.com> Date: Mon Jan 29 17:56:23 2024 +0700 fix: use english lang in plugin item consistent commitb26d1129deAuthor: uy/sun <hmy0119@hotmail.com> Date: Sun Jan 28 20:22:43 2024 +0800 Chinese: support showLatestNovels (#733) * improve: better chapterText * feat: support latest page commit6ff206eab3Author: nyagami <hoangquan05112002@gmail.com> Date: Sat Jan 27 09:26:19 2024 +0700 Refactor: Using English key (#728) * fix: use english key instead of native * fix: ukrainian * fix: web test with new plugins map commit62fc988019Author: Marcin Majewski <skilletssgames@gmail.com> Date: Fri Jan 26 14:42:54 2024 +0100 Fix search box styles (#727) commit3a1e0c43ebAuthor: uy/sun <hmy0119@hotmail.com> Date: Fri Jan 26 19:46:47 2024 +0800 Add 69shu and 69xinshu (#726) * fix(linovelib): use NovelStatus and translate filter label * feat(69xinshu): add 69xinshu * feat(69shu): add 69shu * remove: empty userAgent * updated the filters and removed dead sites. Error: net::ERR_NAME_NOT_RESOLVED at https://cratenovel.com/novel Error: net::ERR_CONNECTION_REFUSED at https://clicknovel.net/novel Error: net::ERR_NAME_NOT_RESOLVED at https://noobchan.xyz/novel Error: net::ERR_CONNECTION_TIMED_OUT at https://sugarbbscan.com/series * test * Squashed commit of the following: commitcadf7a72feAuthor: Felipe Bonfim <felipebonfim2006@gmail.com> Date: Tue Jan 30 14:55:34 2024 -0400 kiniga added (#739) * kiniga added * kiniga updated icon commit38fc1860daAuthor: K1ngfish3r <trulyihu@gmail.com> Date: Mon Jan 29 23:27:42 2024 +0800 (add src) LNMTL & ScribbleHub (#738) * quick * quick panda fix * remove console.log commit4c7bee5855Author: nyagami <hoangquan05112002@gmail.com> Date: Mon Jan 29 17:56:23 2024 +0700 fix: use english lang in plugin item consistent commitb26d1129deAuthor: uy/sun <hmy0119@hotmail.com> Date: Sun Jan 28 20:22:43 2024 +0800 Chinese: support showLatestNovels (#733) * improve: better chapterText * feat: support latest page commit6ff206eab3Author: nyagami <hoangquan05112002@gmail.com> Date: Sat Jan 27 09:26:19 2024 +0700 Refactor: Using English key (#728) * fix: use english key instead of native * fix: ukrainian * fix: web test with new plugins map commit62fc988019Author: Marcin Majewski <skilletssgames@gmail.com> Date: Fri Jan 26 14:42:54 2024 +0100 Fix search box styles (#727) commit3a1e0c43ebAuthor: uy/sun <hmy0119@hotmail.com> Date: Fri Jan 26 19:46:47 2024 +0800 Add 69shu and 69xinshu (#726) * fix(linovelib): use NovelStatus and translate filter label * feat(69xinshu): add 69xinshu * feat(69shu): add 69shu * remove: empty userAgent * add wuxiamtl, fannovel * fix * Update ranobelib.ts * parseMadaraDate deleted * remove multisrc name from Plugin item --------- Co-authored-by: nyagami <hoangquan05112002@gmail.com>
150 lines
4.5 KiB
TypeScript
150 lines
4.5 KiB
TypeScript
import { CheerioAPI, load } from "cheerio";
|
|
import { fetchApi, fetchFile } from "@libs/fetch";
|
|
import { Plugin } from "@typings/plugin";
|
|
import { NovelStatus } from "@libs/novelStatus";
|
|
|
|
interface WPmangaStreamOptions {
|
|
reverseChapters?: boolean;
|
|
lang?: string;
|
|
}
|
|
|
|
export interface WPmangaStreamMetadata {
|
|
id: string;
|
|
sourceSite: string;
|
|
sourceName: string;
|
|
options?: WPmangaStreamOptions;
|
|
}
|
|
|
|
class WPmangaStreamPlugin implements Plugin.PluginBase {
|
|
id: string;
|
|
name: string;
|
|
icon: string;
|
|
site: string;
|
|
version: string;
|
|
options?: WPmangaStreamOptions;
|
|
|
|
constructor(metadata: WPmangaStreamMetadata) {
|
|
this.id = metadata.id;
|
|
this.name = metadata.sourceName;
|
|
this.icon = `multisrc/wpmangastream/icons/${metadata.id}.png`;
|
|
this.site = metadata.sourceSite;
|
|
this.version = "1.0.0";
|
|
this.options = metadata.options;
|
|
}
|
|
|
|
async popularNovels(page: number): Promise<Plugin.NovelItem[]> {
|
|
const url = this.site + "series/?page=" + page + "&status=&order=popular";
|
|
const body = await fetchApi(url).then((res) => res.text());
|
|
const loadedCheerio = load(body);
|
|
const novels: Plugin.NovelItem[] = [];
|
|
|
|
loadedCheerio("article.maindet").each(function () {
|
|
const name = loadedCheerio(this).find("h2").text();
|
|
const image = loadedCheerio(this).find("img");
|
|
const url = loadedCheerio(this).find("h2 a").attr("href");
|
|
|
|
if (!url) return;
|
|
novels.push({
|
|
name,
|
|
cover: image.attr("data-src") || image.attr("src"),
|
|
url,
|
|
});
|
|
});
|
|
|
|
return novels;
|
|
}
|
|
|
|
async parseNovelAndChapters(url: string): Promise<Plugin.SourceNovel> {
|
|
const body = await fetchApi(url).then((res) => res.text());
|
|
const loadedCheerio = load(body);
|
|
|
|
const novel: Plugin.SourceNovel = { url };
|
|
|
|
// novel.url = url;
|
|
novel.name = loadedCheerio("h1.entry-title").text();
|
|
novel.cover =
|
|
loadedCheerio("img.wp-post-image").attr("data-src") ||
|
|
loadedCheerio("img.wp-post-image").attr("src");
|
|
novel.status = loadedCheerio("div.sertostat > span").attr("class");
|
|
|
|
loadedCheerio("div.serl > span").each(function () {
|
|
const detailName = loadedCheerio(this).text().trim();
|
|
const detail = loadedCheerio(this).next().text().trim();
|
|
|
|
switch (detailName) {
|
|
case "الكاتب":
|
|
case "Author":
|
|
case "Auteur":
|
|
novel.author = detail;
|
|
break;
|
|
}
|
|
});
|
|
|
|
novel.genres = loadedCheerio(".sertogenre")
|
|
.children("a")
|
|
.map((i, el) => loadedCheerio(el).text())
|
|
.toArray()
|
|
.join(",");
|
|
|
|
let summary = loadedCheerio(".sersys > p").siblings().remove("div").end();
|
|
novel.summary = "";
|
|
for (let i = 0; i < summary.length; i++) {
|
|
const p = summary[i];
|
|
novel.summary += loadedCheerio(p).text().trim() + "\\n\\n";
|
|
}
|
|
|
|
const totalChapters = loadedCheerio(".eplister li").length;
|
|
const chapters: Plugin.ChapterItem[] = loadedCheerio(".eplister li")
|
|
.map((chapterIndex, element) => ({
|
|
name:
|
|
loadedCheerio(element).find(".epl-num").text() +
|
|
loadedCheerio(element).find(".epl-title").text(),
|
|
url: loadedCheerio(element).find("a").attr("href") || "",
|
|
releaseTime: loadedCheerio(element).find(".epl-date").text().trim(),
|
|
chapterNumber: this.options?.reverseChapters
|
|
? totalChapters - chapterIndex
|
|
: chapterIndex + 1,
|
|
}))
|
|
.get()
|
|
.filter((chapter) => chapter.name && chapter.url);
|
|
|
|
if (this.options?.reverseChapters && chapters.length) chapters.reverse();
|
|
|
|
novel.chapters = chapters;
|
|
return novel;
|
|
}
|
|
|
|
async parseChapter(chapterUrl: string): Promise<string> {
|
|
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
|
const loadedCheerio = load(body);
|
|
|
|
const chapterText = loadedCheerio(".epcontent").html() || "";
|
|
return chapterText;
|
|
}
|
|
|
|
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
|
const url = this.site + "?s=" + searchTerm;
|
|
const body = await fetchApi(url).then((res) => res.text());
|
|
const loadedCheerio = load(body);
|
|
|
|
const novels: Plugin.NovelItem[] = [];
|
|
|
|
loadedCheerio("article.maindet").each(function () {
|
|
const name = loadedCheerio(this).find("h2").text();
|
|
const image = loadedCheerio(this).find("img");
|
|
const url = loadedCheerio(this).find("h2 a").attr("href");
|
|
|
|
if (!url) return;
|
|
novels.push({
|
|
name,
|
|
cover: image.attr("data-src") || image.attr("src"),
|
|
url,
|
|
});
|
|
});
|
|
|
|
return novels;
|
|
}
|
|
|
|
fetchImage = fetchFile;
|
|
}
|