plugin refactoring (#639)
* fix * fix * madara plugins cleaned Error: net::ERR_NAME_NOT_RESOLVED at https://cratenovel.com/novel/page/1?m_orderby=latest Error: net::ERR_SSL_PROTOCOL_ERROR at https://clicknovel.net/novel/page/1?m_orderby=latest Error: net::ERR_NAME_NOT_RESOLVED at https://www.onlymtl.com/novel/page/1?m_orderby=latest Error: net::ERR_TOO_MANY_REDIRECTS at https://mtlnovel.club/novel/page/1?m_orderby=latest Error: net::ERR_NAME_NOT_RESOLVED at https://noobchan.xyz/novel/page/1?m_orderby=latest * readwn * .
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { FilterInputs } from "../../../libs/filterInputs";
|
||||
import { ScrpitGeneratorFunction } from "../generate";
|
||||
import list from "./sources.json";
|
||||
import { MadaraMetadata } from "./template";
|
||||
import { readFileSync } from 'fs';
|
||||
import { readFileSync } from "fs";
|
||||
import path from "path";
|
||||
|
||||
|
||||
@@ -14,7 +15,12 @@ export const generateAll: ScrpitGeneratorFunction = function () {
|
||||
const generator = function generator(metadata: MadaraMetadata) {
|
||||
const lang = metadata.options?.lang || "English";
|
||||
|
||||
const madaraTemplate = readFileSync(path.join(__dirname, 'template.ts'), {encoding: 'utf-8'});
|
||||
const madaraTemplate = readFileSync(path.join(__dirname, "template.ts"), {encoding: "utf-8"});
|
||||
metadata.filters = metadata.filters?.map((filter: any) => ({
|
||||
...filter,
|
||||
inputType: FilterInputs[filter.inputType]
|
||||
}));
|
||||
|
||||
const pluginScript = `
|
||||
${madaraTemplate}
|
||||
const plugin = new MadaraPlugin(${JSON.stringify(metadata)});
|
||||
|
||||
@@ -2555,25 +2555,6 @@
|
||||
"lang": "English"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "cratenovel",
|
||||
"sourceSite": "https://cratenovel.com/",
|
||||
"sourceName": "CrateNovel",
|
||||
"filters": [],
|
||||
"options": {
|
||||
"useNewChapterEndpoint": true,
|
||||
"lang": "English"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "clicknovel",
|
||||
"sourceSite": "https://clicknovel.net/",
|
||||
"sourceName": "ClickNovel",
|
||||
"filters": [],
|
||||
"options": {
|
||||
"lang": "English"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "readwebnovels",
|
||||
"sourceSite": "https://readwebnovels.net/",
|
||||
@@ -3233,16 +3214,6 @@
|
||||
"lang": "Indonesian"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "onlymtl",
|
||||
"sourceSite": "https://www.onlymtl.com/",
|
||||
"sourceName": "OnlyMTL",
|
||||
"filters": [],
|
||||
"options": {
|
||||
"useNewChapterEndpoint": true,
|
||||
"lang": "English"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "hizomanga",
|
||||
"sourceSite": "https://hizomanga.com/",
|
||||
@@ -3889,26 +3860,6 @@
|
||||
"lang": "English"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "mtlnovel.club",
|
||||
"sourceSite": "https://mtlnovel.club/",
|
||||
"sourceName": "MTLNovel.Club",
|
||||
"filters": [],
|
||||
"options": {
|
||||
"useNewChapterEndpoint": true,
|
||||
"lang": "English"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "noobchanTL",
|
||||
"sourceSite": "https://noobchan.xyz/",
|
||||
"sourceName": "Noobchan Translation",
|
||||
"filters": [],
|
||||
"options": {
|
||||
"useNewChapterEndpoint": true,
|
||||
"lang": "English"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "guavaread",
|
||||
"sourceSite": "https://guavaread.com/",
|
||||
@@ -5314,7 +5265,6 @@
|
||||
],
|
||||
"options": {
|
||||
"path": {
|
||||
"novels": "novel",
|
||||
"novel": "manga",
|
||||
"chapter": "manga"
|
||||
},
|
||||
|
||||
@@ -43,7 +43,7 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filter?: Filter[] | undefined;
|
||||
filters?: Filter[] | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata){
|
||||
this.id = metadata.id;
|
||||
@@ -55,14 +55,14 @@ class MadaraPlugin implements Plugin.PluginBase {
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filter = metadata.filters;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions): 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 + '/';
|
||||
url += this.options?.path?.genres + filters.genres;
|
||||
} else {
|
||||
url += this.options?.path?.novels ? this.options.path.novels : MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user