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:
nyagami
2024-04-27 18:55:55 +07:00
committed by GitHub
parent dfb3f0a011
commit 886e6474f2
9 changed files with 99 additions and 14 deletions
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 { Filters, FilterTypes } from '@libs/filterInputs';
import dayjs from 'dayjs'; 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 { class LightNovelWorld implements Plugin.PagePlugin {
id = 'lightnovelworld'; id: string;
name = 'LightNovelWorld'; name: string;
site = 'https://www.webnovelworld.org/'; site: string;
version = '1.0.1'; version: string;
icon = 'src/en/lightnovelworld/icon.png'; icon: string;
headers = { headers = {
Accept: 'application/json', Accept: 'application/json',
'Content-Type': '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( async popularNovels(
page: number, page: number,
@@ -139,19 +163,15 @@ class LightNovelWorld implements Plugin.PagePlugin {
let formData = new FormData(); let formData = new FormData();
formData.append('inputContent', searchTerm); formData.append('inputContent', searchTerm);
const body = await fetchApi(url, { const results = await fetchApi(url, {
method: 'POST', method: 'POST',
headers: { LNRequestVerifyToken: verifytoken! }, headers: { LNRequestVerifyToken: verifytoken! },
body: formData, body: formData,
}).then(r => r.text()); }).then(r => r.json());
let loadedCheerio = parseHTML(body);
let novels: Plugin.NovelItem[] = []; let novels: Plugin.NovelItem[] = [];
let results = JSON.parse(loadedCheerio('body').text()); const loadedCheerio = parseHTML(results.resultview);
loadedCheerio = parseHTML(results.resultview);
loadedCheerio('.novel-item').each((idx, ele) => { loadedCheerio('.novel-item').each((idx, ele) => {
const novelName = loadedCheerio(ele).find('h4.novel-title').text().trim(); const novelName = loadedCheerio(ele).find('h4.novel-title').text().trim();
@@ -244,5 +264,3 @@ class LightNovelWorld implements Plugin.PagePlugin {
}, },
} satisfies Filters; } satisfies Filters;
} }
export default new LightNovelWorld();
+5
View File
@@ -23,5 +23,10 @@
"id": "fannovel", "id": "fannovel",
"sourceSite": "https://www.fannovel.com", "sourceSite": "https://www.fannovel.com",
"sourceName": "FanNovel" "sourceName": "FanNovel"
},
{
"id": "wuxiaspace",
"sourceSite": "https://www.wuxiaspace.com",
"sourceName": "Wuxia Space"
} }
] ]