* fix

* test

* sync

* nitromanga -> madara

* test wuxiaworld

* xm

* add chapterNumber

* fix

chapterNumber > 0

* test filters

* nice

* tunovelaligera -> madara

* Squashed commit of the following:

commit 4c7bee5855
Author: nyagami <hoangquan05112002@gmail.com>
Date:   Mon Jan 29 17:56:23 2024 +0700

    fix: use english lang in plugin item consistent

commit b26d1129de
Author: 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

commit 6ff206eab3
Author: 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

commit 62fc988019
Author: Marcin Majewski <skilletssgames@gmail.com>
Date:   Fri Jan 26 14:42:54 2024 +0100

    Fix search box styles (#727)

commit 3a1e0c43eb
Author: 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:

commit cadf7a72fe
Author: Felipe Bonfim <felipebonfim2006@gmail.com>
Date:   Tue Jan 30 14:55:34 2024 -0400

    kiniga added (#739)

    * kiniga added

    * kiniga updated icon

commit 38fc1860da
Author: 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

commit 4c7bee5855
Author: nyagami <hoangquan05112002@gmail.com>
Date:   Mon Jan 29 17:56:23 2024 +0700

    fix: use english lang in plugin item consistent

commit b26d1129de
Author: 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

commit 6ff206eab3
Author: 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

commit 62fc988019
Author: Marcin Majewski <skilletssgames@gmail.com>
Date:   Fri Jan 26 14:42:54 2024 +0100

    Fix search box styles (#727)

commit 3a1e0c43eb
Author: 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>
This commit is contained in:
Rider21
2024-02-04 08:47:12 +03:00
committed by GitHub
parent 26bdb94100
commit fc52a6e665
36 changed files with 34403 additions and 15118 deletions
+22 -22
View File
@@ -22,7 +22,7 @@ class IfreedomPlugin implements Plugin.PluginBase {
constructor(metadata: IfreedomMetadata) {
this.id = metadata.id;
this.name = metadata.sourceName + "[ifreedom]";
this.name = metadata.sourceName;
this.icon = `multisrc/ifreedom/icons/${metadata.id}.png`;
this.site = metadata.sourceSite;
this.version = "1.0.0";
@@ -31,20 +31,17 @@ class IfreedomPlugin implements Plugin.PluginBase {
async popularNovels(
page: number,
{ filters, showLatestNovels }: Plugin.PopularNovelsOptions,
{ filters, showLatestNovels }: Plugin.PopularNovelsOptions<typeof this.filters>,
): Promise<Plugin.NovelItem[]> {
let url = this.site + "/vse-knigi/?sort=" +
(showLatestNovels ? "По дате обновления" : filters?.sort?.value || "По рейтингу");
if (filters?.status?.value instanceof Array) {
url += filters.status.value.map((i) => "&status[]=" + i).join("");
}
if (filters?.lang?.value instanceof Array) {
url += filters.lang.value.map((i) => "&lang[]=" + i).join("");
}
if (filters?.genre?.value instanceof Array) {
url += filters.genre.value.map((i) => "&genre[]=" + i).join("");
}
Object.entries(filters || {}).forEach(([type, { value }]) => {
if (value instanceof Array && value.length) {
url += "&" + type + "[]=" + value.join("&" + type + "[]=");
}
});
url += "&bpage=" + page;
const body = await fetchApi(url).then((res) => res.text());
@@ -102,14 +99,14 @@ class IfreedomPlugin implements Plugin.PluginBase {
if (novel.author == "Не указан") delete novel.author;
const chapters: Plugin.ChapterItem[] = [];
loadedCheerio("div.li-ranobe").each(function () {
const name = loadedCheerio(this).find("a").text();
const url = loadedCheerio(this).find("a").attr("href");
if (!loadedCheerio(this).find("label.buy-ranobe").length && name && url) {
const releaseTime = loadedCheerio(this)
.find("div.li-col2-ranobe").text().trim();
const totalChapters = loadedCheerio("div.li-ranobe").length;
chapters.push({ name, releaseTime, url });
loadedCheerio("div.li-ranobe").each((chapterIndex, element) => {
const name = loadedCheerio(element).find("a").text();
const url = loadedCheerio(element).find("a").attr("href");
if (!loadedCheerio(element).find("label.buy-ranobe").length && name && url) {
const releaseTime = loadedCheerio(element).find("div.li-col2-ranobe").text().trim();
chapters.push({ name, url, releaseTime, chapterNumber: totalChapters - chapterIndex });
}
});
@@ -121,11 +118,14 @@ class IfreedomPlugin implements Plugin.PluginBase {
const body = await fetchApi(chapterUrl).then((res) => res.text());
const loadedCheerio = parseHTML(body);
loadedCheerio(".entry-content img").each(function () {
const srcset = loadedCheerio(this).attr("srcset")?.split?.(" ");
loadedCheerio(".entry-content img").each((index, element) => {
const srcset = loadedCheerio(element).attr("srcset")?.split?.(" ");
if (srcset?.length) {
const bestlink = srcset.filter((url) => url.startsWith("http")).unshift();
if (typeof bestlink == 'string') loadedCheerio(this).attr("src", bestlink);
loadedCheerio(element).removeAttr("srcset");
const bestlink: string[] = srcset.filter((url) => url.startsWith("http"));
if (bestlink[bestlink.length - 1]) {
loadedCheerio(element).attr("src", bestlink[bestlink.length - 1]);
}
}
});
+3
View File
@@ -11,6 +11,9 @@ export const generateAll: ScrpitGeneratorFunction = function (name) {
/* This map is changing `type` from string to FilterTypes */
.map<MadaraMetadata>((p) => {
let d = false;
if (p?.filters?.genres?.options?.length) {
p.filters.genres.options.unshift({ label: "NONE", value: "" })
}
const filters: Filters = {};
for (const k in p.filters) {
const f = p.filters[k as keyof typeof p.filters];
File diff suppressed because it is too large Load Diff
+285 -239
View File
@@ -4,275 +4,321 @@ import { Plugin } from "@typings/plugin";
import { load as parseHTML } from "cheerio";
import { defaultCover } from "@libs/defaultCover";
import { NovelStatus } from "@libs/novelStatus";
import { parseMadaraDate } from "@libs/parseMadaraDate";
import dayjs from "dayjs";
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
const includesAny = (str: string, keywords: string[]) =>
new RegExp(keywords.join("|")).test(str);
interface MadaraOptionPath {
genres?: string;
novels?: string;
novel?: string;
chapter?: string;
genres?: string;
novels?: string;
novel?: string;
chapter?: string;
}
const MadaraDefaultPath = {
genres: "novel-genre",
novels: "novel",
novel: "novel",
chapter: "novel",
genres: "novel-genre",
novels: "novel",
novel: "novel",
chapter: "novel",
};
interface MadaraOptions {
useNewChapterEndpoint?: boolean;
path?: MadaraOptionPath;
lang?: string;
orderBy?: string;
useNewChapterEndpoint?: boolean;
path?: MadaraOptionPath;
lang?: string;
orderBy?: string;
}
export interface MadaraMetadata {
id: string;
sourceSite: string;
sourceName: string;
options?: MadaraOptions;
filters?: Filters;
id: string;
sourceSite: string;
sourceName: string;
options?: MadaraOptions;
filters?: Filters;
}
class MadaraPlugin implements Plugin.PluginBase {
id: string;
name: string;
icon: string;
site: string;
version: string;
options?: MadaraOptions;
filters?: Filters | undefined;
id: string;
name: string;
icon: string;
site: string;
version: string;
options?: MadaraOptions;
filters?: Filters | undefined;
constructor(metadata: MadaraMetadata) {
this.id = metadata.id;
this.name = metadata.sourceName + "[madara]";
const iconFileName = metadata.sourceName
.replace(/\s+/g, "")
.toLowerCase();
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
this.site = metadata.sourceSite;
this.version = "1.0.0";
this.options = metadata.options;
this.filters = metadata.filters;
constructor(metadata: MadaraMetadata) {
this.id = metadata.id;
this.name = metadata.sourceName;
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
this.site = metadata.sourceSite;
this.version = "1.0.0";
this.options = metadata.options;
this.filters = metadata.filters;
}
async popularNovels(
pageNo: number,
{
filters,
showLatestNovels,
}: Plugin.PopularNovelsOptions<typeof this.filters>,
): Promise<Plugin.NovelItem[]> {
const novels: Plugin.NovelItem[] = [];
let url = this.site;
if (filters?.genres?.value) {
url +=
(this.options?.path?.genres || MadaraDefaultPath.genres) +
"/" + filters.genres.value;
} else {
url += this.options?.path?.novels || MadaraDefaultPath.novels;
}
async popularNovels(
pageNo: number,
{
filters,
showLatestNovels,
}: Plugin.PopularNovelsOptions<typeof this.filters>
): Promise<Plugin.NovelItem[]> {
const novels: Plugin.NovelItem[] = [];
let url = this.site;
if (filters?.genres?.value) {
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
"/" +
filters.genres.value;
} else {
url += this.options?.path?.novels || MadaraDefaultPath.novels;
}
url += "/page/" + pageNo + "/?m_orderby=" +
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
url +=
"/page/" +
pageNo +
"/" +
"?m_orderby=" +
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
const body = await fetchApi(url).then((res) => res.text());
const loadedCheerio = parseHTML(body);
const body = await fetchApi(url).then((res) => res.text());
loadedCheerio(".manga-title-badges").remove();
const loadedCheerio = parseHTML(body);
loadedCheerio(".page-item-detail").each(function () {
const novelName = loadedCheerio(this).find(".post-title").text().trim();
const image = loadedCheerio(this).find("img");
const novelCover = image.attr("data-src") || image.attr("src");
const novelUrl =
loadedCheerio(this).find(".post-title").find("a").attr("href") || "";
if (!novelName || !novelUrl) return;
loadedCheerio(".manga-title-badges").remove();
const novel: Plugin.NovelItem = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
loadedCheerio(".page-item-detail").each(function () {
const novelName = loadedCheerio(this)
.find(".post-title")
.text()
.trim();
let image = loadedCheerio(this).find("img");
const novelCover = image.attr("data-src") || image.attr("src");
novels.push(novel);
});
let novelUrl =
loadedCheerio(this)
.find(".post-title")
.find("a")
.attr("href") || "";
const novel: Plugin.NovelItem = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
return novels;
}
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
const novel: Plugin.SourceNovel = {
url: novelUrl,
};
novels.push(novel);
});
const body = await fetchApi(novelUrl).then((res) => res.text());
return novels;
let loadedCheerio = parseHTML(body);
loadedCheerio(".manga-title-badges, #manga-title span").remove();
novel.name =
loadedCheerio(".post-title h1").text().trim() ||
loadedCheerio("#manga-title h1").text();
novel.cover =
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
loadedCheerio(".summary_image > a > img").attr("src") ||
loadedCheerio(".summary_image > a > img").attr("src") ||
defaultCover;
loadedCheerio(".post-content_item, .post-content").each(function () {
const detailName = loadedCheerio(this).find("h5").text().trim();
const detail = loadedCheerio(this).find(".summary-content").text().trim();
switch (detailName) {
case "Genre(s)":
case "Género(s)":
case "التصنيفات":
novel.genres = detail;
break;
case "Author(s)":
case "Autor(es)":
case "المؤلف":
case "المؤلف (ين)":
novel.author = detail;
break;
case "Status":
case "Estado":
novel.status =
detail.includes("OnGoing") || detail.includes("مستمرة")
? NovelStatus.Ongoing
: NovelStatus.Completed;
break;
}
});
loadedCheerio("div.summary__content .code-block,script").remove();
novel.summary =
loadedCheerio("div.summary__content").text().trim() ||
loadedCheerio("#tab-manga-about").text().trim() ||
loadedCheerio('.post-content_item h5:contains("Summary")')
.next()
.text()
.trim();
const chapters: Plugin.ChapterItem[] = [];
let html = "";
if (this.options?.useNewChapterEndpoint) {
html = await fetchApi(novelUrl + "ajax/chapters/", {
method: "POST",
}).then((res) => res.text());
} else {
const novelId =
loadedCheerio(".rating-post-id").attr("value") ||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
"";
const formData = new FormData();
formData.append("action", "manga_get_chapters");
formData.append("manga", novelId);
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
method: "POST",
body: formData,
}).then((res) => res.text());
}
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
const novel: Plugin.SourceNovel = {
url: novelUrl,
};
const body = await fetchApi(novelUrl).then((res) => res.text());
let loadedCheerio = parseHTML(body);
loadedCheerio(".manga-title-badges, #manga-title span").remove();
novel.name =
loadedCheerio(".post-title h1").text().trim() ||
loadedCheerio("#manga-title h1").text();
novel.cover =
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
loadedCheerio(".summary_image > a > img").attr("src") ||
defaultCover;
loadedCheerio(".post-content_item, .post-content").each(function () {
const detailName = loadedCheerio(this).find("h5").text().trim();
const detail = loadedCheerio(this)
.find(".summary-content")
.text()
.trim();
switch (detailName) {
case "Genre(s)":
case "التصنيفات":
novel.genres = detail.replace(/[\\t\\n]/g, ",");
break;
case "Author(s)":
case "المؤلف":
case "المؤلف (ين)":
novel.author = detail;
break;
case "Status":
case "الحالة":
novel.status =
detail.includes("OnGoing") || detail.includes("مستمرة")
? NovelStatus.Ongoing
: NovelStatus.Completed;
break;
}
});
loadedCheerio("div.summary__content .code-block,script").remove();
novel.summary =
loadedCheerio("div.summary__content").text().trim() ||
loadedCheerio("#tab-manga-about").text().trim() ||
loadedCheerio('.post-content_item h5:contains("Summary")')
.next()
.text()
.trim();
let html;
if (this.options?.useNewChapterEndpoint !== true) {
const novelId =
loadedCheerio(".rating-post-id").attr("value") ||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
"";
const formData = new FormData();
formData.append("action", "manga_get_chapters");
formData.append("manga", novelId);
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
method: "POST",
body: formData,
}).then((res) => res.text());
} else {
html = await fetchApi(novelUrl + "ajax/chapters/", {
method: "POST",
}).then((res) => res.text());
}
if (html !== "0") {
loadedCheerio = parseHTML(html);
}
const chapters: Plugin.ChapterItem[] = [];
loadedCheerio(".wp-manga-chapter").each(function () {
const chapterName = loadedCheerio(this).find("a").text().trim();
let releaseDate = null;
releaseDate = loadedCheerio(this)
.find("span.chapter-release-date")
.text()
.trim();
if (releaseDate) {
releaseDate = parseMadaraDate(releaseDate);
} else {
/**
* Insert current date
*/
releaseDate = dayjs().format("LL");
}
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
chapters.push({
name: chapterName,
releaseTime: releaseDate,
url: chapterUrl,
});
});
novel.chapters = chapters.reverse();
return novel;
if (html !== "0") {
loadedCheerio = parseHTML(html);
}
async parseChapter(chapterUrl: string): Promise<string> {
const body = await fetchApi(chapterUrl).then((res) => res.text());
const loadedCheerio = parseHTML(body);
const chapterText =
loadedCheerio(".text-left").html() ||
loadedCheerio(".text-right").html() ||
loadedCheerio(".entry-content").html() ||
"";
const totalChapters = loadedCheerio(".wp-manga-chapter").length;
loadedCheerio(".wp-manga-chapter").each((chapterIndex, element) => {
const chapterName = loadedCheerio(element).find("a").text().trim();
return chapterText;
let releaseDate = loadedCheerio(element)
.find("span.chapter-release-date")
.text()
.trim();
if (releaseDate) {
releaseDate = this.parseData(releaseDate);
} else {
releaseDate = dayjs().format("LL");
}
let chapterUrl = loadedCheerio(element).find("a").attr("href") || "";
chapters.push({
name: chapterName,
url: chapterUrl,
releaseTime: releaseDate || null,
chapterNumber: totalChapters - chapterIndex,
});
});
novel.chapters = chapters.reverse();
return novel;
}
async parseChapter(chapterUrl: string): Promise<string> {
const body = await fetchApi(chapterUrl).then((res) => res.text());
const loadedCheerio = parseHTML(body);
const chapterText =
loadedCheerio(".text-left").html() ||
loadedCheerio(".text-right").html() ||
loadedCheerio(".entry-content").html() ||
loadedCheerio(".c-blog-post > div > div:nth-child(2)").html() ||
"";
return chapterText;
}
async searchNovels(
searchTerm: string,
pageNo?: number | undefined,
): Promise<Plugin.NovelItem[]> {
const novels: Plugin.NovelItem[] = [];
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
const body = await fetchApi(url).then((res) => res.text());
const loadedCheerio = parseHTML(body);
loadedCheerio(".c-tabs-item__content").each(function () {
const novelName = loadedCheerio(this).find(".post-title").text().trim();
let image = loadedCheerio(this).find("img");
const novelCover = image.attr("data-src") || image.attr("src");
let novelUrl =
loadedCheerio(this).find(".post-title").find("a").attr("href") || "";
const novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return novels;
}
fetchImage = fetchFile;
parseData = (date: string) => {
const dayJSDate = dayjs(); // today
const timeAgo = date.match(/\d+/)?.[0] || "";
const timeAgoInt = parseInt(timeAgo, 10);
if (!timeAgo) return date; // there is no number!
if (includesAny(date, ["detik", "segundo", "second", "วินาที"])) {
dayJSDate.subtract(timeAgoInt, "second"); // go back N seconds
} else if (
includesAny(date, [
"menit",
"dakika",
"min",
"minute",
"minuto",
"นาที",
"دقائق",
])
) {
dayJSDate.subtract(timeAgoInt, "minute"); // go back N minute
} else if (
includesAny(date, [
"jam",
"saat",
"heure",
"hora",
"hour",
"ชั่วโมง",
"giờ",
"ore",
"ساعة",
"小时",
])
) {
dayJSDate.subtract(timeAgoInt, "hours"); // go back N hours
} else if (
includesAny(date, [
"hari",
"gün",
"jour",
"día",
"dia",
"day",
"วัน",
"ngày",
"giorni",
"أيام",
"天",
])
) {
dayJSDate.subtract(timeAgoInt, "days"); // go back N days
} else if (includesAny(date, ["week", "semana"])) {
dayJSDate.subtract(timeAgoInt, "week"); // go back N a week
} else if (includesAny(date, ["month", "mes"])) {
dayJSDate.subtract(timeAgoInt, "month"); // go back N months
} else if (includesAny(date, ["year", "año"])) {
dayJSDate.subtract(timeAgoInt, "year"); // go back N years
} else {
return date;
}
async searchNovels(
searchTerm: string,
pageNo?: number | undefined
): Promise<Plugin.NovelItem[]> {
const novels: Plugin.NovelItem[] = [];
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
const body = await fetchApi(url).then((res) => res.text());
const loadedCheerio = parseHTML(body);
loadedCheerio(".c-tabs-item__content").each(function () {
const novelName = loadedCheerio(this)
.find(".post-title")
.text()
.trim();
let image = loadedCheerio(this).find("img");
const novelCover = image.attr("data-src") || image.attr("src");
let novelUrl =
loadedCheerio(this)
.find(".post-title")
.find("a")
.attr("href") || "";
const novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return novels;
}
async fetchImage(url: string): Promise<string | undefined> {
return await fetchFile(url, {});
}
return dayJSDate.format("LL");
};
}
-4
View File
@@ -76,10 +76,6 @@
"label": "Fantasy Romance",
"value": "fantasy-romance"
},
{
"label": "Game",
"value": "game"
},
{
"label": "Gender Bender",
"value": "gender-bender"
File diff suppressed because it is too large Load Diff
+50 -21
View File
@@ -3,8 +3,7 @@ import { Filters, FilterTypes } from "@libs/filterInputs";
import { Plugin } from "@typings/plugin";
import { NovelStatus } from "@libs/novelStatus";
import { load as parseHTML } from "cheerio";
import { parseMadaraDate } from "@libs/parseMadaraDate";
// import { defaultCover } from "@libs/defaultCover";
import dayjs from "dayjs";
export interface ReadwnMetadata {
id: string;
@@ -23,9 +22,8 @@ class ReadwnPlugin implements Plugin.PluginBase {
constructor(metadata: ReadwnMetadata) {
this.id = metadata.id;
this.name = metadata.sourceName + "[readwn]";
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
this.icon = `multisrc/readwn/icons/${iconFileName}.png`;
this.name = metadata.sourceName;
this.icon = `multisrc/readwn/icons/${metadata.id}.png`;
this.site = metadata.sourceSite;
this.version = "1.0.0";
this.filters = metadata.filters;
@@ -70,7 +68,8 @@ class ReadwnPlugin implements Plugin.PluginBase {
novel.name = loadedCheerio("h1.novel-title").text();
novel.author = loadedCheerio("span[itemprop=author]").text();
novel.cover = this.site + loadedCheerio("figure.cover > img").attr("data-src");
novel.cover =
this.site + loadedCheerio("figure.cover > img").attr("data-src");
novel.summary = loadedCheerio(".summary")
.text()
@@ -84,7 +83,10 @@ class ReadwnPlugin implements Plugin.PluginBase {
loadedCheerio("div.header-stats > span").each(function () {
if (loadedCheerio(this).find("small").text() === "Status") {
novel.status = loadedCheerio(this).find("strong").text();
novel.status =
loadedCheerio(this).find("strong").text() === "Ongoing"
? NovelStatus.Ongoing
: NovelStatus.Completed;
}
});
@@ -97,17 +99,48 @@ class ReadwnPlugin implements Plugin.PluginBase {
);
const chapters: Plugin.ChapterItem[] = loadedCheerio(".chapter-list li")
.map((index, element) => {
.map((chapterIndex, element) => {
const name = loadedCheerio(element).find("a .chapter-title").text().trim();
const url = loadedCheerio(element).find("a").attr("href")?.trim();
const releaseTime = loadedCheerio(element).find("a .chapter-update").text().trim();
if (!name || !url) return null;
let releaseTime = loadedCheerio(element).find("a .chapter-update").text().trim();
if (releaseTime?.includes?.("ago")) {
const timeAgo = releaseTime.match(/\d+/)?.[0] || "0";
const timeAgoInt = parseInt(timeAgo, 10);
if (timeAgoInt) {
const dayJSDate = dayjs(); // today
if (
releaseTime.includes("hours ago") ||
releaseTime.includes("hour ago")
) {
dayJSDate.subtract(timeAgoInt, "hours"); // go back N hours
}
if (
releaseTime.includes("days ago") ||
releaseTime.includes("day ago")
) {
dayJSDate.subtract(timeAgoInt, "days"); // go back N days
}
if (
releaseTime.includes("months ago") ||
releaseTime.includes("month ago")
) {
dayJSDate.subtract(timeAgoInt, "months"); // go back N months
}
releaseTime = dayJSDate.format("LL");
}
}
return {
name,
releaseTime: parseMadaraDate(releaseTime),
url: this.site + url,
releaseTime: releaseTime,
chapterNumber: chapterIndex + 1,
};
})
.get()
@@ -122,8 +155,9 @@ class ReadwnPlugin implements Plugin.PluginBase {
for (let i = (lastChapterNo || chapters.length) + 1; i <= latestChapterNo; i++) {
chapters.push({
name: "Chapter " + i,
releaseTime: null,
url: novelUrl.replace(".html", "_" + i + ".html"),
releaseTime: null,
chapterNumber: i,
});
}
}
@@ -140,22 +174,17 @@ class ReadwnPlugin implements Plugin.PluginBase {
return chapterText;
}
async searchNovels(keyboard: string): Promise<Plugin.NovelItem[]> {
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
const result = await fetchApi(this.site + "/e/search/index.php", {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Referer: this.site + "/search.html",
Origin: this.site,
"user-agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36",
},
method: "POST",
body: JSON.stringify({
show: "title",
tempid: 1,
tbname: "news",
keyboard,
}),
body:
"show=title&tempid=1&tbname=news&keyboard=" +
encodeURIComponent(searchTerm),
}).then((res) => res.text());
const loadedCheerio = parseHTML(result);
+2 -2
View File
@@ -1552,7 +1552,7 @@
],
"type": "Picker"
},
"trash": {
"extra": {
"label": "Другое:",
"value": [],
"options": [
@@ -1612,7 +1612,7 @@
},
"adult": {
"label": "Возрастные ограничения:",
"value": "0",
"value": "1",
"options": [
{
"label": "Все",
+1 -1
View File
@@ -1,6 +1,6 @@
[
{
"id": "tl.rulate",
"id": "rulate",
"sourceSite": "https://tl.rulate.ru",
"sourceName": "Rulate",
"filters": {
+28 -68
View File
@@ -22,9 +22,8 @@ class RulatePlugin implements Plugin.PluginBase {
constructor(metadata: RulateMetadata) {
this.id = metadata.id;
this.name = metadata.sourceName + "[rulate]";
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
this.icon = `multisrc/rulate/icons/${iconFileName}.png`;
this.name = metadata.sourceName;
this.icon = `multisrc/rulate/icons/${metadata.id}.png`;
this.site = metadata.sourceSite;
this.version = "1.0.0";
this.filters = metadata.filters;
@@ -35,8 +34,7 @@ class RulatePlugin implements Plugin.PluginBase {
{ filters, showLatestNovels }: Plugin.PopularNovelsOptions,
): Promise<Plugin.NovelItem[]> {
const novels: Plugin.NovelItem[] = [];
const baseUrl = this.site;
let url = baseUrl + "/search?t=";
let url = this.site + "/search?t=";
url += "&cat=" + (filters?.cat?.value || "0");
url += "&s_lang=" + (filters?.s_lang?.value || "0");
url += "&t_lang=" + (filters?.t_lang?.value || "0");
@@ -45,39 +43,13 @@ class RulatePlugin implements Plugin.PluginBase {
url += "&atmosphere=" + (filters?.atmosphere?.value || "0");
url += "&adult=" + (filters?.adult?.value || "0");
if (filters?.genres?.value instanceof Array) {
url += filters.genres.value.map((i) => "&genres[]=" + i).join("");
}
//if (filters?.genres?.value?.exclude instanceof Array) {
// url += filters.genres.value.exclude
// ?.map((i) => "&genres_ex[]=" + i)
// .join("");
//}
if (filters?.tags?.value instanceof Array) {
url += filters.tags.value.map((i) => "&tags[]=" + i).join("");
}
//if (filters?.tags?.value?.exclude instanceof Array) {
// url += filters.tags.value.exclude
// ?.map((i) => "&tags_ex[]=" + i)
// .join("");
//}
if (filters?.fandoms?.value instanceof Array) {
url += filters.fandoms.value.map((i) => "&fandoms[]=" + i).join("");
}
// if (filters?.fandoms?.value?.exclude instanceof Array) {
// url += filters.fandoms.value.exclude
// .map((i) => "&fandoms_ex[]=" + i)
// .join("");
// }
if (filters?.trash?.value instanceof Array) {
url += filters.trash.value.map((i) => "&" + i + "=1").join("");
}
Object.entries(filters || {}).forEach(([type, { value }]) => {
if (value instanceof Array && value.length) {
url += "&" + value
.map((val) => (type == "extra" ? val + "=1" : type + "[]=" + val))
.join("&");
}
});
url += "&Book_page=" + pageNo;
@@ -86,21 +58,20 @@ class RulatePlugin implements Plugin.PluginBase {
loadedCheerio(
'ul[class="search-results"] > li:not([class="ad_type_catalog"])',
).each(function () {
loadedCheerio(this).find("p > a").text();
const name = loadedCheerio(this).find("p > a").text();
const cover = loadedCheerio(this).find("img").attr("src");
const url = loadedCheerio(this).find("p > a").attr("href");
).each((index, element) => {
loadedCheerio(element).find("p > a").text();
const name = loadedCheerio(element).find("p > a").text();
const cover = loadedCheerio(element).find("img").attr("src");
const url = loadedCheerio(element).find("p > a").attr("href");
if (!name || !url) return;
novels.push({ name, cover: baseUrl + cover, url: baseUrl + url });
novels.push({ name, cover: this.site + cover, url: this.site + url });
});
return novels;
}
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
const baseUrl = this.site;
const novel: Plugin.SourceNovel = {
url: novelUrl,
};
@@ -129,7 +100,7 @@ class RulatePlugin implements Plugin.PluginBase {
novel.name = novel.name.split("[")[0].trim();
}
novel.cover =
baseUrl + loadedCheerio('div[class="images"] > div img').attr("src");
this.site + loadedCheerio('div[class="images"] > div img').attr("src");
novel.summary =
loadedCheerio("#Info > div:nth-child(3), .book-description").text().trim();
novel.author = loadedCheerio(
@@ -172,27 +143,17 @@ class RulatePlugin implements Plugin.PluginBase {
}
const chapters: Plugin.ChapterItem[] = [];
loadedCheerio("table > tbody > tr.chapter_row").each(function () {
const chapterName = loadedCheerio(this)
.find('td[class="t"] > a')
.text()
.trim();
const releaseDate = loadedCheerio(this)
.find("td > span")
.attr("title")
?.trim();
const chapterUrl = loadedCheerio(this)
.find('td[class="t"] > a')
.attr("href");
loadedCheerio("table > tbody > tr.chapter_row").each((chapterIndex, element) => {
const chapterName = loadedCheerio(element).find('td[class="t"] > a').text().trim();
const releaseDate = loadedCheerio(element).find("td > span").attr("title")?.trim();
const chapterUrl = loadedCheerio(element).find('td[class="t"] > a').attr("href");
if (
!loadedCheerio(this).find('td > span[class="disabled"]').length &&
releaseDate
) {
if (!loadedCheerio(element).find('td > span[class="disabled"]').length && releaseDate) {
chapters.push({
name: chapterName,
url: this.site + chapterUrl,
releaseTime: releaseDate,
url: baseUrl + chapterUrl,
chapterNumber: chapterIndex + 1,
});
}
});
@@ -202,7 +163,6 @@ class RulatePlugin implements Plugin.PluginBase {
}
async parseChapter(chapterUrl: string): Promise<string> {
const baseUrl = this.site;
let result = await fetchApi(chapterUrl);
if (result.url.includes("mature?path=")) {
const formData = new FormData();
@@ -218,10 +178,10 @@ class RulatePlugin implements Plugin.PluginBase {
const body = await result.text();
const loadedCheerio = parseHTML(body);
loadedCheerio(".content-text img").each(function () {
if (!loadedCheerio(this).attr("src")?.startsWith("http")) {
const src = loadedCheerio(this).attr("src");
loadedCheerio(this).attr("src", baseUrl + src);
loadedCheerio(".content-text img").each((index, element) => {
if (!loadedCheerio(element).attr("src")?.startsWith("http")) {
const src = loadedCheerio(element).attr("src");
loadedCheerio(element).attr("src", this.site + src);
}
});
+7 -3
View File
@@ -25,7 +25,7 @@ class WPmangaStreamPlugin implements Plugin.PluginBase {
constructor(metadata: WPmangaStreamMetadata) {
this.id = metadata.id;
this.name = metadata.sourceName + "[wpmangastream]";
this.name = metadata.sourceName;
this.icon = `multisrc/wpmangastream/icons/${metadata.id}.png`;
this.site = metadata.sourceSite;
this.version = "1.0.0";
@@ -93,13 +93,17 @@ class WPmangaStreamPlugin implements Plugin.PluginBase {
novel.summary += loadedCheerio(p).text().trim() + "\\n\\n";
}
const totalChapters = loadedCheerio(".eplister li").length;
const chapters: Plugin.ChapterItem[] = loadedCheerio(".eplister li")
.map((index, element) => ({
.map((chapterIndex, element) => ({
name:
loadedCheerio(element).find(".epl-num").text() +
loadedCheerio(element).find(".epl-title").text(),
releaseTime: loadedCheerio(element).find(".epl-date").text().trim(),
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);