Filters Redesign (#658)
* Add XCheckboxFilter * Fix madara typo * Change the branch name in config * Add typing for madara popoularnovels filters * Add preview and refactor PluginWrapper * Add preview HTML sanitize and other improv. * Web improvements + sanitizeHTML * Add dark mode * Add git run less to compile less * Add less.js to remove the need for compiling less
This commit is contained in:
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"ar-mtl","sourceSite":"https://ar-mtl.club/","sourceName":"ArMTL","filters":[],"options":{"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"ar-mtl","sourceSite":"https://ar-mtl.club/","sourceName":"ArMTL","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"arnovel","sourceSite":"https://arnovel.me/","sourceName":"ArNovel","filters":[{"key":"sort","label":"الترتيب حسب","values":[{"label":"A-Z","value":"alphabet"},{"label":"الآخير","value":"latest"},{"label":"الأكثر مشاهدة","value":"views"},{"label":"التقييم","value":"rating"},{"label":"جديد","value":"new-manga"},{"label":"شائع","value":"trending"}],"inputType":1},{"key":"genres","label":"التصنيفات","values":[{"label":"أكشن","value":"%d8%a3%d9%83%d8%b4%d9%86"},{"label":"إتشي","value":"%d8%a5%d8%aa%d8%b4%d9%80%d9%8a"},{"label":"بالغ","value":"%d8%a8%d8%a7%d9%84%d8%ba"},{"label":"تاريخي","value":"%d8%aa%d8%a7%d8%b1%d9%8a%d8%ae%d9%8a"},{"label":"تراجدي","value":"%d8%aa%d8%b1%d8%a7%d8%ac%d8%af%d9%8a"},{"label":"جوسي","value":"%d8%ac%d9%88%d8%b3%d9%8a"},{"label":"حريم","value":"%d8%ad%d8%b1%d9%8a%d9%85"},{"label":"حياة مدرسية","value":"%d8%ad%d9%8a%d8%a7%d8%a9-%d9%85%d8%af%d8%b1%d8%b3%d9%8a%d8%a9"},{"label":"خارق لطبيعية","value":"%d8%ae%d8%a7%d8%b1%d9%82-%d9%84%d8%b7%d8%a8%d9%8a%d8%b9%d9%8a%d8%a9"},{"label":"خيال","value":"%d8%ae%d9%8a%d8%a7%d9%84"},{"label":"خيال علمي","value":"%d8%ae%d9%8a%d8%a7%d9%84-%d8%b9%d9%84%d9%85%d9%8a"},{"label":"دراما","value":"%d8%af%d8%b1%d8%a7%d9%85%d8%a7"},{"label":"راشد","value":"%d8%b1%d8%a7%d8%b4%d8%af"},{"label":"رعب","value":"%d8%b1%d8%b9%d8%a8"},{"label":"رومنسي","value":"%d8%b1%d9%88%d9%85%d9%86%d8%b3%d9%8a"},{"label":"رياضي","value":"%d8%b1%d9%8a%d8%a7%d8%b6%d9%8a"},{"label":"سينين","value":"%d8%b3%d9%8a%d9%86%d9%8a%d9%86"},{"label":"شريحة من الحياة","value":"%d8%b4%d8%b1%d9%8a%d8%ad%d8%a9-%d9%85%d9%86-%d8%a7%d9%84%d8%ad%d9%8a%d8%a7%d8%a9"},{"label":"شوجو","value":"%d8%b4%d9%88%d8%ac%d9%88"},{"label":"شونين","value":"%d8%b4%d9%88%d9%86%d9%8a%d9%86"},{"label":"غموض","value":"%d8%ba%d9%85%d9%88%d8%b6"},{"label":"فنون قتال","value":"%d9%81%d9%86%d9%88%d9%86-%d9%82%d8%aa%d8%a7%d9%84"},{"label":"كوميديا","value":"%d9%83%d9%88%d9%85%d9%8a%d8%af%d9%8a%d8%a7"},{"label":"مغامرات","value":"%d9%85%d8%ba%d8%a7%d9%85%d8%b1%d8%a7%d8%aa"},{"label":"منتهية","value":"%d9%85%d9%86%d8%aa%d9%87%d9%8a%d8%a9"},{"label":"ميكا","value":"%d9%85%d9%8a%d9%83%d8%a7"},{"label":"نفسي","value":"%d9%86%d9%81%d8%b3%d9%8a"}],"inputType":1}],"options":{"path":{"genres":"home/novel-genre"},"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"arnovel","sourceSite":"https://arnovel.me/","sourceName":"ArNovel","filters":{"sort":{"label":"الترتيب حسب","value":"","options":[{"label":"Default","value":""},{"label":"A-Z","value":"alphabet"},{"label":"الآخير","value":"latest"},{"label":"الأكثر مشاهدة","value":"views"},{"label":"التقييم","value":"rating"},{"label":"جديد","value":"new-manga"},{"label":"شائع","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"التصنيفات","value":"","options":[{"label":"NONE","value":""},{"label":"أكشن","value":"%d8%a3%d9%83%d8%b4%d9%86"},{"label":"إتشي","value":"%d8%a5%d8%aa%d8%b4%d9%80%d9%8a"},{"label":"بالغ","value":"%d8%a8%d8%a7%d9%84%d8%ba"},{"label":"تاريخي","value":"%d8%aa%d8%a7%d8%b1%d9%8a%d8%ae%d9%8a"},{"label":"تراجدي","value":"%d8%aa%d8%b1%d8%a7%d8%ac%d8%af%d9%8a"},{"label":"جوسي","value":"%d8%ac%d9%88%d8%b3%d9%8a"},{"label":"حريم","value":"%d8%ad%d8%b1%d9%8a%d9%85"},{"label":"حياة مدرسية","value":"%d8%ad%d9%8a%d8%a7%d8%a9-%d9%85%d8%af%d8%b1%d8%b3%d9%8a%d8%a9"},{"label":"خارق لطبيعية","value":"%d8%ae%d8%a7%d8%b1%d9%82-%d9%84%d8%b7%d8%a8%d9%8a%d8%b9%d9%8a%d8%a9"},{"label":"خيال","value":"%d8%ae%d9%8a%d8%a7%d9%84"},{"label":"خيال علمي","value":"%d8%ae%d9%8a%d8%a7%d9%84-%d8%b9%d9%84%d9%85%d9%8a"},{"label":"دراما","value":"%d8%af%d8%b1%d8%a7%d9%85%d8%a7"},{"label":"راشد","value":"%d8%b1%d8%a7%d8%b4%d8%af"},{"label":"رعب","value":"%d8%b1%d8%b9%d8%a8"},{"label":"رومنسي","value":"%d8%b1%d9%88%d9%85%d9%86%d8%b3%d9%8a"},{"label":"رياضي","value":"%d8%b1%d9%8a%d8%a7%d8%b6%d9%8a"},{"label":"سينين","value":"%d8%b3%d9%8a%d9%86%d9%8a%d9%86"},{"label":"شريحة من الحياة","value":"%d8%b4%d8%b1%d9%8a%d8%ad%d8%a9-%d9%85%d9%86-%d8%a7%d9%84%d8%ad%d9%8a%d8%a7%d8%a9"},{"label":"شوجو","value":"%d8%b4%d9%88%d8%ac%d9%88"},{"label":"شونين","value":"%d8%b4%d9%88%d9%86%d9%8a%d9%86"},{"label":"غموض","value":"%d8%ba%d9%85%d9%88%d8%b6"},{"label":"فنون قتال","value":"%d9%81%d9%86%d9%88%d9%86-%d9%82%d8%aa%d8%a7%d9%84"},{"label":"كوميديا","value":"%d9%83%d9%88%d9%85%d9%8a%d8%af%d9%8a%d8%a7"},{"label":"مغامرات","value":"%d9%85%d8%ba%d8%a7%d9%85%d8%b1%d8%a7%d8%aa"},{"label":"منتهية","value":"%d9%85%d9%86%d8%aa%d9%87%d9%8a%d8%a9"},{"label":"ميكا","value":"%d9%85%d9%8a%d9%83%d8%a7"},{"label":"نفسي","value":"%d9%86%d9%81%d8%b3%d9%8a"}],"type":FilterTypes.Picker}},"options":{"path":{"genres":"home/novel-genre"},"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"hizomanga","sourceSite":"https://hizomanga.com/","sourceName":"HizoManga","filters":[{"key":"sort","label":"ترتيب حسب","values":[{"label":"A-Z","value":"alphabet"},{"label":"New","value":"new-manga"},{"label":"الأحدث","value":"latest"},{"label":"الأكثر مشاهدة","value":"views"},{"label":"التقييم","value":"rating"},{"label":"الرائج","value":"trending"}],"inputType":1},{"key":"genres","label":"التصنيفات","values":[{"label":"آلات","value":"mechanisms"},{"label":"أكشن","value":"action"},{"label":"إثارة","value":"excitement"},{"label":"إيسكاي","value":"%d8%a5%d9%8a%d8%b3%d9%83%d8%a7%d9%8a"},{"label":"الحياة اليومية","value":"slice-of-life"},{"label":"الحياة مدرسية","value":"school-life"},{"label":"تاريخي","value":"historical"},{"label":"تراجيدي","value":"tragic"},{"label":"جريمة","value":"%d8%ac%d8%b1%d9%8a%d9%85%d8%a9"},{"label":"جندر بندر","value":"%d8%ac%d9%86%d8%af%d8%b1-%d8%a8%d9%86%d8%af%d8%b1"},{"label":"جوسي","value":"josei"},{"label":"حريم","value":"harem"},{"label":"خارق للطبيعة","value":"supernatural"},{"label":"خيال","value":"fantasy"},{"label":"خيال علمي","value":"sci-fi"},{"label":"دراما","value":"drama"},{"label":"دموي","value":"%d8%af%d9%85%d9%88%d9%8a"},{"label":"راشد","value":"mature"},{"label":"رعب","value":"horror"},{"label":"رومانسي","value":"romance"},{"label":"رياضة","value":"sports"},{"label":"زمنكاني","value":"my-time"},{"label":"زومبي","value":"%d8%b2%d9%88%d9%85%d8%a8%d9%8a"},{"label":"سينين","value":"seinen"},{"label":"شريحة من الحياة","value":"%d8%b4%d8%b1%d9%8a%d8%ad%d8%a9-%d9%85%d9%86-%d8%a7%d9%84%d8%ad%d9%8a%d8%a7%d8%a9"},{"label":"شوجو","value":"shoujo"},{"label":"شونين","value":"shounen"},{"label":"طبي","value":"%d8%b7%d8%a8%d9%8a"},{"label":"غموض","value":"ambiguity"},{"label":"فنون قتالية","value":"martial-arts"},{"label":"قوة خارقة","value":"superpower"},{"label":"كوميدي","value":"comedy"},{"label":"مغامرات","value":"adventure"},{"label":"نفسي","value":"psychological"}],"inputType":1}],"options":{"path":{"novels":"serie","novel":"serie","chapter":"serie","genres":"manga-genre"},"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"hizomanga","sourceSite":"https://hizomanga.com/","sourceName":"HizoManga","filters":{"sort":{"label":"ترتيب حسب","value":"","options":[{"label":"Default","value":""},{"label":"A-Z","value":"alphabet"},{"label":"New","value":"new-manga"},{"label":"الأحدث","value":"latest"},{"label":"الأكثر مشاهدة","value":"views"},{"label":"التقييم","value":"rating"},{"label":"الرائج","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"التصنيفات","value":"","options":[{"label":"NONE","value":""},{"label":"آلات","value":"mechanisms"},{"label":"أكشن","value":"action"},{"label":"إثارة","value":"excitement"},{"label":"إيسكاي","value":"%d8%a5%d9%8a%d8%b3%d9%83%d8%a7%d9%8a"},{"label":"الحياة اليومية","value":"slice-of-life"},{"label":"الحياة مدرسية","value":"school-life"},{"label":"تاريخي","value":"historical"},{"label":"تراجيدي","value":"tragic"},{"label":"جريمة","value":"%d8%ac%d8%b1%d9%8a%d9%85%d8%a9"},{"label":"جندر بندر","value":"%d8%ac%d9%86%d8%af%d8%b1-%d8%a8%d9%86%d8%af%d8%b1"},{"label":"جوسي","value":"josei"},{"label":"حريم","value":"harem"},{"label":"خارق للطبيعة","value":"supernatural"},{"label":"خيال","value":"fantasy"},{"label":"خيال علمي","value":"sci-fi"},{"label":"دراما","value":"drama"},{"label":"دموي","value":"%d8%af%d9%85%d9%88%d9%8a"},{"label":"راشد","value":"mature"},{"label":"رعب","value":"horror"},{"label":"رومانسي","value":"romance"},{"label":"رياضة","value":"sports"},{"label":"زمنكاني","value":"my-time"},{"label":"زومبي","value":"%d8%b2%d9%88%d9%85%d8%a8%d9%8a"},{"label":"سينين","value":"seinen"},{"label":"شريحة من الحياة","value":"%d8%b4%d8%b1%d9%8a%d8%ad%d8%a9-%d9%85%d9%86-%d8%a7%d9%84%d8%ad%d9%8a%d8%a7%d8%a9"},{"label":"شوجو","value":"shoujo"},{"label":"شونين","value":"shounen"},{"label":"طبي","value":"%d8%b7%d8%a8%d9%8a"},{"label":"غموض","value":"ambiguity"},{"label":"فنون قتالية","value":"martial-arts"},{"label":"قوة خارقة","value":"superpower"},{"label":"كوميدي","value":"comedy"},{"label":"مغامرات","value":"adventure"},{"label":"نفسي","value":"psychological"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"serie","novel":"serie","chapter":"serie","genres":"manga-genre"},"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"novel4up","sourceSite":"https://novel4up.com/","sourceName":"Novel4Up","filters":[{"key":"sort","label":"ترتيب حسب:","values":[{"label":"أ-ي","value":"alphabet"},{"label":"الأحدث","value":"latest"},{"label":"الأكثر مشاهدة","value":"views"},{"label":"التقييم","value":"rating"},{"label":"الجديد","value":"new-manga"},{"label":"الشائع","value":"trending"}],"inputType":1},{"key":"genres","label":"التصنيفات","values":[{"label":"أكشن","value":"action"},{"label":"الخارق للطبيعة","value":"supernatural"},{"label":"تاريخي","value":"historical"},{"label":"تحقيق","value":"detective"},{"label":"تراجيديا","value":"tragedy"},{"label":"حريم","value":"harem"},{"label":"حياة مدرسية","value":"school-life"},{"label":"خيال علمي","value":"sci-fi"},{"label":"دراما","value":"drama"},{"label":"رعب","value":"horror"},{"label":"رومانسي","value":"romance"},{"label":"رياضة","value":"sports"},{"label":"سحر","value":"magic"},{"label":"شريحة من الحياة","value":"slice-of-life"},{"label":"شوانهوا","value":"xuanhuan"},{"label":"شوجو","value":"shoujo"},{"label":"شونين","value":"shounen"},{"label":"غموض","value":"mystery"},{"label":"فانتازيا","value":"fantasy"},{"label":"فنون قتال","value":"martial-arts"},{"label":"كوميديا","value":"comedy"},{"label":"مغامرة","value":"adventure"},{"label":"ميكا","value":"mecha"},{"label":"نفسي","value":"psychological"},{"label":"ون شوت","value":"one-shot"},{"label":"ووشيا","value":"wuxia"}],"inputType":1}],"options":{"lang":"Arabic"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novel4up","sourceSite":"https://novel4up.com/","sourceName":"Novel4Up","filters":{"sort":{"label":"ترتيب حسب:","value":"","options":[{"label":"Default","value":""},{"label":"أ-ي","value":"alphabet"},{"label":"الأحدث","value":"latest"},{"label":"الأكثر مشاهدة","value":"views"},{"label":"التقييم","value":"rating"},{"label":"الجديد","value":"new-manga"},{"label":"الشائع","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"التصنيفات","value":"","options":[{"label":"NONE","value":""},{"label":"أكشن","value":"action"},{"label":"الخارق للطبيعة","value":"supernatural"},{"label":"تاريخي","value":"historical"},{"label":"تحقيق","value":"detective"},{"label":"تراجيديا","value":"tragedy"},{"label":"حريم","value":"harem"},{"label":"حياة مدرسية","value":"school-life"},{"label":"خيال علمي","value":"sci-fi"},{"label":"دراما","value":"drama"},{"label":"رعب","value":"horror"},{"label":"رومانسي","value":"romance"},{"label":"رياضة","value":"sports"},{"label":"سحر","value":"magic"},{"label":"شريحة من الحياة","value":"slice-of-life"},{"label":"شوانهوا","value":"xuanhuan"},{"label":"شوجو","value":"shoujo"},{"label":"شونين","value":"shounen"},{"label":"غموض","value":"mystery"},{"label":"فانتازيا","value":"fantasy"},{"label":"فنون قتال","value":"martial-arts"},{"label":"كوميديا","value":"comedy"},{"label":"مغامرة","value":"adventure"},{"label":"ميكا","value":"mecha"},{"label":"نفسي","value":"psychological"},{"label":"ون شوت","value":"one-shot"},{"label":"ووشيا","value":"wuxia"}],"type":FilterTypes.Picker}},"options":{"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"riwyat","sourceSite":"https://riwyat.com/","sourceName":"Riwyat","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"أكشن","value":"%d8%a3%d9%83%d8%b4%d9%86"},{"label":"أيتشي","value":"%d8%a3%d9%8a%d8%aa%d8%b4%d9%8a"},{"label":"استراتجي","value":"%d8%a7%d8%b3%d8%aa%d8%b1%d8%a7%d8%aa%d8%ac%d9%8a"},{"label":"العصر الحديث","value":"%d8%a7%d9%84%d8%b9%d8%b5%d8%b1-%d8%a7%d9%84%d8%ad%d8%af%d9%8a%d8%ab"},{"label":"انتقام","value":"%d8%a7%d9%86%d8%aa%d9%82%d8%a7%d9%85"},{"label":"بالغ","value":"%d8%a8%d8%a7%d9%84%d8%ba"},{"label":"بناء مملكة","value":"%d8%a8%d9%86%d8%a7%d8%a1-%d9%85%d9%85%d9%84%d9%83%d8%a9"},{"label":"بوليسي","value":"%d8%a8%d9%88%d9%84%d9%8a%d8%b3%d9%8a"},{"label":"تاريخي","value":"%d8%aa%d8%a7%d8%b1%d9%8a%d8%ae%d9%8a"},{"label":"جوسي","value":"%d8%ac%d9%88%d8%b3%d9%8a"},{"label":"حريم","value":"%d8%ad%d8%b1%d9%8a%d9%85"},{"label":"حياة يومية","value":"%d8%ad%d9%8a%d8%a7%d8%a9-%d9%8a%d9%88%d9%85%d9%8a%d8%a9"},{"label":"خيال","value":"%d8%ae%d9%8a%d8%a7%d9%84"},{"label":"خيال علمي","value":"%d8%ae%d9%8a%d8%a7%d9%84-%d8%b9%d9%84%d9%85%d9%8a"},{"label":"دراما","value":"%d8%af%d8%b1%d8%a7%d9%85%d8%a7"},{"label":"رعب","value":"%d8%b1%d8%b9%d8%a8"},{"label":"رومانسية","value":"%d8%b1%d9%88%d9%85%d8%a7%d9%86%d8%b3%d9%8a%d8%a9"},{"label":"رياضي","value":"%d8%b1%d9%8a%d8%a7%d8%b6%d9%8a"},{"label":"زيانشيا","value":"xianxia"},{"label":"سنين","value":"%d8%b3%d9%86%d9%8a%d9%86"},{"label":"شريحة حياة","value":"%d8%b4%d8%b1%d9%8a%d8%ad%d8%a9-%d8%ad%d9%8a%d8%a7%d8%a9"},{"label":"شوانهوان","value":"xuanhuan"},{"label":"شوجو","value":"%d8%b4%d9%88%d8%ac%d9%88"},{"label":"شونين","value":"%d8%b4%d9%88%d9%86%d9%8a%d9%86"},{"label":"شيانشيا","value":"%d8%b4%d9%8a%d8%a7%d9%86%d8%b4%d9%8a%d8%a7"},{"label":"عسكري","value":"%d8%b9%d8%b3%d9%83%d8%b1%d9%8a"},{"label":"غموض","value":"%d8%ba%d9%85%d9%88%d8%b6"},{"label":"فانتازيا","value":"%d9%81%d8%a7%d9%86%d8%aa%d8%a7%d8%b2%d9%8a%d8%a7"},{"label":"فنون قتالية","value":"%d9%81%d9%86%d9%88%d9%86-%d9%82%d8%aa%d8%a7%d9%84%d9%8a%d8%a9"},{"label":"قوى خارقة","value":"%d9%82%d9%88%d9%89-%d8%ae%d8%a7%d8%b1%d9%82%d8%a9"},{"label":"كوميديا","value":"%d9%83%d9%88%d9%85%d9%8a%d8%af%d9%8a%d8%a7"},{"label":"كوميك","value":"%d9%83%d9%88%d9%85%d9%8a%d9%83"},{"label":"للكبار","value":"%d9%84%d9%84%d9%83%d8%a8%d8%a7%d8%b1"},{"label":"مأساة","value":"%d9%85%d8%a3%d8%b3%d8%a7%d8%a9"},{"label":"مانجا","value":"%d9%85%d8%a7%d9%86%d8%ac%d8%a7"},{"label":"مانها","value":"%d9%85%d8%a7%d9%86%d9%87%d8%a7"},{"label":"مانهوا","value":"%d9%85%d8%a7%d9%86%d9%87%d9%88%d8%a7"},{"label":"مدرسي","value":"%d9%85%d8%af%d8%b1%d8%b3%d9%8a"},{"label":"مصاصي دماء","value":"%d9%85%d8%b5%d8%a7%d8%b5%d9%8a-%d8%af%d9%85%d8%a7%d8%a1"},{"label":"مغامرة","value":"%d9%85%d8%ba%d8%a7%d9%85%d8%b1%d8%a9"},{"label":"مكتملة","value":"%d9%85%d9%83%d8%aa%d9%85%d9%84%d8%a9"},{"label":"نفسي","value":"%d9%86%d9%81%d8%b3%d9%8a"},{"label":"نهاية العالم","value":"%d9%86%d9%87%d8%a7%d9%8a%d8%a9-%d8%a7%d9%84%d8%b9%d8%a7%d9%84%d9%85"},{"label":"واب تون","value":"%d9%88%d8%a7%d8%a8-%d8%aa%d9%88%d9%86"},{"label":"وان شوت","value":"%d9%88%d8%a7%d9%86-%d8%b4%d9%88%d8%aa"}],"inputType":1}],"options":{"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"riwyat","sourceSite":"https://riwyat.com/","sourceName":"Riwyat","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"أكشن","value":"%d8%a3%d9%83%d8%b4%d9%86"},{"label":"أيتشي","value":"%d8%a3%d9%8a%d8%aa%d8%b4%d9%8a"},{"label":"استراتجي","value":"%d8%a7%d8%b3%d8%aa%d8%b1%d8%a7%d8%aa%d8%ac%d9%8a"},{"label":"العصر الحديث","value":"%d8%a7%d9%84%d8%b9%d8%b5%d8%b1-%d8%a7%d9%84%d8%ad%d8%af%d9%8a%d8%ab"},{"label":"انتقام","value":"%d8%a7%d9%86%d8%aa%d9%82%d8%a7%d9%85"},{"label":"بالغ","value":"%d8%a8%d8%a7%d9%84%d8%ba"},{"label":"بناء مملكة","value":"%d8%a8%d9%86%d8%a7%d8%a1-%d9%85%d9%85%d9%84%d9%83%d8%a9"},{"label":"بوليسي","value":"%d8%a8%d9%88%d9%84%d9%8a%d8%b3%d9%8a"},{"label":"تاريخي","value":"%d8%aa%d8%a7%d8%b1%d9%8a%d8%ae%d9%8a"},{"label":"جوسي","value":"%d8%ac%d9%88%d8%b3%d9%8a"},{"label":"حريم","value":"%d8%ad%d8%b1%d9%8a%d9%85"},{"label":"حياة يومية","value":"%d8%ad%d9%8a%d8%a7%d8%a9-%d9%8a%d9%88%d9%85%d9%8a%d8%a9"},{"label":"خيال","value":"%d8%ae%d9%8a%d8%a7%d9%84"},{"label":"خيال علمي","value":"%d8%ae%d9%8a%d8%a7%d9%84-%d8%b9%d9%84%d9%85%d9%8a"},{"label":"دراما","value":"%d8%af%d8%b1%d8%a7%d9%85%d8%a7"},{"label":"رعب","value":"%d8%b1%d8%b9%d8%a8"},{"label":"رومانسية","value":"%d8%b1%d9%88%d9%85%d8%a7%d9%86%d8%b3%d9%8a%d8%a9"},{"label":"رياضي","value":"%d8%b1%d9%8a%d8%a7%d8%b6%d9%8a"},{"label":"زيانشيا","value":"xianxia"},{"label":"سنين","value":"%d8%b3%d9%86%d9%8a%d9%86"},{"label":"شريحة حياة","value":"%d8%b4%d8%b1%d9%8a%d8%ad%d8%a9-%d8%ad%d9%8a%d8%a7%d8%a9"},{"label":"شوانهوان","value":"xuanhuan"},{"label":"شوجو","value":"%d8%b4%d9%88%d8%ac%d9%88"},{"label":"شونين","value":"%d8%b4%d9%88%d9%86%d9%8a%d9%86"},{"label":"شيانشيا","value":"%d8%b4%d9%8a%d8%a7%d9%86%d8%b4%d9%8a%d8%a7"},{"label":"عسكري","value":"%d8%b9%d8%b3%d9%83%d8%b1%d9%8a"},{"label":"غموض","value":"%d8%ba%d9%85%d9%88%d8%b6"},{"label":"فانتازيا","value":"%d9%81%d8%a7%d9%86%d8%aa%d8%a7%d8%b2%d9%8a%d8%a7"},{"label":"فنون قتالية","value":"%d9%81%d9%86%d9%88%d9%86-%d9%82%d8%aa%d8%a7%d9%84%d9%8a%d8%a9"},{"label":"قوى خارقة","value":"%d9%82%d9%88%d9%89-%d8%ae%d8%a7%d8%b1%d9%82%d8%a9"},{"label":"كوميديا","value":"%d9%83%d9%88%d9%85%d9%8a%d8%af%d9%8a%d8%a7"},{"label":"كوميك","value":"%d9%83%d9%88%d9%85%d9%8a%d9%83"},{"label":"للكبار","value":"%d9%84%d9%84%d9%83%d8%a8%d8%a7%d8%b1"},{"label":"مأساة","value":"%d9%85%d8%a3%d8%b3%d8%a7%d8%a9"},{"label":"مانجا","value":"%d9%85%d8%a7%d9%86%d8%ac%d8%a7"},{"label":"مانها","value":"%d9%85%d8%a7%d9%86%d9%87%d8%a7"},{"label":"مانهوا","value":"%d9%85%d8%a7%d9%86%d9%87%d9%88%d8%a7"},{"label":"مدرسي","value":"%d9%85%d8%af%d8%b1%d8%b3%d9%8a"},{"label":"مصاصي دماء","value":"%d9%85%d8%b5%d8%a7%d8%b5%d9%8a-%d8%af%d9%85%d8%a7%d8%a1"},{"label":"مغامرة","value":"%d9%85%d8%ba%d8%a7%d9%85%d8%b1%d8%a9"},{"label":"مكتملة","value":"%d9%85%d9%83%d8%aa%d9%85%d9%84%d8%a9"},{"label":"نفسي","value":"%d9%86%d9%81%d8%b3%d9%8a"},{"label":"نهاية العالم","value":"%d9%86%d9%87%d8%a7%d9%8a%d8%a9-%d8%a7%d9%84%d8%b9%d8%a7%d9%84%d9%85"},{"label":"واب تون","value":"%d9%88%d8%a7%d8%a8-%d8%aa%d9%88%d9%86"},{"label":"وان شوت","value":"%d9%88%d8%a7%d9%86-%d8%b4%d9%88%d8%aa"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"teamxnovel","sourceSite":"https://teamxnovel.com/","sourceName":"TeamXNovel","filters":[],"options":{"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"teamxnovel","sourceSite":"https://teamxnovel.com/","sourceName":"TeamXNovel","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
+97
-94
@@ -1,35 +1,35 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
|
||||
class KolNovel implements Plugin.PluginBase {
|
||||
id = "kolnovel";
|
||||
name = "KolNovel";
|
||||
icon = "multisrc/wpmangastream/icons/kolnovel.png"
|
||||
icon = "multisrc/wpmangastream/icons/kolnovel.png";
|
||||
site = "https://kolnovel.lol/";
|
||||
version = "1.0.0";
|
||||
userAgent = "";
|
||||
cookieString = "";
|
||||
async popularNovels(pageNo: number, {filters}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}series/?page=${pageNo}`;
|
||||
|
||||
if (filters) {
|
||||
if (Array.isArray(filters.genres) && filters.genres.length) {
|
||||
link += filters.genres.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
if (filters.genres.value.length)
|
||||
link += filters.genres.value.map((i) => `&genre[]=${i}`).join("");
|
||||
if (filters.type.value.length)
|
||||
link += filters.type.value.map((i) => `&lang[]=${i}`).join("");
|
||||
|
||||
if (Array.isArray(filters.type) && filters.type.length)
|
||||
link += filters.type.map((i) => `&lang[]=${i}`).join("");
|
||||
}
|
||||
link += "&status=" + (filters?.status ? filters.status : "");
|
||||
|
||||
link += "&order=" + (filters?.order ? filters.order : "popular");
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const body = await fetchApi(link, {headers}).then((result) =>
|
||||
const body = await fetchApi(link, { headers }).then((result) =>
|
||||
result.text()
|
||||
);
|
||||
|
||||
@@ -59,10 +59,10 @@ class KolNovel implements Plugin.PluginBase {
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetch(url, {headers});
|
||||
const result = await fetch(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
@@ -136,30 +136,33 @@ class KolNovel implements Plugin.PluginBase {
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetch(chapterUrl, {headers});
|
||||
const result = await fetch(chapterUrl, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.epcontent > div, i').remove();
|
||||
let ignore = loadedCheerio('article > style').text().trim().split(',');
|
||||
loadedCheerio(".epcontent > div, i").remove();
|
||||
let ignore = loadedCheerio("article > style").text().trim().split(",");
|
||||
ignore.push(...(ignore.pop()?.match(/^\.\w+/) || []));
|
||||
ignore.map(tag => loadedCheerio(`p${tag}`).remove());
|
||||
ignore.map((tag) => loadedCheerio(`p${tag}`).remove());
|
||||
|
||||
let chapterText = loadedCheerio(".epcontent").html() || "";
|
||||
|
||||
let chapterText = loadedCheerio('.epcontent').html() || "";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?s=${searchTerm}`;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -186,140 +189,140 @@ class KolNovel implements Plugin.PluginBase {
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url);
|
||||
}
|
||||
filters = [
|
||||
{
|
||||
key: "order",
|
||||
filters = {
|
||||
order: {
|
||||
label: "ترتيب حسب",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "الإعداد الأولي", value: "" },
|
||||
|
||||
|
||||
{ label: "A-Z", value: "title" },
|
||||
|
||||
|
||||
{ label: "Z-A", value: "titlereverse" },
|
||||
|
||||
|
||||
{ label: "أخر التحديثات", value: "update" },
|
||||
|
||||
|
||||
{ label: "أخر ما تم إضافته", value: "latest" },
|
||||
|
||||
|
||||
{ label: "الرائجة", value: "popular" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
value: "",
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
status: {
|
||||
value: "",
|
||||
label: "الحالة",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "All", value: "" },
|
||||
|
||||
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
|
||||
|
||||
{ label: "Hiatus", value: "hiatus" },
|
||||
|
||||
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
type: {
|
||||
value: [],
|
||||
label: "النوع",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "إنجليزية", value: "english" },
|
||||
|
||||
|
||||
{ label: "روايةلايت", value: "light-novel" },
|
||||
|
||||
|
||||
{ label: "روايةويب", value: "web-novel" },
|
||||
|
||||
|
||||
{ label: "صينية", value: "chinese" },
|
||||
|
||||
|
||||
{ label: "عربية", value: "arabic" },
|
||||
|
||||
|
||||
{ label: "كورية", value: "korean" },
|
||||
|
||||
|
||||
{ label: "يابانية", value: "japanese" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
genres: {
|
||||
value: [],
|
||||
label: "تصنيف",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "Wuxia", value: "wuxia" },
|
||||
|
||||
|
||||
{ label: "Xianxia", value: "xianxia" },
|
||||
|
||||
|
||||
{ label: "XUANHUAN", value: "xuanhuan" },
|
||||
|
||||
|
||||
{ label: "أكشن", value: "action" },
|
||||
|
||||
|
||||
{ label: "إثارة", value: "excitement" },
|
||||
|
||||
|
||||
{ label: "إنتقالالىعالمأخر", value: "isekai" },
|
||||
|
||||
|
||||
{ label: "إيتشي", value: "etchi" },
|
||||
|
||||
|
||||
{ label: "الخيالالعلمي", value: "sci-fi" },
|
||||
|
||||
|
||||
{ label: "بوليسي", value: "policy" },
|
||||
|
||||
|
||||
{ label: "تاريخي", value: "historical" },
|
||||
|
||||
|
||||
{ label: "تحقيقات", value: "%d8%aa%d8%ad%d9%82%d9%8a%d9%82" },
|
||||
|
||||
|
||||
{ label: "تقمصشخصيات", value: "rpg" },
|
||||
|
||||
|
||||
{ label: "جريمة", value: "crime" },
|
||||
|
||||
|
||||
{ label: "جوسى", value: "josei" },
|
||||
|
||||
|
||||
{ label: "حريم", value: "harem" },
|
||||
|
||||
|
||||
{ label: "حياةمدرسية", value: "school-life" },
|
||||
|
||||
|
||||
{ label: "خيالي(فانتازيا)", value: "fantasy" },
|
||||
|
||||
|
||||
{ label: "دراما", value: "drama" },
|
||||
|
||||
|
||||
{ label: "رعب", value: "horror" },
|
||||
|
||||
|
||||
{ label: "رومانسي", value: "romantic" },
|
||||
|
||||
|
||||
{ label: "سحر", value: "magic" },
|
||||
|
||||
|
||||
{ label: "سينن", value: "senen" },
|
||||
|
||||
|
||||
{ label: "شريحةمنالحياة", value: "slice-of-life" },
|
||||
|
||||
|
||||
{ label: "شوجو", value: "shojo" },
|
||||
|
||||
|
||||
{ label: "شونين", value: "shonen" },
|
||||
|
||||
|
||||
{ label: "طبي", value: "medical" },
|
||||
|
||||
|
||||
{ label: "ظواهرخارقةللطبيعة", value: "supernatural" },
|
||||
|
||||
|
||||
{ label: "غموض", value: "mysteries" },
|
||||
|
||||
|
||||
{ label: "فنونالقتال", value: "martial-arts" },
|
||||
|
||||
|
||||
{ label: "قوىخارقة", value: "superpower" },
|
||||
|
||||
|
||||
{ label: "كوميدي", value: "comedy" },
|
||||
|
||||
|
||||
{ label: "مأساوي", value: "tragedy" },
|
||||
|
||||
|
||||
{ label: "مابعدالكارثة", value: "after-the-disaster" },
|
||||
|
||||
|
||||
{ label: "مغامرة", value: "adventure" },
|
||||
|
||||
|
||||
{ label: "ميكا", value: "mechanical" },
|
||||
|
||||
|
||||
{ label: "ناضج", value: "mature" },
|
||||
|
||||
|
||||
{ label: "نفسي", value: "psychological" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
];
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new KolNovel();
|
||||
export default new KolNovel();
|
||||
|
||||
+311
-283
@@ -1,6 +1,6 @@
|
||||
import { CheerioAPI, load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { showToast } from "@libs/showToast";
|
||||
|
||||
@@ -12,18 +12,21 @@ class Linovelib implements Plugin.PluginBase {
|
||||
version = "1.0.0";
|
||||
userAgent = "";
|
||||
cookieString = "";
|
||||
async popularNovels(pageNo: number, {filters}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}/top/`;
|
||||
|
||||
link += (filters?.sort ? filters.sort : "monthvisit");
|
||||
link += filters.sort;
|
||||
|
||||
link += `/${pageNo}.html`;
|
||||
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const body = await fetchApi(link, {headers}).then((result) =>
|
||||
const body = await fetchApi(link, { headers }).then((result) =>
|
||||
result.text()
|
||||
);
|
||||
|
||||
@@ -32,12 +35,12 @@ class Linovelib implements Plugin.PluginBase {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio(".module-rank-booklist .book-layout").each((i, el) => {
|
||||
let url = loadedCheerio(el).attr('href');
|
||||
let url = loadedCheerio(el).attr("href");
|
||||
|
||||
const novelName = loadedCheerio(el).find('.book-title').text();
|
||||
const novelName = loadedCheerio(el).find(".book-title").text();
|
||||
const novelCover = loadedCheerio(el)
|
||||
.find('img.book-cover')
|
||||
.attr('data-src');
|
||||
.find("img.book-cover")
|
||||
.attr("data-src");
|
||||
const novelUrl = this.site + url;
|
||||
|
||||
if (!url) return;
|
||||
@@ -52,15 +55,15 @@ class Linovelib implements Plugin.PluginBase {
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
@@ -70,21 +73,23 @@ class Linovelib implements Plugin.PluginBase {
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('#bookDetailWrapper .book-title').text();
|
||||
novel.name = loadedCheerio("#bookDetailWrapper .book-title").text();
|
||||
|
||||
novel.cover = loadedCheerio('#bookDetailWrapper img.book-cover').attr(
|
||||
'src',
|
||||
novel.cover = loadedCheerio("#bookDetailWrapper img.book-cover").attr(
|
||||
"src"
|
||||
);
|
||||
|
||||
novel.summary = loadedCheerio('#bookSummary content').text();
|
||||
novel.summary = loadedCheerio("#bookSummary content").text();
|
||||
|
||||
novel.author = loadedCheerio('#bookDetailWrapper .book-rand-a a').text();
|
||||
novel.author = loadedCheerio(
|
||||
"#bookDetailWrapper .book-rand-a a"
|
||||
).text();
|
||||
|
||||
// TODO: Need some regex and dirty selector to get it
|
||||
// Need to look into how to translate that message
|
||||
novel.status = undefined;
|
||||
|
||||
novel.genres = loadedCheerio('.tag-small.red')
|
||||
novel.genres = loadedCheerio(".tag-small.red")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
@@ -96,37 +101,38 @@ class Linovelib implements Plugin.PluginBase {
|
||||
const idPattern = /\/(\d+)\.html/;
|
||||
const novelId = url.match(idPattern)?.[1];
|
||||
|
||||
const chaptersUrl = this.site + loadedCheerio('#btnReadBook').attr('href');
|
||||
const chaptersResult = await fetchApi(chaptersUrl, {headers});
|
||||
const chaptersUrl =
|
||||
this.site + loadedCheerio("#btnReadBook").attr("href");
|
||||
const chaptersResult = await fetchApi(chaptersUrl, { headers });
|
||||
const chaptersBody = await chaptersResult.text();
|
||||
|
||||
const chaptersLoadedCheerio = parseHTML(chaptersBody);
|
||||
|
||||
let volumeName:string, chapterId:number;
|
||||
let volumeName: string, chapterId: number;
|
||||
|
||||
chaptersLoadedCheerio('#volumes .chapter-li').each((i, el) => {
|
||||
if (chaptersLoadedCheerio(el).hasClass('chapter-bar')) {
|
||||
volumeName = chaptersLoadedCheerio(el).text();
|
||||
} else {
|
||||
const urlPart = chaptersLoadedCheerio(el)
|
||||
.find('.chapter-li-a')
|
||||
.attr('href');
|
||||
const chapterIdMatch = urlPart?.match(idPattern);
|
||||
|
||||
// Sometimes the href attribute does not contain the url, but javascript:cid(0).
|
||||
// Increment the previous chapter ID should result in the right URL
|
||||
if (chapterIdMatch) {
|
||||
chapterId = +chapterIdMatch[1];
|
||||
chaptersLoadedCheerio("#volumes .chapter-li").each((i, el) => {
|
||||
if (chaptersLoadedCheerio(el).hasClass("chapter-bar")) {
|
||||
volumeName = chaptersLoadedCheerio(el).text();
|
||||
} else {
|
||||
chapterId++;
|
||||
}}
|
||||
const urlPart = chaptersLoadedCheerio(el)
|
||||
.find(".chapter-li-a")
|
||||
.attr("href");
|
||||
const chapterIdMatch = urlPart?.match(idPattern);
|
||||
|
||||
// Sometimes the href attribute does not contain the url, but javascript:cid(0).
|
||||
// Increment the previous chapter ID should result in the right URL
|
||||
if (chapterIdMatch) {
|
||||
chapterId = +chapterIdMatch[1];
|
||||
} else {
|
||||
chapterId++;
|
||||
}
|
||||
}
|
||||
|
||||
const chapterUrl = `${this.site}/novel/${novelId}/${chapterId}.html`;
|
||||
const chapterName =
|
||||
volumeName +
|
||||
' — ' +
|
||||
chaptersLoadedCheerio(el).find('.chapter-index').text().trim();
|
||||
" — " +
|
||||
chaptersLoadedCheerio(el).find(".chapter-index").text().trim();
|
||||
const releaseDate = null;
|
||||
|
||||
if (!chapterId) return;
|
||||
@@ -138,24 +144,28 @@ class Linovelib implements Plugin.PluginBase {
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter;
|
||||
novel.chapters = chapter;
|
||||
|
||||
return novel;
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
let chapterName, chapterText = "", hasNextPage, pageHasNextPage, pageText = "";
|
||||
let chapterName,
|
||||
chapterText = "",
|
||||
hasNextPage,
|
||||
pageHasNextPage,
|
||||
pageText = "";
|
||||
let pageNumber = 1;
|
||||
|
||||
/*
|
||||
* TODO: Maybe there are other ways to get the translation table
|
||||
* It is embed and encrypted inside readtool.js
|
||||
* UPDATE: Decrypted, see skillgg
|
||||
*/
|
||||
* TODO: Maybe there are other ways to get the translation table
|
||||
* It is embed and encrypted inside readtool.js
|
||||
* UPDATE: Decrypted, see skillgg
|
||||
*/
|
||||
// const mapping_dict = {
|
||||
// '“': '「',
|
||||
// '’': '』',
|
||||
@@ -263,297 +273,315 @@ class Linovelib implements Plugin.PluginBase {
|
||||
// '': '裸',
|
||||
// };
|
||||
const skillgg: Record<string, string> = {
|
||||
'\u201c': '\u300c',
|
||||
'\u201d': '\u300d',
|
||||
'\u2018': '\u300e',
|
||||
'\u2019': '\u300f',
|
||||
'\ue82c': '\u7684',
|
||||
'\ue852': '\u4e00',
|
||||
'\ue82d': '\u662f',
|
||||
'\ue819': '\u4e86',
|
||||
'\ue856': '\u6211',
|
||||
'\ue857': '\u4e0d',
|
||||
'\ue816': '\u4eba',
|
||||
'\ue83c': '\u5728',
|
||||
'\ue830': '\u4ed6',
|
||||
'\ue82e': '\u6709',
|
||||
'\ue836': '\u8fd9',
|
||||
'\ue859': '\u4e2a',
|
||||
'\ue80a': '\u4e0a',
|
||||
'\ue855': '\u4eec',
|
||||
'\ue842': '\u6765',
|
||||
'\ue858': '\u5230',
|
||||
'\ue80b': '\u65f6',
|
||||
'\ue81f': '\u5927',
|
||||
'\ue84a': '\u5730',
|
||||
'\ue853': '\u4e3a',
|
||||
'\ue81e': '\u5b50',
|
||||
'\ue822': '\u4e2d',
|
||||
'\ue813': '\u4f60',
|
||||
'\ue85b': '\u8bf4',
|
||||
'\ue807': '\u751f',
|
||||
'\ue818': '\u56fd',
|
||||
'\ue810': '\u5e74',
|
||||
'\ue812': '\u7740',
|
||||
'\ue851': '\u5c31',
|
||||
'\ue801': '\u90a3',
|
||||
'\ue80c': '\u548c',
|
||||
'\ue815': '\u8981',
|
||||
'\ue84c': '\u5979',
|
||||
'\ue840': '\u51fa',
|
||||
'\ue848': '\u4e5f',
|
||||
'\ue835': '\u5f97',
|
||||
'\ue800': '\u91cc',
|
||||
'\ue826': '\u540e',
|
||||
'\ue863': '\u81ea',
|
||||
'\ue861': '\u4ee5',
|
||||
'\ue854': '\u4f1a',
|
||||
'\ue827': '\u5bb6',
|
||||
'\ue83b': '\u53ef',
|
||||
'\ue85d': '\u4e0b',
|
||||
'\ue84d': '\u800c',
|
||||
'\ue862': '\u8fc7',
|
||||
'\ue81c': '\u5929',
|
||||
'\ue81d': '\u53bb',
|
||||
'\ue860': '\u80fd',
|
||||
'\ue843': '\u5bf9',
|
||||
'\ue82f': '\u5c0f',
|
||||
'\ue802': '\u591a',
|
||||
'\ue831': '\u7136',
|
||||
'\ue84b': '\u4e8e',
|
||||
'\ue837': '\u5fc3',
|
||||
'\ue829': '\u5b66',
|
||||
'\ue85e': '\u4e48',
|
||||
'\ue83a': '\u4e4b',
|
||||
'\ue832': '\u90fd',
|
||||
'\ue808': '\u597d',
|
||||
'\ue841': '\u770b',
|
||||
'\ue821': '\u8d77',
|
||||
'\ue845': '\u53d1',
|
||||
'\ue803': '\u5f53',
|
||||
'\ue828': '\u6ca1',
|
||||
'\ue81b': '\u6210',
|
||||
'\ue83e': '\u53ea',
|
||||
'\ue820': '\u5982',
|
||||
'\ue84e': '\u4e8b',
|
||||
'\ue85a': '\u628a',
|
||||
'\ue806': '\u8fd8',
|
||||
'\ue83f': '\u7528',
|
||||
'\ue833': '\u7b2c',
|
||||
'\ue811': '\u6837',
|
||||
'\ue804': '\u9053',
|
||||
'\ue814': '\u60f3',
|
||||
'\ue80f': '\u4f5c',
|
||||
'\ue84f': '\u79cd',
|
||||
'\ue80e': '\u5f00',
|
||||
'\ue823': '\u7f8e',
|
||||
'\ue849': '\u4e73',
|
||||
'\ue805': '\u9634',
|
||||
'\ue809': '\u6db2',
|
||||
'\ue81a': '\u830e',
|
||||
'\ue844': '\u6b32',
|
||||
'\ue847': '\u547b',
|
||||
'\ue850': '\u8089',
|
||||
'\ue824': '\u4ea4',
|
||||
'\ue85f': '\u6027',
|
||||
'\ue817': '\u80f8',
|
||||
'\ue85c': '\u79c1',
|
||||
'\ue838': '\u7a74',
|
||||
'\ue82a': '\u6deb',
|
||||
'\ue83d': '\u81c0',
|
||||
'\ue82b': '\u8214',
|
||||
'\ue80d': '\u5c04',
|
||||
'\ue839': '\u8131',
|
||||
'\ue834': '\u88f8',
|
||||
'\ue846': '\u9a9a',
|
||||
'\ue825': '\u5507',
|
||||
"\u201c": "\u300c",
|
||||
"\u201d": "\u300d",
|
||||
"\u2018": "\u300e",
|
||||
"\u2019": "\u300f",
|
||||
"\ue82c": "\u7684",
|
||||
"\ue852": "\u4e00",
|
||||
"\ue82d": "\u662f",
|
||||
"\ue819": "\u4e86",
|
||||
"\ue856": "\u6211",
|
||||
"\ue857": "\u4e0d",
|
||||
"\ue816": "\u4eba",
|
||||
"\ue83c": "\u5728",
|
||||
"\ue830": "\u4ed6",
|
||||
"\ue82e": "\u6709",
|
||||
"\ue836": "\u8fd9",
|
||||
"\ue859": "\u4e2a",
|
||||
"\ue80a": "\u4e0a",
|
||||
"\ue855": "\u4eec",
|
||||
"\ue842": "\u6765",
|
||||
"\ue858": "\u5230",
|
||||
"\ue80b": "\u65f6",
|
||||
"\ue81f": "\u5927",
|
||||
"\ue84a": "\u5730",
|
||||
"\ue853": "\u4e3a",
|
||||
"\ue81e": "\u5b50",
|
||||
"\ue822": "\u4e2d",
|
||||
"\ue813": "\u4f60",
|
||||
"\ue85b": "\u8bf4",
|
||||
"\ue807": "\u751f",
|
||||
"\ue818": "\u56fd",
|
||||
"\ue810": "\u5e74",
|
||||
"\ue812": "\u7740",
|
||||
"\ue851": "\u5c31",
|
||||
"\ue801": "\u90a3",
|
||||
"\ue80c": "\u548c",
|
||||
"\ue815": "\u8981",
|
||||
"\ue84c": "\u5979",
|
||||
"\ue840": "\u51fa",
|
||||
"\ue848": "\u4e5f",
|
||||
"\ue835": "\u5f97",
|
||||
"\ue800": "\u91cc",
|
||||
"\ue826": "\u540e",
|
||||
"\ue863": "\u81ea",
|
||||
"\ue861": "\u4ee5",
|
||||
"\ue854": "\u4f1a",
|
||||
"\ue827": "\u5bb6",
|
||||
"\ue83b": "\u53ef",
|
||||
"\ue85d": "\u4e0b",
|
||||
"\ue84d": "\u800c",
|
||||
"\ue862": "\u8fc7",
|
||||
"\ue81c": "\u5929",
|
||||
"\ue81d": "\u53bb",
|
||||
"\ue860": "\u80fd",
|
||||
"\ue843": "\u5bf9",
|
||||
"\ue82f": "\u5c0f",
|
||||
"\ue802": "\u591a",
|
||||
"\ue831": "\u7136",
|
||||
"\ue84b": "\u4e8e",
|
||||
"\ue837": "\u5fc3",
|
||||
"\ue829": "\u5b66",
|
||||
"\ue85e": "\u4e48",
|
||||
"\ue83a": "\u4e4b",
|
||||
"\ue832": "\u90fd",
|
||||
"\ue808": "\u597d",
|
||||
"\ue841": "\u770b",
|
||||
"\ue821": "\u8d77",
|
||||
"\ue845": "\u53d1",
|
||||
"\ue803": "\u5f53",
|
||||
"\ue828": "\u6ca1",
|
||||
"\ue81b": "\u6210",
|
||||
"\ue83e": "\u53ea",
|
||||
"\ue820": "\u5982",
|
||||
"\ue84e": "\u4e8b",
|
||||
"\ue85a": "\u628a",
|
||||
"\ue806": "\u8fd8",
|
||||
"\ue83f": "\u7528",
|
||||
"\ue833": "\u7b2c",
|
||||
"\ue811": "\u6837",
|
||||
"\ue804": "\u9053",
|
||||
"\ue814": "\u60f3",
|
||||
"\ue80f": "\u4f5c",
|
||||
"\ue84f": "\u79cd",
|
||||
"\ue80e": "\u5f00",
|
||||
"\ue823": "\u7f8e",
|
||||
"\ue849": "\u4e73",
|
||||
"\ue805": "\u9634",
|
||||
"\ue809": "\u6db2",
|
||||
"\ue81a": "\u830e",
|
||||
"\ue844": "\u6b32",
|
||||
"\ue847": "\u547b",
|
||||
"\ue850": "\u8089",
|
||||
"\ue824": "\u4ea4",
|
||||
"\ue85f": "\u6027",
|
||||
"\ue817": "\u80f8",
|
||||
"\ue85c": "\u79c1",
|
||||
"\ue838": "\u7a74",
|
||||
"\ue82a": "\u6deb",
|
||||
"\ue83d": "\u81c0",
|
||||
"\ue82b": "\u8214",
|
||||
"\ue80d": "\u5c04",
|
||||
"\ue839": "\u8131",
|
||||
"\ue834": "\u88f8",
|
||||
"\ue846": "\u9a9a",
|
||||
"\ue825": "\u5507",
|
||||
};
|
||||
const addPage = async (pageCheerio: CheerioAPI) => {
|
||||
const formatPage = async () => {
|
||||
// Remove JS
|
||||
pageCheerio('#ccacontent .cgo').remove();
|
||||
const formatPage = async () => {
|
||||
// Remove JS
|
||||
pageCheerio("#ccacontent .cgo").remove();
|
||||
|
||||
// Load lazyloaded images
|
||||
pageCheerio('#ccacontent img.imagecontent').each((i, el) => {
|
||||
// Sometimes images are either in data-src or src
|
||||
const imgSrc =
|
||||
pageCheerio(el).attr('data-src') || pageCheerio(el).attr('src');
|
||||
if (imgSrc) {
|
||||
// The original CDN URL is locked behind a CF-like challenge, switch the URL to bypass that
|
||||
// There are no react-native-url-polyfill lib, can't use URL API
|
||||
const regex = /\/\/.+\.com\//;
|
||||
const imgUrl = imgSrc.replace(regex, '//img.linovelib.com/');
|
||||
// Clean up img element
|
||||
pageCheerio(el)
|
||||
.attr('src', imgUrl)
|
||||
.removeAttr('data-src')
|
||||
.removeClass('lazyload');
|
||||
}
|
||||
});
|
||||
// Load lazyloaded images
|
||||
pageCheerio("#ccacontent img.imagecontent").each((i, el) => {
|
||||
// Sometimes images are either in data-src or src
|
||||
const imgSrc =
|
||||
pageCheerio(el).attr("data-src") ||
|
||||
pageCheerio(el).attr("src");
|
||||
if (imgSrc) {
|
||||
// The original CDN URL is locked behind a CF-like challenge, switch the URL to bypass that
|
||||
// There are no react-native-url-polyfill lib, can't use URL API
|
||||
const regex = /\/\/.+\.com\//;
|
||||
const imgUrl = imgSrc.replace(
|
||||
regex,
|
||||
"//img.linovelib.com/"
|
||||
);
|
||||
// Clean up img element
|
||||
pageCheerio(el)
|
||||
.attr("src", imgUrl)
|
||||
.removeAttr("data-src")
|
||||
.removeClass("lazyload");
|
||||
}
|
||||
});
|
||||
|
||||
// Recover the original character
|
||||
pageText = pageCheerio('#ccacontent').html() || "";
|
||||
pageText = pageText.replace(/./g, char => skillgg[char] || char);
|
||||
// Recover the original character
|
||||
pageText = pageCheerio("#ccacontent").html() || "";
|
||||
pageText = pageText.replace(
|
||||
/./g,
|
||||
(char) => skillgg[char] || char
|
||||
);
|
||||
|
||||
return Promise.resolve();
|
||||
};
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
await formatPage();
|
||||
chapterName =
|
||||
pageCheerio('#atitle + h3').text() +
|
||||
' — ' +
|
||||
pageCheerio('#atitle').text();
|
||||
if (chapterText === "") {
|
||||
chapterText = '<h2>' + chapterName + '</h2>';
|
||||
}
|
||||
chapterText += pageText;
|
||||
await formatPage();
|
||||
chapterName =
|
||||
pageCheerio("#atitle + h3").text() +
|
||||
" — " +
|
||||
pageCheerio("#atitle").text();
|
||||
if (chapterText === "") {
|
||||
chapterText = "<h2>" + chapterName + "</h2>";
|
||||
}
|
||||
chapterText += pageText;
|
||||
};
|
||||
|
||||
const loadPage = async (url:string) => {
|
||||
const result = await fetchApi(url, {headers});
|
||||
const body = await result.text();
|
||||
const pageCheerio = parseHTML(body);
|
||||
await addPage(pageCheerio);
|
||||
pageHasNextPage =
|
||||
pageCheerio('#footlink a:last').text() === '下一页' ? true : false;
|
||||
return { pageCheerio, pageHasNextPage };
|
||||
const loadPage = async (url: string) => {
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
const pageCheerio = parseHTML(body);
|
||||
await addPage(pageCheerio);
|
||||
pageHasNextPage =
|
||||
pageCheerio("#footlink a:last").text() === "下一页"
|
||||
? true
|
||||
: false;
|
||||
return { pageCheerio, pageHasNextPage };
|
||||
};
|
||||
|
||||
let url = chapterUrl;
|
||||
do {
|
||||
const page = await loadPage(url);
|
||||
hasNextPage = page.pageHasNextPage;
|
||||
if (hasNextPage === true) {
|
||||
pageNumber++;
|
||||
url = chapterUrl.replace(/\.html/gi, `_${pageNumber}` + '.html');
|
||||
}
|
||||
const page = await loadPage(url);
|
||||
hasNextPage = page.pageHasNextPage;
|
||||
if (hasNextPage === true) {
|
||||
pageNumber++;
|
||||
url = chapterUrl.replace(
|
||||
/\.html/gi,
|
||||
`_${pageNumber}` + ".html"
|
||||
);
|
||||
}
|
||||
} while (hasNextPage === true);
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const searchUrl = `${this.site}/search/`;
|
||||
const Term = encodeURI(searchTerm);
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
let NextPage, NoNextPage:boolean, DeadEnd;
|
||||
let NextPage, NoNextPage: boolean, DeadEnd;
|
||||
pageNo = 1;
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
const addPage = async (pageCheerio: CheerioAPI, redirect: string) => {
|
||||
const loadSearchResults = () => {
|
||||
pageCheerio('.book-ol .book-layout').each((i, el) => {
|
||||
let nUrl = pageCheerio(el).attr('href');
|
||||
const loadSearchResults = () => {
|
||||
pageCheerio(".book-ol .book-layout").each((i, el) => {
|
||||
let nUrl = pageCheerio(el).attr("href");
|
||||
|
||||
const novelName = pageCheerio(el).find('.book-title').text();
|
||||
const novelCover = pageCheerio(el)
|
||||
.find('img.book-cover')
|
||||
.attr('data-src');
|
||||
const novelUrl = this.site + nUrl;
|
||||
const novelName = pageCheerio(el)
|
||||
.find(".book-title")
|
||||
.text();
|
||||
const novelCover = pageCheerio(el)
|
||||
.find("img.book-cover")
|
||||
.attr("data-src");
|
||||
const novelUrl = this.site + nUrl;
|
||||
|
||||
if (!nUrl) return;
|
||||
if (!nUrl) return;
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
const novelResults = pageCheerio('.book-ol a.book-layout');
|
||||
if (novelResults.length === 0) {
|
||||
showToast('Bypass check by searching in Webview');
|
||||
} else {
|
||||
loadSearchResults();
|
||||
}
|
||||
const novelResults = pageCheerio(".book-ol a.book-layout");
|
||||
if (novelResults.length === 0) {
|
||||
showToast("Bypass check by searching in Webview");
|
||||
} else {
|
||||
loadSearchResults();
|
||||
}
|
||||
|
||||
if (redirect.length) {
|
||||
novels.length = 0;
|
||||
const novelName = pageCheerio('#bookDetailWrapper .book-title').text();
|
||||
if (redirect.length) {
|
||||
novels.length = 0;
|
||||
const novelName = pageCheerio(
|
||||
"#bookDetailWrapper .book-title"
|
||||
).text();
|
||||
|
||||
const novelCover = pageCheerio('#bookDetailWrapper img.book-cover').attr(
|
||||
'src',
|
||||
);
|
||||
const novelUrl =
|
||||
this.site +
|
||||
pageCheerio('#btnReadBook').attr('href')?.slice(0, -8) +
|
||||
'.html';
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
}
|
||||
const novelCover = pageCheerio(
|
||||
"#bookDetailWrapper img.book-cover"
|
||||
).attr("src");
|
||||
const novelUrl =
|
||||
this.site +
|
||||
pageCheerio("#btnReadBook").attr("href")?.slice(0, -8) +
|
||||
".html";
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const loadPage = async (url:string) => {
|
||||
const result = await fetchApi(url, {headers});
|
||||
const body = await result.text();
|
||||
const pageCheerio = parseHTML(body);
|
||||
const redirect = pageCheerio('div.book-layout').text();
|
||||
await addPage(pageCheerio, redirect);
|
||||
NextPage = pageCheerio('.next').attr('href');
|
||||
if (!NextPage) {
|
||||
NoNextPage === true;
|
||||
} else {
|
||||
NoNextPage = NextPage === '#' ? true : false;
|
||||
}
|
||||
return { pageCheerio, NoNextPage };
|
||||
const loadPage = async (url: string) => {
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
const pageCheerio = parseHTML(body);
|
||||
const redirect = pageCheerio("div.book-layout").text();
|
||||
await addPage(pageCheerio, redirect);
|
||||
NextPage = pageCheerio(".next").attr("href");
|
||||
if (!NextPage) {
|
||||
NoNextPage === true;
|
||||
} else {
|
||||
NoNextPage = NextPage === "#" ? true : false;
|
||||
}
|
||||
return { pageCheerio, NoNextPage };
|
||||
};
|
||||
|
||||
let url = `${searchUrl}${Term}_${pageNo}.html`;
|
||||
do {
|
||||
const page = await loadPage(url);
|
||||
DeadEnd = page.NoNextPage;
|
||||
if (DeadEnd === false) {
|
||||
pageNo++;
|
||||
url = `${searchUrl}${Term}_${pageNo}.html`;
|
||||
}
|
||||
const page = await loadPage(url);
|
||||
DeadEnd = page.NoNextPage;
|
||||
if (DeadEnd === false) {
|
||||
pageNo++;
|
||||
url = `${searchUrl}${Term}_${pageNo}.html`;
|
||||
}
|
||||
} while (DeadEnd === false);
|
||||
|
||||
return novels;
|
||||
};
|
||||
}
|
||||
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url);
|
||||
}
|
||||
filters = [
|
||||
{
|
||||
key: "sort",
|
||||
label: "Sort By",
|
||||
values: [
|
||||
{ label: "月点击榜", value: "monthvisit" },
|
||||
}
|
||||
filters = {
|
||||
sort: {
|
||||
label: "Sort By",
|
||||
value: "monthvisit",
|
||||
options: [
|
||||
{ label: "月点击榜", value: "monthvisit" },
|
||||
|
||||
{ label: "周点击榜", value: "weekvisit" },
|
||||
{ label: "周点击榜", value: "weekvisit" },
|
||||
|
||||
{ label: "月推荐榜", value: "monthvote" },
|
||||
{ label: "月推荐榜", value: "monthvote" },
|
||||
|
||||
{ label: "周推荐榜", value: "weekvote" },
|
||||
{ label: "周推荐榜", value: "weekvote" },
|
||||
|
||||
{ label: "月鲜花榜", value: "monthflower" },
|
||||
{ label: "月鲜花榜", value: "monthflower" },
|
||||
|
||||
{ label: "周鲜花榜", value: "weekflower" },
|
||||
{ label: "周鲜花榜", value: "weekflower" },
|
||||
|
||||
{ label: "月鸡蛋榜", value: "monthegg" },
|
||||
{ label: "月鸡蛋榜", value: "monthegg" },
|
||||
|
||||
{ label: "周鸡蛋榜", value: "weekegg" },
|
||||
{ label: "周鸡蛋榜", value: "weekegg" },
|
||||
|
||||
{ label: "最近更新", value: "lastupdate" },
|
||||
{ label: "最近更新", value: "lastupdate" },
|
||||
|
||||
{ label: "最新入库", value: "postdate" },
|
||||
{ label: "最新入库", value: "postdate" },
|
||||
|
||||
{ label: "收藏榜", value: "goodnum" },
|
||||
{ label: "收藏榜", value: "goodnum" },
|
||||
|
||||
{ label: "新书榜", value: "newhot" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
];
|
||||
{ label: "新书榜", value: "newhot" },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new Linovelib();
|
||||
|
||||
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"boxnovel","sourceSite":"https://boxnovel.com/","sourceName":"BoxNovel","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shounen","value":"shounen"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"}],"inputType":1}],"options":{"path":{"genres":"manga-genre"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"boxnovel","sourceSite":"https://boxnovel.com/","sourceName":"BoxNovel","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shounen","value":"shounen"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"genres":"manga-genre"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
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;
|
||||
userAgent: string;
|
||||
cookieString: 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.userAgent = "";
|
||||
this.cookieString = "";
|
||||
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 && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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() ||
|
||||
"";
|
||||
|
||||
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;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"clicknovel","sourceSite":"https://clicknovel.net/","sourceName":"ClickNovel","filters":{},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
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;
|
||||
userAgent: string;
|
||||
cookieString: 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.userAgent = "";
|
||||
this.cookieString = "";
|
||||
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 && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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() ||
|
||||
"";
|
||||
|
||||
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;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"cratenovel","sourceSite":"https://cratenovel.com/","sourceName":"CrateNovel","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"daonovel","sourceSite":"https://daonovel.com/","sourceName":"DaoNovel","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"path":{"novels":"novels-list","novel":"novels","chapter":"novels"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"daonovel","sourceSite":"https://daonovel.com/","sourceName":"DaoNovel","filters":{"sort":{"value":"","label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"novels-list","novel":"novels","chapter":"novels"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"fanTLS","sourceSite":"https://fanstranslations.com/","sourceName":"Fans Translations","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"fanTLS","sourceSite":"https://fanstranslations.com/","sourceName":"Fans Translations","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"1stkissnovel","sourceSite":"https://1stkissnovel.org/","sourceName":"FirstKissNovel","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Apocalypse","value":"apocalypse"},{"label":"Boy's Love","value":"boys-love"},{"label":"Comedy","value":"comedy"},{"label":"Completed","value":"completed"},{"label":"Cooking","value":"cooking"},{"label":"Demons","value":"demons"},{"label":"Detective","value":"detective"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"Food","value":"food"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Girls Love","value":"girls-love"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Humor","value":"humor"},{"label":"Isekai","value":"isekai"},{"label":"Josei","value":"josei"},{"label":"Magic","value":"magic"},{"label":"Magical","value":"magical"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Medical","value":"medical"},{"label":"Military","value":"military"},{"label":"Moder","value":"moder"},{"label":"Modern","value":"modern"},{"label":"Murim","value":"murim"},{"label":"Music","value":"music"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Reverse","value":"reverse"},{"label":"Reverse harem","value":"reverse-harem"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Super power","value":"super-power"},{"label":"Superhero","value":"superhero"},{"label":"Supernatural","value":"supernatural"},{"label":"Thriller","value":"thriller"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban Life","value":"urban-life"},{"label":"Vampire","value":"vampire"},{"label":"Webtoons","value":"webtoons"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"1stkissnovel","sourceSite":"https://1stkissnovel.org/","sourceName":"FirstKissNovel","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Apocalypse","value":"apocalypse"},{"label":"Boy's Love","value":"boys-love"},{"label":"Comedy","value":"comedy"},{"label":"Completed","value":"completed"},{"label":"Cooking","value":"cooking"},{"label":"Demons","value":"demons"},{"label":"Detective","value":"detective"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"Food","value":"food"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Girls Love","value":"girls-love"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Humor","value":"humor"},{"label":"Isekai","value":"isekai"},{"label":"Josei","value":"josei"},{"label":"Magic","value":"magic"},{"label":"Magical","value":"magical"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Medical","value":"medical"},{"label":"Military","value":"military"},{"label":"Moder","value":"moder"},{"label":"Modern","value":"modern"},{"label":"Murim","value":"murim"},{"label":"Music","value":"music"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Reverse","value":"reverse"},{"label":"Reverse harem","value":"reverse-harem"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Super power","value":"super-power"},{"label":"Superhero","value":"superhero"},{"label":"Supernatural","value":"supernatural"},{"label":"Thriller","value":"thriller"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban Life","value":"urban-life"},{"label":"Vampire","value":"vampire"},{"label":"Webtoons","value":"webtoons"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"freenovel.me","sourceSite":"https://freenovel.me/","sourceName":"FreeNovelMe","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Drama","value":"drama"},{"label":"Fantasy","value":"fantasy"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Historical","value":"historical"},{"label":"History","value":"history"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Martial","value":"martial"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Premium","value":"premium"},{"label":"Psychological","value":"psychological"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"}],"inputType":1}],"options":{"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"freenovel.me","sourceSite":"https://freenovel.me/","sourceName":"FreeNovelMe","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Drama","value":"drama"},{"label":"Fantasy","value":"fantasy"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Historical","value":"historical"},{"label":"History","value":"history"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Martial","value":"martial"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Premium","value":"premium"},{"label":"Psychological","value":"psychological"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"}],"value":"","type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"guavaread","sourceSite":"https://guavaread.com/","sourceName":"Guavaread","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Complete","value":"complete"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Drama","value":"drama"},{"label":"Dropped","value":"dropped"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Mature","value":"mature"},{"label":"Mystery","value":"mystery"},{"label":"Original Story","value":"original-story"},{"label":"Pilot","value":"pilot"},{"label":"Psychological","value":"psychological"},{"label":"R-15","value":"r-15"},{"label":"R-19","value":"r-19"},{"label":"Reverse Harem","value":"reverse-harem"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Shoujo","value":"shoujo"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"}],"inputType":1}],"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"guavaread","sourceSite":"https://guavaread.com/","sourceName":"Guavaread","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Complete","value":"complete"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Drama","value":"drama"},{"label":"Dropped","value":"dropped"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Mature","value":"mature"},{"label":"Mystery","value":"mystery"},{"label":"Original Story","value":"original-story"},{"label":"Pilot","value":"pilot"},{"label":"Psychological","value":"psychological"},{"label":"R-15","value":"r-15"},{"label":"R-19","value":"r-19"},{"label":"Reverse Harem","value":"reverse-harem"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Shoujo","value":"shoujo"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"lnheaven","sourceSite":"https://lightnovelheaven.com/","sourceName":"LightNovelHeaven","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"lnheaven","sourceSite":"https://lightnovelheaven.com/","sourceName":"LightNovelHeaven","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"lunarletters","sourceSite":"https://www.lunarletters.com/","sourceName":"LunarLetters","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"lunarletters","sourceSite":"https://www.lunarletters.com/","sourceName":"LunarLetters","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
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;
|
||||
userAgent: string;
|
||||
cookieString: 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.userAgent = "";
|
||||
this.cookieString = "";
|
||||
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 && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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() ||
|
||||
"";
|
||||
|
||||
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;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"mtlnovel.club","sourceSite":"https://mtlnovel.club/","sourceName":"MTLNovel.Club","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"mtl-novel","sourceSite":"https://mtl-novel.com/","sourceName":"MTL-Novel","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Chinese","value":"chinese"},{"label":"Comedy","value":"comedy"},{"label":"Conan","value":"conan"},{"label":"Drama","value":"drama"},{"label":"Erciyuan","value":"erciyuan"},{"label":"Fairy Tail","value":"fairy-tail"},{"label":"Faloo","value":"faloo"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"FoodWars!","value":"foodwars"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Hunter x Hunter","value":"hunter-x-hunter"},{"label":"Japanese","value":"japanese"},{"label":"Jojo","value":"jojo"},{"label":"Josei","value":"josei"},{"label":"Korean","value":"korean"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Marvel","value":"marvel"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Military","value":"military"},{"label":"Mystery","value":"mystery"},{"label":"Naruto","value":"naruto"},{"label":"One piece","value":"one-piece"},{"label":"Pokemon","value":"pokemon"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sport","value":"sport"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"System","value":"system"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban","value":"urban"},{"label":"Urban Life","value":"urban-life"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"path":{"genres":"manga-genre"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"mtl-novel","sourceSite":"https://mtl-novel.com/","sourceName":"MTL-Novel","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Chinese","value":"chinese"},{"label":"Comedy","value":"comedy"},{"label":"Conan","value":"conan"},{"label":"Drama","value":"drama"},{"label":"Erciyuan","value":"erciyuan"},{"label":"Fairy Tail","value":"fairy-tail"},{"label":"Faloo","value":"faloo"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"FoodWars!","value":"foodwars"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Hunter x Hunter","value":"hunter-x-hunter"},{"label":"Japanese","value":"japanese"},{"label":"Jojo","value":"jojo"},{"label":"Josei","value":"josei"},{"label":"Korean","value":"korean"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Marvel","value":"marvel"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Military","value":"military"},{"label":"Mystery","value":"mystery"},{"label":"Naruto","value":"naruto"},{"label":"One piece","value":"one-piece"},{"label":"Pokemon","value":"pokemon"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sport","value":"sport"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"System","value":"system"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban","value":"urban"},{"label":"Urban Life","value":"urban-life"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"path":{"genres":"manga-genre"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"mostnovel","sourceSite":"https://mostnovel.com/","sourceName":"MostNovel","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"ACG","value":"acg"},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"AGA","value":"aga"},{"label":"Anime","value":"anime"},{"label":"Anime & Comics","value":"anime-comics"},{"label":"Bender","value":"bender"},{"label":"BL","value":"bl"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Contemporary Romance","value":"contemporary-romance"},{"label":"Cooking","value":"cooking"},{"label":"Cultivation","value":"cultivation"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Eastern Fantasy","value":"eastern-fantasy"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Horror&Thriller","value":"horrorthriller"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Magical Realism","value":"magical-realism"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Modern","value":"modern"},{"label":"Movies","value":"movies"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smart MC","value":"smart-mc"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban Life","value":"urban-life"},{"label":"Video Games","value":"video-games"},{"label":"Webtoon","value":"webtoon"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga","genres":"manga-genre"},"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"mostnovel","sourceSite":"https://mostnovel.com/","sourceName":"MostNovel","filters":{"sort":{"value":"","label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"value":"","label":"GENRES","options":[{"label":"NONE","value":""},{"label":"ACG","value":"acg"},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"AGA","value":"aga"},{"label":"Anime","value":"anime"},{"label":"Anime & Comics","value":"anime-comics"},{"label":"Bender","value":"bender"},{"label":"BL","value":"bl"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Contemporary Romance","value":"contemporary-romance"},{"label":"Cooking","value":"cooking"},{"label":"Cultivation","value":"cultivation"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Eastern Fantasy","value":"eastern-fantasy"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Horror&Thriller","value":"horrorthriller"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Magical Realism","value":"magical-realism"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Modern","value":"modern"},{"label":"Movies","value":"movies"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smart MC","value":"smart-mc"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban Life","value":"urban-life"},{"label":"Video Games","value":"video-games"},{"label":"Webtoon","value":"webtoon"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga","genres":"manga-genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"mysticalmerries","sourceSite":"https://mysticalmerries.com/","sourceName":"MysticalSeries","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adaptation","value":"adaptation"},{"label":"Adventure","value":"adventure"},{"label":"bilibili","value":"bilibili"},{"label":"Chinese Novel","value":"chinese-novel"},{"label":"Comedy","value":"comedy"},{"label":"Crossdressing","value":"crossdressing"},{"label":"Drama","value":"drama"},{"label":"Dropped","value":"dropped"},{"label":"Family","value":"family"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Korean Novel","value":"korean-novell"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Modern Romance","value":"modern-romance"},{"label":"Mystery","value":"mystery"},{"label":"Office Workers","value":"office-workers"},{"label":"One shot","value":"one-shot"},{"label":"Pilot Novel","value":"pilot-novel"},{"label":"R15","value":"r15"},{"label":"R19","value":"r19"},{"label":"Regression","value":"regression"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Reverse Harem","value":"reverse-harem"},{"label":"Romance Fantasy","value":"romance-fantasy"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Supernatural","value":"supernatural"},{"label":"Violence","value":"violence"}],"inputType":1}],"options":{"path":{"novels":"series","novel":"series","chapter":"series","genres":"genre"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"mysticalmerries","sourceSite":"https://mysticalmerries.com/","sourceName":"MysticalSeries","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adaptation","value":"adaptation"},{"label":"Adventure","value":"adventure"},{"label":"bilibili","value":"bilibili"},{"label":"Chinese Novel","value":"chinese-novel"},{"label":"Comedy","value":"comedy"},{"label":"Crossdressing","value":"crossdressing"},{"label":"Drama","value":"drama"},{"label":"Dropped","value":"dropped"},{"label":"Family","value":"family"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Korean Novel","value":"korean-novell"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Modern Romance","value":"modern-romance"},{"label":"Mystery","value":"mystery"},{"label":"Office Workers","value":"office-workers"},{"label":"One shot","value":"one-shot"},{"label":"Pilot Novel","value":"pilot-novel"},{"label":"R15","value":"r15"},{"label":"R19","value":"r19"},{"label":"Regression","value":"regression"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Reverse Harem","value":"reverse-harem"},{"label":"Romance Fantasy","value":"romance-fantasy"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Supernatural","value":"supernatural"},{"label":"Violence","value":"violence"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"series","novel":"series","chapter":"series","genres":"genre"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"neosekaiTLS","sourceSite":"https://www.neosekaitranslations.com/","sourceName":"NeoSekai Translations","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Fantasy","value":"fantasy"},{"label":"Harem","value":"harem"},{"label":"Horror","value":"horror"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-Fi","value":"sci-fi"},{"label":"Slice of Life","value":"slice-of-life"}],"inputType":1}],"options":{"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"neosekaiTLS","sourceSite":"https://www.neosekaitranslations.com/","sourceName":"NeoSekai Translations","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Fantasy","value":"fantasy"},{"label":"Harem","value":"harem"},{"label":"Horror","value":"horror"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-Fi","value":"sci-fi"},{"label":"Slice of Life","value":"slice-of-life"}],"type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"nocturneTLS","sourceSite":"https://nocturnetls.net/","sourceName":"Nocturne Translations","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Webtoon","value":"webtoon"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"path":{"novels":"novels","novel":"novels","chapter":"novels","genres":"manga-genre"},"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"nocturneTLS","sourceSite":"https://nocturnetls.net/","sourceName":"Nocturne Translations","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Webtoon","value":"webtoon"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"novels","novel":"novels","chapter":"novels","genres":"manga-genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
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;
|
||||
userAgent: string;
|
||||
cookieString: 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.userAgent = "";
|
||||
this.cookieString = "";
|
||||
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 && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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() ||
|
||||
"";
|
||||
|
||||
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;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"noobchanTL","sourceSite":"https://noobchan.xyz/","sourceName":"Noobchan Translation","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"novelmultiverse","sourceSite":"https://www.novelmultiverse.com/","sourceName":"NovelMultiverse","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Original","value":"original"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Translation","value":"translation"},{"label":"Webtoon","value":"webtoon"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelmultiverse","sourceSite":"https://www.novelmultiverse.com/","sourceName":"NovelMultiverse","filters":{"sort":{"value":"","label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Original","value":"original"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Translation","value":"translation"},{"label":"Webtoon","value":"webtoon"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"novelr18","sourceSite":"https://novelr18.com/","sourceName":"NovelR18","filters":[{"key":"sort","label":"Sort by :","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest Update","value":"latest"},{"label":"Most Views","value":"views"},{"label":"Newly Added Novels","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"path":{"novel":"manga","chapter":"manga"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelr18","sourceSite":"https://novelr18.com/","sourceName":"NovelR18","filters":{"sort":{"label":"Sort by :","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest Update","value":"latest"},{"label":"Most Views","value":"views"},{"label":"Newly Added Novels","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"novel","novel":"manga","chapter":"manga"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"novelTL","sourceSite":"https://noveltranslate.com/","sourceName":"NovelTranslate","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Bleach","value":"bleach"},{"label":"Chinese","value":"chinese"},{"label":"Comedy","value":"comedy"},{"label":"Conan","value":"conan"},{"label":"cooking","value":"cooking"},{"label":"Dragon Ball","value":"dragon-ball"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Erciyuan","value":"erciyuan"},{"label":"Fairy Tail","value":"fairy-tail"},{"label":"Faloo","value":"faloo"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"FoodWars!","value":"foodwars"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Hunter x Hunter","value":"hunter-x-hunter"},{"label":"Isekai","value":"isekai"},{"label":"Japanese","value":"japanese"},{"label":"Jojo","value":"jojo"},{"label":"Josei","value":"josei"},{"label":"Korean","value":"korean"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Marvel","value":"marvel"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Military","value":"military"},{"label":"Mystery","value":"mystery"},{"label":"Naruto","value":"naruto"},{"label":"One piece","value":"one-piece"},{"label":"Pokemon","value":"pokemon"},{"label":"Political","value":"political"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sport","value":"sport"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"System","value":"system"},{"label":"Toriko","value":"toriko"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban","value":"urban"},{"label":"Urban Life","value":"urban-life"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"path":{"novels":"all-novels","novel":"manga","chapter":"manga","genres":"manga-genre"},"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelTL","sourceSite":"https://noveltranslate.com/","sourceName":"NovelTranslate","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Bleach","value":"bleach"},{"label":"Chinese","value":"chinese"},{"label":"Comedy","value":"comedy"},{"label":"Conan","value":"conan"},{"label":"cooking","value":"cooking"},{"label":"Dragon Ball","value":"dragon-ball"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Erciyuan","value":"erciyuan"},{"label":"Fairy Tail","value":"fairy-tail"},{"label":"Faloo","value":"faloo"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"FoodWars!","value":"foodwars"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Hunter x Hunter","value":"hunter-x-hunter"},{"label":"Isekai","value":"isekai"},{"label":"Japanese","value":"japanese"},{"label":"Jojo","value":"jojo"},{"label":"Josei","value":"josei"},{"label":"Korean","value":"korean"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Marvel","value":"marvel"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Military","value":"military"},{"label":"Mystery","value":"mystery"},{"label":"Naruto","value":"naruto"},{"label":"One piece","value":"one-piece"},{"label":"Pokemon","value":"pokemon"},{"label":"Political","value":"political"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sport","value":"sport"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"System","value":"system"},{"label":"Toriko","value":"toriko"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban","value":"urban"},{"label":"Urban Life","value":"urban-life"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"novels":"all-novels","novel":"manga","chapter":"manga","genres":"manga-genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"novelroom","sourceSite":"https://novelroom.net/","sourceName":"Novelroom.net","filters":[],"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga"},"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelroom","sourceSite":"https://novelroom.net/","sourceName":"Novelroom.net","filters":{},"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"novelstic","sourceSite":"https://novelstic.com/","sourceName":"Novelstic","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelstic","sourceSite":"https://novelstic.com/","sourceName":"Novelstic","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
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;
|
||||
userAgent: string;
|
||||
cookieString: 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.userAgent = "";
|
||||
this.cookieString = "";
|
||||
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 && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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() ||
|
||||
"";
|
||||
|
||||
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;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"onlymtl","sourceSite":"https://www.onlymtl.com/","sourceName":"OnlyMTL","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"readwebnovels","sourceSite":"https://readwebnovels.net/","sourceName":"ReadWebNovels","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"readwebnovels","sourceSite":"https://readwebnovels.net/","sourceName":"ReadWebNovels","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"sleeptTLS","sourceSite":"https://sleepytranslations.com/","sourceName":"SleepyTranslations","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"sleeptTLS","sourceSite":"https://sleepytranslations.com/","sourceName":"SleepyTranslations","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
+173
-139
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"sonicmtl","sourceSite":"https://www.sonicmtl.com/","sourceName":"SonicMTL","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban Life","value":"urban-life"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"sonicmtl","sourceSite":"https://www.sonicmtl.com/","sourceName":"SonicMTL","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban Life","value":"urban-life"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"sugarbbscan","sourceSite":"https://sugarbbscan.com/","sourceName":"Sugar Babies","filters":[],"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"sugarbbscan","sourceSite":"https://sugarbbscan.com/","sourceName":"Sugar Babies","filters":{},"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"sweetEscapeTL","sourceSite":"https://sweetescapetranslations.com/","sourceName":"Sweet Escape Translations","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Mature","value":"mature"},{"label":"Modern","value":"modern"},{"label":"Mystery","value":"mystery"},{"label":"R-15","value":"r-15"},{"label":"Romance","value":"romance"},{"label":"Slice of Life","value":"slice-of-life"}],"inputType":1}],"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga","genres":"manga-genre"},"useNewChapterEndpoint":false,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"sweetEscapeTL","sourceSite":"https://sweetescapetranslations.com/","sourceName":"Sweet Escape Translations","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Mature","value":"mature"},{"label":"Modern","value":"modern"},{"label":"Mystery","value":"mystery"},{"label":"R-15","value":"r-15"},{"label":"Romance","value":"romance"},{"label":"Slice of Life","value":"slice-of-life"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga","genres":"manga-genre"},"useNewChapterEndpoint":false,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"webnovelover","sourceSite":"https://www.webnovelover.com/","sourceName":"WebNovelLover","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adapted into drama","value":"adapted-into-drama"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Completed","value":"completed"},{"label":"Drama","value":"drama"},{"label":"English Novel","value":"english-novel"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Indo Novel","value":"indo-novel"},{"label":"Josei","value":"josei"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mystery","value":"mystery"},{"label":"Rebirth","value":"rebirth"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Romance","value":"romance"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Shoujo","value":"shoujo"},{"label":"Shounen","value":"shounen"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Spiritual","value":"spiritual"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Transmigration","value":"transmigration"},{"label":"University","value":"university"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Youth","value":"youth"}],"inputType":1}],"options":{"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"webnovelover","sourceSite":"https://www.webnovelover.com/","sourceName":"WebNovelLover","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adapted into drama","value":"adapted-into-drama"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Completed","value":"completed"},{"label":"Drama","value":"drama"},{"label":"English Novel","value":"english-novel"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Indo Novel","value":"indo-novel"},{"label":"Josei","value":"josei"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mystery","value":"mystery"},{"label":"Rebirth","value":"rebirth"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Romance","value":"romance"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Shoujo","value":"shoujo"},{"label":"Shounen","value":"shounen"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Spiritual","value":"spiritual"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Transmigration","value":"transmigration"},{"label":"University","value":"university"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Youth","value":"youth"}],"type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"wuxiaworld.site","sourceSite":"https://wuxiaworld.site/","sourceName":"WuxiaWorld.Site","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"wuxiaworld.site","sourceSite":"https://wuxiaworld.site/","sourceName":"WuxiaWorld.Site","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"zetroTL","sourceSite":"https://zetrotranslation.com/","sourceName":"Zetro Translation","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Dark Elf","value":"dark-elf"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Harem","value":"harem"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"NTR","value":"ntr"},{"label":"Original Works","value":"original-works"},{"label":"Rom-Com","value":"rom-com"},{"label":"Romance","value":"romance"},{"label":"School","value":"school"},{"label":"Shoujo","value":"shoujo"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Villain","value":"villain"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"path":{"genres":"genre"},"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"zetroTL","sourceSite":"https://zetrotranslation.com/","sourceName":"Zetro Translation","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Dark Elf","value":"dark-elf"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Harem","value":"harem"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"NTR","value":"ntr"},{"label":"Original Works","value":"original-works"},{"label":"Rom-Com","value":"rom-com"},{"label":"Romance","value":"romance"},{"label":"School","value":"school"},{"label":"Shoujo","value":"shoujo"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Villain","value":"villain"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"path":{"genres":"genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"zinnovel","sourceSite":"https://zinnovel.com/","sourceName":"ZinnNovel","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Lolicon","value":"lolicon"},{"label":"Magical Realism","value":"magical-realism"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Video Games","value":"video-games"},{"label":"Webtoon","value":"webtoon"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga","genres":"manga-genre"},"lang":"English"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"zinnovel","sourceSite":"https://zinnovel.com/","sourceName":"ZinnNovel","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Lolicon","value":"lolicon"},{"label":"Magical Realism","value":"magical-realism"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Video Games","value":"video-games"},{"label":"Webtoon","value":"webtoon"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga","genres":"manga-genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -3,19 +3,24 @@ import { Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { fetchFile } from "@libs/fetch";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
|
||||
class BLN implements Plugin.PluginBase {
|
||||
id = "BLN.com";
|
||||
name = "BestLightNovel";
|
||||
icon = "src/en/bestlightnovel/icon.png";
|
||||
site = "https://bestlightnovel.com/";
|
||||
filter?: Filter[] | undefined;
|
||||
filter?: undefined;
|
||||
version = "1.0.0";
|
||||
userAgent = "";
|
||||
cookieString = "";
|
||||
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + "novel_list?type=topview&category=all&state=all&page=1" + pageNo;
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url =
|
||||
this.site +
|
||||
"novel_list?type=topview&category=all&state=all&page=1" +
|
||||
pageNo;
|
||||
|
||||
const result = await fetch(url);
|
||||
if (!result.ok) {
|
||||
@@ -137,32 +142,35 @@ class BLN implements Plugin.PluginBase {
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}search_novels/${searchTerm}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
|
||||
let loadedCheerio = cheerioload(body);
|
||||
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
|
||||
loadedCheerio(".update_item.list_category").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h3 > a").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h3 > a").attr("href");
|
||||
|
||||
|
||||
if (!novelUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No novel url!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
@@ -171,4 +179,3 @@ class BLN implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
export default new BLN();
|
||||
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
|
||||
class FTest implements Plugin.PluginBase {
|
||||
id = "ftest";
|
||||
name = "Filter Test";
|
||||
icon = "src/en/noblemtl/icon.png";
|
||||
site = "https://noblemtl.com/";
|
||||
version = "1.0.0";
|
||||
userAgent = "";
|
||||
cookieString = "";
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
return { url: "" };
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
return "Empty chapter";
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
return [];
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url);
|
||||
}
|
||||
|
||||
filters = {
|
||||
picker: {
|
||||
type: FilterTypes.Picker,
|
||||
label: "Picker",
|
||||
options: [
|
||||
{ label: "A", value: "a" },
|
||||
{ label: "B", value: "b" },
|
||||
],
|
||||
value: "a",
|
||||
},
|
||||
nd_picker: {
|
||||
type: FilterTypes.Picker,
|
||||
label: "ND_Picker",
|
||||
options: [
|
||||
{ label: "A", value: "a" },
|
||||
{ label: "B", value: "b" },
|
||||
],
|
||||
value: "b",
|
||||
},
|
||||
checkbox: {
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
label: "Checkbox",
|
||||
options: [
|
||||
{ label: "A", value: "a" },
|
||||
{ label: "B", value: "b" },
|
||||
],
|
||||
value: [],
|
||||
},
|
||||
nd_checkbox: {
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
label: "ND_Checkbox",
|
||||
options: [
|
||||
{ label: "A", value: "a" },
|
||||
{ label: "B", value: "b" },
|
||||
],
|
||||
value: ["a"],
|
||||
},
|
||||
switch: {
|
||||
type: FilterTypes.Switch,
|
||||
label: "Switch",
|
||||
value: false,
|
||||
},
|
||||
nd_switch: {
|
||||
type: FilterTypes.Switch,
|
||||
label: "ND_Switch",
|
||||
value: true,
|
||||
},
|
||||
text: {
|
||||
type: FilterTypes.TextInput,
|
||||
label: "Text",
|
||||
value: "",
|
||||
},
|
||||
nd_text: {
|
||||
type: FilterTypes.TextInput,
|
||||
label: "ND_Text",
|
||||
value: "some default value",
|
||||
},
|
||||
xcheckbox: {
|
||||
type: FilterTypes.ExcludableCheckboxGroup,
|
||||
label: "XCheckbox",
|
||||
options: [
|
||||
{ label: "A", value: "a" },
|
||||
{ label: "C", value: "c" },
|
||||
{ label: "B", value: "b" },
|
||||
],
|
||||
value: {},
|
||||
},
|
||||
nd_xcheckbox: {
|
||||
type: FilterTypes.ExcludableCheckboxGroup,
|
||||
label: "ND_XCheckbox",
|
||||
options: [
|
||||
{ label: "A", value: "a" },
|
||||
{ label: "C", value: "c" },
|
||||
{ label: "B", value: "b" },
|
||||
],
|
||||
value: { exclude: ["a"], include: ["b"] },
|
||||
},
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
const Test = new FTest();
|
||||
|
||||
export default new FTest();
|
||||
+53
-42
@@ -1,6 +1,6 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
|
||||
class NobleMTL implements Plugin.PluginBase {
|
||||
@@ -11,26 +11,27 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
version = "1.0.0";
|
||||
userAgent = "";
|
||||
cookieString = "";
|
||||
async popularNovels(pageNo: number, {filters}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}series/?page=${pageNo}`;
|
||||
|
||||
if (filters) {
|
||||
if (Array.isArray(filters.genres) && filters.genres.length) {
|
||||
link += filters.genres.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
if (filters.genres.value.length)
|
||||
link += filters.genres.value.map((i) => `&genre[]=${i}`).join("");
|
||||
|
||||
if (Array.isArray(filters.type) && filters.type.length)
|
||||
link += filters.type.map((i) => `&lang[]=${i}`).join("");
|
||||
}
|
||||
link += "&status=" + (filters?.status ? filters.status : "");
|
||||
if (filters.type.value.length)
|
||||
link += filters.type.value.map((i) => `&lang[]=${i}`).join("");
|
||||
|
||||
link += "&order=" + (filters?.order ? filters.order : "popular");
|
||||
link += "&status=" + filters.status.value;
|
||||
|
||||
link += "&order=" + filters.order.value;
|
||||
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const body = await fetchApi(link, {headers}).then((result) =>
|
||||
const body = await fetchApi(link, { headers }).then((result) =>
|
||||
result.text()
|
||||
);
|
||||
|
||||
@@ -57,15 +58,15 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
@@ -83,7 +84,12 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
|
||||
loadedCheerio("div.spe > span").each(function () {
|
||||
const detailName = loadedCheerio(this).find("b").text().trim();
|
||||
const detail = loadedCheerio(this).find('b').remove().end().text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find("b")
|
||||
.remove()
|
||||
.end()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Author:":
|
||||
@@ -139,10 +145,10 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(chapterUrl, {headers});
|
||||
const result = await fetchApi(chapterUrl, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -152,13 +158,16 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?s=${searchTerm}`;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -184,12 +193,11 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
return await fetchFile(url);
|
||||
}
|
||||
|
||||
|
||||
filters = [
|
||||
{
|
||||
key: "order",
|
||||
filters = {
|
||||
order: {
|
||||
label: "Sort By",
|
||||
values: [
|
||||
type: FilterTypes.Picker,
|
||||
options: [
|
||||
{ label: "Default", value: "" },
|
||||
|
||||
{ label: "A-Z", value: "title" },
|
||||
@@ -202,12 +210,12 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Popular", value: "popular" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
value: "",
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
|
||||
status: {
|
||||
label: "Status",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "All", value: "" },
|
||||
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
@@ -216,12 +224,12 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
value: "",
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
type: {
|
||||
label: "Type",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "Chinese novel", value: "chinese-novel" },
|
||||
|
||||
{ label: "habyeol", value: "habyeol" },
|
||||
@@ -234,12 +242,13 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
|
||||
{ label: "호곡", value: "%ed%98%b8%ea%b3%a1" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
value: [],
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
genres: {
|
||||
label: "Genres",
|
||||
values: [
|
||||
value: [],
|
||||
options: [
|
||||
{ label: "A.I", value: "a.i" },
|
||||
|
||||
{ label: "Academy", value: "academy" },
|
||||
@@ -409,9 +418,11 @@ class NobleMTL implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Yuri", value: "yuri" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
];
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new NobleMTL();
|
||||
const Noble = new NobleMTL();
|
||||
|
||||
export default new NobleMTL();
|
||||
|
||||
+42
-38
@@ -1,6 +1,6 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
|
||||
class PandaMTL implements Plugin.PluginBase {
|
||||
@@ -11,26 +11,28 @@ class PandaMTL implements Plugin.PluginBase {
|
||||
version = "1.0.0";
|
||||
userAgent = "";
|
||||
cookieString = "";
|
||||
async popularNovels(pageNo: number, {filters}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}series/?page=${pageNo}`;
|
||||
|
||||
if (filters) {
|
||||
if (Array.isArray(filters.genres) && filters.genres.length) {
|
||||
link += filters.genres.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
|
||||
if (Array.isArray(filters.type) && filters.type.length)
|
||||
link += filters.type.map((i) => `&lang[]=${i}`).join("");
|
||||
if (filters.genres.value.length) {
|
||||
link += filters.genres.value.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
|
||||
if (filters.type.value.length)
|
||||
link += filters.type.value.map((i) => `&lang[]=${i}`).join("");
|
||||
|
||||
link += "&status=" + (filters?.status ? filters.status : "");
|
||||
|
||||
link += "&order=" + (filters?.order ? filters.order : "popular");
|
||||
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const body = await fetchApi(link, {headers}).then((result) =>
|
||||
const body = await fetchApi(link, { headers }).then((result) =>
|
||||
result.text()
|
||||
);
|
||||
|
||||
@@ -60,10 +62,10 @@ class PandaMTL implements Plugin.PluginBase {
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
@@ -136,10 +138,10 @@ class PandaMTL implements Plugin.PluginBase {
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(chapterUrl, {headers});
|
||||
const result = await fetchApi(chapterUrl, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -148,13 +150,16 @@ class PandaMTL implements Plugin.PluginBase {
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?s=${searchTerm}`;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -182,12 +187,11 @@ class PandaMTL implements Plugin.PluginBase {
|
||||
return await fetchFile(url);
|
||||
}
|
||||
|
||||
|
||||
filters = [
|
||||
{
|
||||
key: "order",
|
||||
filters = {
|
||||
order: {
|
||||
label: "Sort By",
|
||||
values: [
|
||||
value: "",
|
||||
options: [
|
||||
{ label: "Default", value: "" },
|
||||
|
||||
{ label: "A-Z", value: "title" },
|
||||
@@ -200,12 +204,12 @@ class PandaMTL implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Popular", value: "popular" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
status: {
|
||||
label: "Status",
|
||||
values: [
|
||||
value: "",
|
||||
options: [
|
||||
{ label: "All", value: "" },
|
||||
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
@@ -214,22 +218,22 @@ class PandaMTL implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
type: {
|
||||
value: [],
|
||||
label: "Type",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "Light Novel (KR)", value: "light-novel-kr" },
|
||||
|
||||
{ label: "Web Novel", value: "web-novel" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
genres: {
|
||||
label: "Genres",
|
||||
values: [
|
||||
value: [],
|
||||
options: [
|
||||
{ label: "Action", value: "action" },
|
||||
|
||||
{ label: "Adult", value: "adult" },
|
||||
@@ -268,9 +272,9 @@ class PandaMTL implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Tragedy", value: "tragedy" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
];
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new PandaMTL();
|
||||
export default new PandaMTL();
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"meionovel","sourceSite":"https://meionovel.id/","sourceName":"MeioNovel","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Cooking","value":"cooking"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fanfiction","value":"fanfiction"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Josei","value":"josei"},{"label":"Magic","value":"magic"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Reverse Harem","value":"reverse-harem"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Virtual Reality","value":"virtual-reality"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"useNewChapterEndpoint":true,"lang":"Indonesian"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"meionovel","sourceSite":"https://meionovel.id/","sourceName":"MeioNovel","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Cooking","value":"cooking"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fanfiction","value":"fanfiction"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Josei","value":"josei"},{"label":"Magic","value":"magic"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Reverse Harem","value":"reverse-harem"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Virtual Reality","value":"virtual-reality"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"Indonesian"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"morenovel","sourceSite":"https://morenovel.net/","sourceName":"MoreNovel","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"inputType":1}],"options":{"useNewChapterEndpoint":true,"lang":"Indonesian"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"morenovel","sourceSite":"https://morenovel.net/","sourceName":"MoreNovel","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"Indonesian"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"wbnovel","sourceSite":"https://wbnovel.com/","sourceName":"WBNovel","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1},{"key":"genres","label":"GENRES","values":[{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Alchemy","value":"alchemy"},{"label":"Comedy","value":"comedy"},{"label":"Crafting","value":"crafting"},{"label":"Cultivation","value":"cultivation"},{"label":"Drama","value":"drama"},{"label":"Dungeon Crawling","value":"dungeon-crawling"},{"label":"Eci","value":"eci"},{"label":"Fantasy","value":"fantasy"},{"label":"Game","value":"game"},{"label":"Harem","value":"harem"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Kingdom Building","value":"kingdom-building"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Modern Setting","value":"modern-setting"},{"label":"Mystery","value":"mystery"},{"label":"Pets","value":"pets"},{"label":"Psychological","value":"psychological"},{"label":"Reincarnator","value":"reincarnator"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shounen","value":"shounen"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Transmigration","value":"transmigration"},{"label":"Virtual Reality","value":"virtual-reality"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"}],"inputType":1}],"options":{"lang":"Indonesian"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"wbnovel","sourceSite":"https://wbnovel.com/","sourceName":"WBNovel","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Alchemy","value":"alchemy"},{"label":"Comedy","value":"comedy"},{"label":"Crafting","value":"crafting"},{"label":"Cultivation","value":"cultivation"},{"label":"Drama","value":"drama"},{"label":"Dungeon Crawling","value":"dungeon-crawling"},{"label":"Eci","value":"eci"},{"label":"Fantasy","value":"fantasy"},{"label":"Game","value":"game"},{"label":"Harem","value":"harem"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Kingdom Building","value":"kingdom-building"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Modern Setting","value":"modern-setting"},{"label":"Mystery","value":"mystery"},{"label":"Pets","value":"pets"},{"label":"Psychological","value":"psychological"},{"label":"Reincarnator","value":"reincarnator"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shounen","value":"shounen"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Transmigration","value":"transmigration"},{"label":"Virtual Reality","value":"virtual-reality"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"}],"type":FilterTypes.Picker}},"options":{"lang":"Indonesian"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -14,7 +14,6 @@ export const icon = "src/jp/syosetu/icon.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https//yomou.syosetu.com/";
|
||||
|
||||
|
||||
const searchUrl = (pagenum?: number, order?: string) => {
|
||||
return `https://yomou.syosetu.com/search.php?order=${order || "hyoka"}${
|
||||
pagenum !== undefined
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
|
||||
class LightNovelBrasil implements Plugin.PluginBase {
|
||||
@@ -11,26 +11,27 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
version = "1.0.0";
|
||||
userAgent = "";
|
||||
cookieString = "";
|
||||
async popularNovels(pageNo: number, {filters}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}series/?page=${pageNo}`;
|
||||
|
||||
if (filters) {
|
||||
if (Array.isArray(filters.genres) && filters.genres.length) {
|
||||
link += filters.genres.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
if (filters.genres.value.length)
|
||||
link += filters.genres.value.map((i) => `&genre[]=${i}`).join("");
|
||||
|
||||
if (filters.type.value.length)
|
||||
link += filters.type.value.map((i) => `&lang[]=${i}`).join("");
|
||||
|
||||
if (Array.isArray(filters.type) && filters.type.length)
|
||||
link += filters.type.map((i) => `&lang[]=${i}`).join("");
|
||||
}
|
||||
link += "&status=" + (filters?.status ? filters.status : "");
|
||||
|
||||
link += "&order=" + (filters?.order ? filters.order : "popular");
|
||||
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const body = await fetchApi(link, {headers}).then((result) =>
|
||||
const body = await fetchApi(link, { headers }).then((result) =>
|
||||
result.text()
|
||||
);
|
||||
|
||||
@@ -57,15 +58,15 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
@@ -83,7 +84,12 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
|
||||
loadedCheerio("div.spe > span").each(function () {
|
||||
const detailName = loadedCheerio(this).find("b").text().trim();
|
||||
const detail = loadedCheerio(this).find('b').remove().end().text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find("b")
|
||||
.remove()
|
||||
.end()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Autor:":
|
||||
@@ -140,10 +146,10 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(chapterUrl, {headers});
|
||||
const result = await fetchApi(chapterUrl, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -153,13 +159,16 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?s=${searchTerm}`;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -185,12 +194,11 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
return await fetchFile(url);
|
||||
}
|
||||
|
||||
|
||||
filters = [
|
||||
{
|
||||
key: "order",
|
||||
filters = {
|
||||
order: {
|
||||
label: "Sort By",
|
||||
values: [
|
||||
value: "",
|
||||
options: [
|
||||
{ label: "Default", value: "" },
|
||||
|
||||
{ label: "A-Z", value: "title" },
|
||||
@@ -203,12 +211,12 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Popular", value: "popular" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
status: {
|
||||
label: "Status",
|
||||
values: [
|
||||
value: "",
|
||||
options: [
|
||||
{ label: "All", value: "" },
|
||||
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
@@ -217,12 +225,12 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
type: {
|
||||
label: "Type",
|
||||
values: [
|
||||
value: [],
|
||||
options: [
|
||||
{ label: "Chinese novel", value: "chinese-novel" },
|
||||
|
||||
{ label: "habyeol", value: "habyeol" },
|
||||
@@ -235,12 +243,12 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
|
||||
{ label: "호곡", value: "%ed%98%b8%ea%b3%a1" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
genres: {
|
||||
value: [],
|
||||
label: "Genres",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "A.I", value: "a.i" },
|
||||
|
||||
{ label: "Academy", value: "academy" },
|
||||
@@ -410,9 +418,9 @@ class LightNovelBrasil implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Yuri", value: "yuri" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
];
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new LightNovelBrasil();
|
||||
export default new LightNovelBrasil();
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+119
-107
@@ -1,6 +1,6 @@
|
||||
import { CheerioAPI, load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { showToast } from "@libs/showToast";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
@@ -15,27 +15,30 @@ class TuNovelaLigera implements Plugin.PluginBase {
|
||||
userAgent = "";
|
||||
cookieString = "";
|
||||
|
||||
async popularNovels(pageNo: number, {filters}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}`;
|
||||
|
||||
link += (filters?.genres ? `genero/` + filters.genres : "novelas");
|
||||
link += filters.genres ? `genero/` + filters.genres : "novelas";
|
||||
|
||||
link += `/page/${pageNo}`;
|
||||
|
||||
link += (filters?.order ? filters.order : "?m_orderby=rating")
|
||||
link += filters.order;
|
||||
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(link, {headers})
|
||||
const result = await fetchApi(link, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio(".page-item-detail").each((i,el) => {
|
||||
loadedCheerio(".page-item-detail").each((i, el) => {
|
||||
const novelName = loadedCheerio(el).find(".h5 > a").text();
|
||||
const novelCover = loadedCheerio(el).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(el).find(".h5 > a").attr("href");
|
||||
@@ -51,15 +54,15 @@ class TuNovelaLigera implements Plugin.PluginBase {
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
@@ -78,7 +81,7 @@ class TuNovelaLigera implements Plugin.PluginBase {
|
||||
novel.cover =
|
||||
novelCover.attr("data-src") ||
|
||||
novelCover.attr("src") ||
|
||||
novelCover.attr('data-cfsrc') ||
|
||||
novelCover.attr("data-cfsrc") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item").each(function () {
|
||||
@@ -114,14 +117,14 @@ class TuNovelaLigera implements Plugin.PluginBase {
|
||||
|
||||
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
|
||||
let lastPage = 1;
|
||||
lastPage = +loadedCheerio('.lcp_paginator li:last').prev().text();
|
||||
lastPage = +loadedCheerio(".lcp_paginator li:last").prev().text();
|
||||
|
||||
const getChapters = async () => {
|
||||
const n = url.split('/');
|
||||
const n = url.split("/");
|
||||
const novelName = n[4];
|
||||
showToast('Cargando desde Archivo...');
|
||||
showToast("Cargando desde Archivo...");
|
||||
|
||||
const formData = new FormData()
|
||||
const formData = new FormData();
|
||||
formData.append("action", "madara_load_more");
|
||||
formData.append("page", "0");
|
||||
formData.append("template", "html/loop/content");
|
||||
@@ -131,24 +134,25 @@ class TuNovelaLigera implements Plugin.PluginBase {
|
||||
const result = await fetchApi(
|
||||
`${this.site}wp-admin/admin-ajax.php`,
|
||||
{
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers
|
||||
},
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers,
|
||||
}
|
||||
);
|
||||
const text = await result.text();
|
||||
|
||||
loadedCheerio = parseHTML(text);
|
||||
|
||||
loadedCheerio('.heading').each((i, el) => {
|
||||
loadedCheerio(".heading").each((i, el) => {
|
||||
const chapterName = loadedCheerio(el)
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
.text()
|
||||
.replace(/[\t\n]/g, "")
|
||||
.trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(el).find('a').attr('href') || "";
|
||||
|
||||
chapter.push({
|
||||
const chapterUrl =
|
||||
loadedCheerio(el).find("a").attr("href") || "";
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
url: chapterUrl,
|
||||
releaseTime: releaseDate,
|
||||
@@ -156,56 +160,56 @@ class TuNovelaLigera implements Plugin.PluginBase {
|
||||
});
|
||||
return chapter.reverse();
|
||||
};
|
||||
|
||||
|
||||
const getPageChapters = async () => {
|
||||
for (let i = 1; i <= lastPage; i++) {
|
||||
const chaptersUrl = `${novelUrl}?lcp_page0=${i}`;
|
||||
showToast(`Cargando desde la página ${i}/${lastPage}...`);
|
||||
const result = await fetchApi(chaptersUrl, {headers});
|
||||
const result = await fetchApi(chaptersUrl, { headers });
|
||||
const chaptersHTML = await result.text();
|
||||
|
||||
let chapterCheerio = parseHTML(chaptersHTML);
|
||||
|
||||
chapterCheerio('.lcp_catlist li').each((i, el) => {
|
||||
chapterCheerio(".lcp_catlist li").each((i, el) => {
|
||||
const chapterName = chapterCheerio(el)
|
||||
.find('a')
|
||||
.find("a")
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.replace(/[\t\n]/g, "")
|
||||
.trim();
|
||||
|
||||
const releaseDate = chapterCheerio(el)
|
||||
.find('span')
|
||||
.find("span")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl =
|
||||
chapterCheerio(el).find('a').attr('href') || "";
|
||||
chapterCheerio(el).find("a").attr("href") || "";
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
await delay(1000);
|
||||
}
|
||||
return chapter.reverse();
|
||||
}
|
||||
};
|
||||
|
||||
novel.chapters = await getChapters();
|
||||
|
||||
if (!novel.chapters.length) {
|
||||
showToast('¡Archivo no encontrado!');
|
||||
showToast("¡Archivo no encontrado!");
|
||||
await delay(1000);
|
||||
novel.chapters = await getPageChapters();
|
||||
}
|
||||
|
||||
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(chapterUrl);
|
||||
@@ -213,13 +217,17 @@ class TuNovelaLigera implements Plugin.PluginBase {
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio("#hola_siguiente").next().find('div').remove();
|
||||
const chapterText = loadedCheerio("#hola_siguiente").next().html() || "";
|
||||
loadedCheerio("#hola_siguiente").next().find("div").remove();
|
||||
const chapterText =
|
||||
loadedCheerio("#hola_siguiente").next().html() || "";
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?s=${searchTerm}&post_type=wp-manga`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
@@ -238,136 +246,140 @@ class TuNovelaLigera implements Plugin.PluginBase {
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
}
|
||||
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url);
|
||||
}
|
||||
|
||||
filters = [
|
||||
{
|
||||
key: "order",
|
||||
filters = {
|
||||
order: {
|
||||
value: "?m_orderby=rating",
|
||||
label: "Ordenado por",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "Lo mas reciente", value: "?m_orderby=latest" },
|
||||
|
||||
{ label: "A-Z", value: "?m_orderby=alphabet" },
|
||||
|
||||
|
||||
{ label: "Clasificación", value: "?m_orderby=rating" },
|
||||
|
||||
|
||||
{ label: "Trending", value: "?m_orderby=trending" },
|
||||
|
||||
|
||||
{ label: "Mas visto", value: "?m_orderby=views" },
|
||||
|
||||
|
||||
{ label: "Nuevo", value: "?m_orderby=new-manga" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
genres: {
|
||||
value: "",
|
||||
label: "Generos",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "None", value: "" },
|
||||
{ label: "Acción", value: "accion" },
|
||||
|
||||
{ label: "Adulto", value: "adulto" },
|
||||
|
||||
|
||||
{ label: "Artes Marciales", value: "artes-marciales" },
|
||||
|
||||
|
||||
{ label: "Aventura", value: "aventura" },
|
||||
|
||||
|
||||
{ label: "Ciencia Ficción", value: "ciencia-ficcion" },
|
||||
|
||||
|
||||
{ label: "Comedia", value: "comedia" },
|
||||
|
||||
|
||||
{ label: "Deportes", value: "deportes" },
|
||||
|
||||
|
||||
{ label: "Drama", value: "drama" },
|
||||
|
||||
|
||||
{ label: "Eastern Fantasy", value: "eastern-fantasy" },
|
||||
|
||||
|
||||
{ label: "Ecchi", value: "ecchi" },
|
||||
|
||||
|
||||
{ label: "FanFiction", value: "fan-fiction" },
|
||||
|
||||
|
||||
{ label: "Fantasía", value: "fantasia" },
|
||||
|
||||
|
||||
{ label: "Fantasía oriental", value: "fantasia-oriental" },
|
||||
|
||||
|
||||
{ label: "Ficción Romántica", value: "ficcion-romantica" },
|
||||
|
||||
|
||||
{ label: "Gender Bender", value: "gender-bender" },
|
||||
|
||||
|
||||
{ label: "Harem", value: "harem" },
|
||||
|
||||
|
||||
{ label: "Histórico", value: "historico" },
|
||||
|
||||
|
||||
{ label: "Horror", value: "horror" },
|
||||
|
||||
|
||||
{ label: "Josei", value: "josei" },
|
||||
|
||||
|
||||
{ label: "Maduro", value: "maduro" },
|
||||
|
||||
|
||||
{ label: "Mecha", value: "mecha" },
|
||||
|
||||
|
||||
{ label: "Misterio", value: "misterio" },
|
||||
|
||||
|
||||
{ label: "Novela China", value: "novela-china" },
|
||||
|
||||
|
||||
{ label: "Novela FanFiction", value: "novela-fanfiction" },
|
||||
|
||||
|
||||
{ label: "Novela Japonesa", value: "novela-japonesa" },
|
||||
|
||||
|
||||
{ label: "Novela Koreana", value: "novela-koreana" },
|
||||
|
||||
|
||||
{ label: "Novela ligera", value: "novela-ligera" },
|
||||
|
||||
|
||||
{ label: "Novela original", value: "novela-original" },
|
||||
|
||||
|
||||
{ label: "Novela Web", value: "web-novel" },
|
||||
|
||||
|
||||
{ label: "Psicológico", value: "psicologico" },
|
||||
|
||||
|
||||
{ label: "Realismo Mágico", value: "realismo-magico" },
|
||||
|
||||
|
||||
{ label: "Recuento de vida", value: "recuento-de-vida" },
|
||||
|
||||
|
||||
{ label: "Romance", value: "romance" },
|
||||
|
||||
{ label: "Romance contemporáneo", value: "romance-contemporaneo" },
|
||||
|
||||
|
||||
{
|
||||
label: "Romance contemporáneo",
|
||||
value: "romance-contemporaneo",
|
||||
},
|
||||
|
||||
{ label: "Romance Moderno", value: "romance-moderno" },
|
||||
|
||||
|
||||
{ label: "Seinen", value: "seinen" },
|
||||
|
||||
|
||||
{ label: "Shoujo", value: "shoujo" },
|
||||
|
||||
|
||||
{ label: "Shounen", value: "shounen" },
|
||||
|
||||
|
||||
{ label: "Sobrenatural", value: "sobrenatural" },
|
||||
|
||||
|
||||
{ label: "Tragedia", value: "tragedia" },
|
||||
|
||||
|
||||
{ label: "Vampiros", value: "vampiros" },
|
||||
|
||||
|
||||
{ label: "Vida Escolar", value: "vida-escolar" },
|
||||
|
||||
|
||||
{ label: "Western Fantasy", value: "western-fantasy" },
|
||||
|
||||
|
||||
{ label: "Wuxia", value: "wuxia" },
|
||||
|
||||
|
||||
{ label: "Xianxia", value: "xianxia" },
|
||||
|
||||
|
||||
{ label: "Xuanhuan", value: "xuanhuan" },
|
||||
|
||||
|
||||
{ label: "Yaoi", value: "yaoi" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
];
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new TuNovelaLigera();
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"turkcelightnovels","sourceSite":"https://turkcelightnovels.com/","sourceName":"TurkceLightNovels","filters":[{"key":"sort","label":"Order by","values":[{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"inputType":1}],"options":{"path":{"novels":"light-novel","novel":"light-novel","chapter":"light-novel"},"lang":"Turkish"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"turkcelightnovels","sourceSite":"https://turkcelightnovels.com/","sourceName":"TurkceLightNovels","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"light-novel","novel":"light-novel","chapter":"light-novel"},"lang":"Turkish"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
import { Plugin } from '@typings/plugin'
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
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";
|
||||
|
||||
interface MadaraOptionPath{
|
||||
genres?: string,
|
||||
novels?: string,
|
||||
novel?: string,
|
||||
chapter?: string,
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath: MadaraOptionPath = {
|
||||
novels: 'novel',
|
||||
novel: 'novel',
|
||||
chapter: 'novel'
|
||||
}
|
||||
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?: Filter[],
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
@@ -44,12 +44,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName.replace(/\s+/g, "").toLowerCase();
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
@@ -58,188 +60,219 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
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 && this.options?.path?.genres) {
|
||||
if (filters?.genres && this.options?.path?.genres) {
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
url += this.options?.path?.novels
|
||||
? this.options.path.novels
|
||||
: MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url += '/page/' + pageNo + '/' +
|
||||
'?m_orderby=' + (showLatestNovels ? 'latest' : (filters?.sort || 'rating'));
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
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');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
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");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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("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();
|
||||
|
||||
|
||||
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, ',');
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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',
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => res.text());
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
novelUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
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')
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
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(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
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 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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -247,6 +280,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
const plugin = new MadaraPlugin({"id":"webnoveloku","sourceSite":"https://www.webnoveloku.com/","sourceName":"WebNovelOku ","filters":[{"key":"sort","label":"Sırala","values":[{"label":"A-Z","value":"alphabet"},{"label":"En Son","value":"latest"},{"label":"Görüntülenme","value":"views"},{"label":"Popülarite","value":"trending"},{"label":"Reyting","value":"rating"},{"label":"Yeni","value":"new-manga"}],"inputType":1}],"options":{"lang":"Turkish"}});
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"webnoveloku","sourceSite":"https://www.webnoveloku.com/","sourceName":"WebNovelOku ","filters":{"sort":{"label":"Sırala","value":"","options":[{"label":"Default","value":""},{"label":"A-Z","value":"alphabet"},{"label":"En Son","value":"latest"},{"label":"Görüntülenme","value":"views"},{"label":"Popülarite","value":"trending"},{"label":"Reyting","value":"rating"},{"label":"Yeni","value":"new-manga"}],"type":FilterTypes.Picker}},"options":{"lang":"Turkish"}});
|
||||
export default plugin;
|
||||
|
||||
+51
-42
@@ -1,6 +1,6 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
|
||||
class LSHNovel implements Plugin.PluginBase {
|
||||
@@ -11,26 +11,28 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
version = "1.0.0";
|
||||
userAgent = "";
|
||||
cookieString = "";
|
||||
async popularNovels(pageNo: number, {filters}: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}series/?page=${pageNo}`;
|
||||
|
||||
if (filters) {
|
||||
if (Array.isArray(filters.genres) && filters.genres.length) {
|
||||
link += filters.genres.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
|
||||
if (Array.isArray(filters.type) && filters.type.length)
|
||||
link += filters.type.map((i) => `&lang[]=${i}`).join("");
|
||||
if (filters.genres.value.length) {
|
||||
link += filters.genres.value.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
link += "&status=" + (filters?.status ? filters.status : "");
|
||||
|
||||
link += "&order=" + (filters?.order ? filters.order : "popular");
|
||||
if (filters.type.value.length)
|
||||
link += filters.type.value.map((i) => `&lang[]=${i}`).join("");
|
||||
|
||||
link += "&status=" + filters.status;
|
||||
|
||||
link += "&order=" + filters.order;
|
||||
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const body = await fetchApi(link, {headers}).then((result) =>
|
||||
const body = await fetchApi(link, { headers }).then((result) =>
|
||||
result.text()
|
||||
);
|
||||
|
||||
@@ -57,15 +59,15 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
@@ -83,7 +85,12 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
|
||||
loadedCheerio("div.spe > span").each(function () {
|
||||
const detailName = loadedCheerio(this).find("b").text().trim();
|
||||
const detail = loadedCheerio(this).find('b').remove().end().text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find("b")
|
||||
.remove()
|
||||
.end()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Yazar:":
|
||||
@@ -139,10 +146,10 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(chapterUrl, {headers});
|
||||
const result = await fetchApi(chapterUrl, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -152,13 +159,16 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?s=${searchTerm}`;
|
||||
const headers = new Headers();
|
||||
if(this.cookieString){
|
||||
if (this.cookieString) {
|
||||
headers.append("cookie", this.cookieString);
|
||||
}
|
||||
const result = await fetchApi(url, {headers});
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -184,12 +194,11 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
return await fetchFile(url);
|
||||
}
|
||||
|
||||
|
||||
filters = [
|
||||
{
|
||||
key: "order",
|
||||
filters = {
|
||||
order: {
|
||||
value: "popular",
|
||||
label: "Önerilen",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "Varsayılan", value: "" },
|
||||
|
||||
{ label: "A-Z", value: "title" },
|
||||
@@ -202,12 +211,12 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Bestimiz", value: "popular" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
status: {
|
||||
label: "Statü",
|
||||
values: [
|
||||
value: "",
|
||||
options: [
|
||||
{ label: "Tümü", value: "" },
|
||||
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
@@ -216,12 +225,12 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
type: {
|
||||
value: [],
|
||||
label: "Tür",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "Çeviri Novel", value: "ceviri-novel" },
|
||||
|
||||
{ label: "Liz-Chan", value: "liz-chan" },
|
||||
@@ -232,12 +241,12 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Web Novel", value: "web-novel" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
genres: {
|
||||
value: [],
|
||||
label: "Kategori",
|
||||
values: [
|
||||
options: [
|
||||
{ label: "+18", value: "18" },
|
||||
|
||||
{ label: "Action", value: "action" },
|
||||
@@ -306,9 +315,9 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
|
||||
{ label: "Yaoi", value: "yaoi" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
];
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new LSHNovel();
|
||||
export default new LSHNovel();
|
||||
|
||||
@@ -2,7 +2,6 @@ import { CheerioAPI, load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { isUrlAbsolute } from "@libs/isAbsoluteUrl";
|
||||
import { Filter } from "@libs/filterInputs";
|
||||
class HakoPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -11,7 +10,7 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
constructor(){
|
||||
constructor() {
|
||||
this.id = "ln.hako";
|
||||
this.name = "Hako";
|
||||
this.icon = "src/vi/hakolightnovel/icon.png";
|
||||
@@ -20,7 +19,7 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
}
|
||||
parseNovels(loadedCheerio: CheerioAPI){
|
||||
parseNovels(loadedCheerio: CheerioAPI) {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio(".row > .thumb-item-flow").each((index, ele) => {
|
||||
let url = loadedCheerio(ele)
|
||||
@@ -44,15 +43,21 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
cover = this.site + cover;
|
||||
}
|
||||
|
||||
const novel = {name, url, cover};
|
||||
const novel = { name, url, cover };
|
||||
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions): Promise<Plugin.NovelItem[]> {
|
||||
const link = this.site + "/danh-sach?truyendich=1&sapxep=topthang&page=" + pageNo;
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const link =
|
||||
this.site +
|
||||
"/danh-sach?truyendich=1&sapxep=topthang&page=" +
|
||||
pageNo;
|
||||
const result = await fetch(link);
|
||||
const body = await result.text();
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -64,32 +69,33 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
};
|
||||
const result = await fetch(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
novel.name = loadedCheerio(".series-name").text();
|
||||
|
||||
|
||||
const background =
|
||||
loadedCheerio(".series-cover > .a6-ratio > div").attr("style") || "";
|
||||
loadedCheerio(".series-cover > .a6-ratio > div").attr("style") ||
|
||||
"";
|
||||
const novelCover = background.substring(
|
||||
background.indexOf("http"),
|
||||
background.length - 2
|
||||
);
|
||||
|
||||
|
||||
novel.cover = novelCover
|
||||
? isUrlAbsolute(novelCover)
|
||||
? novelCover
|
||||
: this.site + novelCover
|
||||
: "";
|
||||
|
||||
|
||||
novel.summary = loadedCheerio(".summary-content").text().trim();
|
||||
|
||||
|
||||
novel.author = loadedCheerio(
|
||||
"#mainpart > div:nth-child(2) > div > div:nth-child(1) > section > main > div.top-part > div > div.col-12.col-md-9 > div.series-information > div:nth-child(2) > span.info-value > a"
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
novel.genres = loadedCheerio(".series-gernes")
|
||||
.text()
|
||||
.trim()
|
||||
@@ -97,21 +103,21 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
.split("\n")
|
||||
.filter((e) => e.trim())
|
||||
.join(", ");
|
||||
|
||||
|
||||
novel.status = loadedCheerio(
|
||||
"#mainpart > div:nth-child(2) > div > div:nth-child(1) > section > main > div.top-part > div > div.col-12.col-md-9 > div.series-information > div:nth-child(4) > span.info-value > a"
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".list-chapters li").each((index, ele) => {
|
||||
let chapterUrl = loadedCheerio(ele).find("a").attr("href");
|
||||
|
||||
|
||||
if (chapterUrl && !isUrlAbsolute(chapterUrl)) {
|
||||
chapterUrl = this.site + chapterUrl;
|
||||
}
|
||||
|
||||
|
||||
if (chapterUrl) {
|
||||
const chapterName = loadedCheerio(ele)
|
||||
.find(".chapter-name")
|
||||
@@ -120,13 +126,13 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
const releaseTime = loadedCheerio(ele)
|
||||
.find(".chapter-time")
|
||||
.text();
|
||||
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseTime,
|
||||
url: chapterUrl,
|
||||
};
|
||||
|
||||
|
||||
chapters.push(chapter);
|
||||
}
|
||||
});
|
||||
@@ -143,7 +149,10 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo?: number | undefined): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + "/tim-kiem?keywords=" + searchTerm;
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
Reference in New Issue
Block a user