Multisrc added (#911)
* create lightnovelworld multisrc * fix: change lightnovelworld id to webnovelworld * added lightnovelworld * added lightnovelpubvip * added lightnovelcave * added wuxiaspace
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,40 @@
|
||||
import { ScrpitGeneratorFunction } from '../generate';
|
||||
import { LightNovelWorldMetadata } from './template';
|
||||
import list from './sources.json';
|
||||
import { readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export const generateAll: ScrpitGeneratorFunction = function (name) {
|
||||
return list.map((source: LightNovelWorldMetadata) => {
|
||||
let filters: any = {};
|
||||
try {
|
||||
filters = require(`./filters/${source.id}`);
|
||||
source.filters = filters.filters;
|
||||
} catch (e) {}
|
||||
console.log(
|
||||
`[${name}] Generating: ${source.id}${' '.repeat(20 - source.id.length)} ${source.filters ? '🔎with filters🔍' : '🚫no filters🚫'}`,
|
||||
);
|
||||
return generator(source);
|
||||
});
|
||||
};
|
||||
|
||||
const generator = function generator(source: LightNovelWorldMetadata) {
|
||||
const LightNovelWPTemplate = readFileSync(
|
||||
path.join(__dirname, 'template.ts'),
|
||||
{
|
||||
encoding: 'utf-8',
|
||||
},
|
||||
);
|
||||
|
||||
const pluginScript = `
|
||||
${LightNovelWPTemplate}
|
||||
const plugin = new LightNovelWorld(${JSON.stringify(source)});
|
||||
export default plugin;
|
||||
`.trim();
|
||||
|
||||
return {
|
||||
lang: source.options?.lang || 'English',
|
||||
filename: source.sourceName,
|
||||
pluginScript,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"id": "webnovelworld",
|
||||
"sourceName": "Web Novel Pub",
|
||||
"sourceSite": "https://www.webnovelworld.org/"
|
||||
},
|
||||
{
|
||||
"id": "lightnovelworld",
|
||||
"sourceName": "LightNovelWord",
|
||||
"sourceSite": "https://www.lightnovelworld.com/"
|
||||
},
|
||||
{
|
||||
"id": "lightnovelpubvip",
|
||||
"sourceName": "LightNovelPub Vip",
|
||||
"sourceSite": "https://lightnovelpub.vip/"
|
||||
},
|
||||
{
|
||||
"id": "lightnovelcave",
|
||||
"sourceName": "LightNovelCave",
|
||||
"sourceSite": "https://www.lightnovelcave.com/"
|
||||
}
|
||||
]
|
||||
@@ -4,16 +4,40 @@ import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
interface LightNovelWorldOptions {
|
||||
lang?: string;
|
||||
versionIncrements?: number;
|
||||
}
|
||||
|
||||
export interface LightNovelWorldMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: LightNovelWorldOptions;
|
||||
filters?: any;
|
||||
}
|
||||
|
||||
class LightNovelWorld implements Plugin.PagePlugin {
|
||||
id = 'lightnovelworld';
|
||||
name = 'LightNovelWorld';
|
||||
site = 'https://www.webnovelworld.org/';
|
||||
version = '1.0.1';
|
||||
icon = 'src/en/lightnovelworld/icon.png';
|
||||
id: string;
|
||||
name: string;
|
||||
site: string;
|
||||
version: string;
|
||||
icon: string;
|
||||
headers = {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
options?: LightNovelWorldOptions;
|
||||
|
||||
constructor(metadata: LightNovelWorldMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName;
|
||||
this.icon = `multisrc/lightnovelworld/${metadata.id.toLowerCase()}/icon.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
const versionIncrements = metadata.options?.versionIncrements || 0;
|
||||
this.version = `1.0.${1 + versionIncrements}`;
|
||||
this.options = metadata.options;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
@@ -139,19 +163,15 @@ class LightNovelWorld implements Plugin.PagePlugin {
|
||||
let formData = new FormData();
|
||||
formData.append('inputContent', searchTerm);
|
||||
|
||||
const body = await fetchApi(url, {
|
||||
const results = await fetchApi(url, {
|
||||
method: 'POST',
|
||||
headers: { LNRequestVerifyToken: verifytoken! },
|
||||
body: formData,
|
||||
}).then(r => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
}).then(r => r.json());
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let results = JSON.parse(loadedCheerio('body').text());
|
||||
|
||||
loadedCheerio = parseHTML(results.resultview);
|
||||
const loadedCheerio = parseHTML(results.resultview);
|
||||
|
||||
loadedCheerio('.novel-item').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).find('h4.novel-title').text().trim();
|
||||
@@ -244,5 +264,3 @@ class LightNovelWorld implements Plugin.PagePlugin {
|
||||
},
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new LightNovelWorld();
|
||||
@@ -23,5 +23,10 @@
|
||||
"id": "fannovel",
|
||||
"sourceSite": "https://www.fannovel.com",
|
||||
"sourceName": "FanNovel"
|
||||
},
|
||||
{
|
||||
"id": "wuxiaspace",
|
||||
"sourceSite": "https://www.wuxiaspace.com",
|
||||
"sourceName": "Wuxia Space"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user