feat(multirsrc): move lightnovelworld to webnovelworld and retire them (#2347)
Signed-off-by: K1ngfish3r <26593485+K1ngfish3r@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"filters": {
|
||||
"order": {
|
||||
"value": "popular",
|
||||
"label": "Order by",
|
||||
"options": [
|
||||
{ "label": "New", "value": "new" },
|
||||
{ "label": "Popular", "value": "popular" },
|
||||
{ "label": "Updates", "value": "updated" }
|
||||
],
|
||||
"type": "Picker"
|
||||
},
|
||||
"status": {
|
||||
"value": "all",
|
||||
"label": "Status",
|
||||
"options": [
|
||||
{ "label": "All", "value": "all" },
|
||||
{ "label": "Completed", "value": "completed" },
|
||||
{ "label": "Ongoing", "value": "ongoing" }
|
||||
],
|
||||
"type": "Picker"
|
||||
},
|
||||
"genres": {
|
||||
"value": "all",
|
||||
"label": "Genre",
|
||||
"options": [
|
||||
{ "label": "All", "value": "all" },
|
||||
{ "label": "Action", "value": "action" },
|
||||
{ "label": "Adventure", "value": "adventure" },
|
||||
{ "label": "Drama", "value": "drama" },
|
||||
{ "label": "Fantasy", "value": "fantasy" },
|
||||
{ "label": "Harem", "value": "harem" },
|
||||
{ "label": "Martial Arts", "value": "martial-arts" },
|
||||
{ "label": "Mature", "value": "mature" },
|
||||
{ "label": "Romance", "value": "romance" },
|
||||
{ "label": "Tragedy", "value": "tragedy" },
|
||||
{ "label": "Xuanhuan", "value": "xuanhuan" },
|
||||
{ "label": "Ecchi", "value": "ecchi" },
|
||||
{ "label": "Comedy", "value": "comedy" },
|
||||
{ "label": "Slice of Life", "value": "slice-of-life" },
|
||||
{ "label": "Mystery", "value": "mystery" },
|
||||
{ "label": "Supernatural", "value": "supernatural" },
|
||||
{ "label": "Psychological", "value": "psychological" },
|
||||
{ "label": "Sci-fi", "value": "sci-fi" },
|
||||
{ "label": "Xianxia", "value": "xianxia" },
|
||||
{ "label": "School Life", "value": "school-life" },
|
||||
{ "label": "Josei", "value": "josei" },
|
||||
{ "label": "Wuxia", "value": "wuxia" },
|
||||
{ "label": "Shounen", "value": "shounen" },
|
||||
{ "label": "Horror", "value": "horror" },
|
||||
{ "label": "Mecha", "value": "mecha" },
|
||||
{ "label": "Historical", "value": "historical" },
|
||||
{ "label": "Shoujo", "value": "shoujo" },
|
||||
{ "label": "Adult", "value": "adult" },
|
||||
{ "label": "Seinen", "value": "seinen" },
|
||||
{ "label": "Sports", "value": "sports" },
|
||||
{ "label": "Lolicon", "value": "lolicon" },
|
||||
{ "label": "Gender Bender", "value": "gender-bender" },
|
||||
{ "label": "Shounen Ai", "value": "shounen-ai" },
|
||||
{ "label": "Yaoi", "value": "yaoi" },
|
||||
{ "label": "Video Games", "value": "video-games" },
|
||||
{ "label": "Smut", "value": "smut" },
|
||||
{ "label": "Magical Realism", "value": "magical-realism" },
|
||||
{ "label": "Eastern Fantasy", "value": "eastern-fantasy" },
|
||||
{ "label": "Contemporary Romance", "value": "contemporary-romance" },
|
||||
{ "label": "Fantasy Romance", "value": "fantasy-romance" },
|
||||
{ "label": "Shoujo Ai", "value": "shoujo-ai" },
|
||||
{ "label": "Yuri", "value": "yuri" }
|
||||
],
|
||||
"type": "Picker"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"filters": {
|
||||
"order": {
|
||||
"value": "popular",
|
||||
"label": "Order by",
|
||||
"options": [
|
||||
{ "label": "New", "value": "new" },
|
||||
{ "label": "Popular", "value": "popular" },
|
||||
{ "label": "Updates", "value": "updated" }
|
||||
],
|
||||
"type": "Picker"
|
||||
},
|
||||
"status": {
|
||||
"value": "all",
|
||||
"label": "Status",
|
||||
"options": [
|
||||
{ "label": "All", "value": "all" },
|
||||
{ "label": "Completed", "value": "completed" },
|
||||
{ "label": "Ongoing", "value": "ongoing" }
|
||||
],
|
||||
"type": "Picker"
|
||||
},
|
||||
"genres": {
|
||||
"value": "all",
|
||||
"label": "Genre",
|
||||
"options": [
|
||||
{ "label": "All", "value": "all" },
|
||||
{ "label": "Action", "value": "action" },
|
||||
{ "label": "Adventure", "value": "adventure" },
|
||||
{ "label": "Drama", "value": "drama" },
|
||||
{ "label": "Fantasy", "value": "fantasy" },
|
||||
{ "label": "Harem", "value": "harem" },
|
||||
{ "label": "Martial Arts", "value": "martial-arts" },
|
||||
{ "label": "Mature", "value": "mature" },
|
||||
{ "label": "Romance", "value": "romance" },
|
||||
{ "label": "Tragedy", "value": "tragedy" },
|
||||
{ "label": "Xuanhuan", "value": "xuanhuan" },
|
||||
{ "label": "Ecchi", "value": "ecchi" },
|
||||
{ "label": "Comedy", "value": "comedy" },
|
||||
{ "label": "Slice of Life", "value": "slice-of-life" },
|
||||
{ "label": "Mystery", "value": "mystery" },
|
||||
{ "label": "Supernatural", "value": "supernatural" },
|
||||
{ "label": "Psychological", "value": "psychological" },
|
||||
{ "label": "Sci-fi", "value": "sci-fi" },
|
||||
{ "label": "Xianxia", "value": "xianxia" },
|
||||
{ "label": "School Life", "value": "school-life" },
|
||||
{ "label": "Josei", "value": "josei" },
|
||||
{ "label": "Wuxia", "value": "wuxia" },
|
||||
{ "label": "Shounen", "value": "shounen" },
|
||||
{ "label": "Horror", "value": "horror" },
|
||||
{ "label": "Mecha", "value": "mecha" },
|
||||
{ "label": "Historical", "value": "historical" },
|
||||
{ "label": "Shoujo", "value": "shoujo" },
|
||||
{ "label": "Adult", "value": "adult" },
|
||||
{ "label": "Seinen", "value": "seinen" },
|
||||
{ "label": "Sports", "value": "sports" },
|
||||
{ "label": "Lolicon", "value": "lolicon" },
|
||||
{ "label": "Gender Bender", "value": "gender-bender" },
|
||||
{ "label": "Shounen Ai", "value": "shounen-ai" },
|
||||
{ "label": "Yaoi", "value": "yaoi" },
|
||||
{ "label": "Video Games", "value": "video-games" },
|
||||
{ "label": "Smut", "value": "smut" },
|
||||
{ "label": "Magical Realism", "value": "magical-realism" },
|
||||
{ "label": "Eastern Fantasy", "value": "eastern-fantasy" },
|
||||
{ "label": "Contemporary Romance", "value": "contemporary-romance" },
|
||||
{ "label": "Fantasy Romance", "value": "fantasy-romance" },
|
||||
{ "label": "Shoujo Ai", "value": "shoujo-ai" },
|
||||
{ "label": "Yuri", "value": "yuri" }
|
||||
],
|
||||
"type": "Picker"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"filters": {
|
||||
"order": {
|
||||
"value": "popular",
|
||||
"label": "Order by",
|
||||
"options": [
|
||||
{ "label": "New", "value": "new" },
|
||||
{ "label": "Popular", "value": "popular" },
|
||||
{ "label": "Updates", "value": "updated" }
|
||||
],
|
||||
"type": "Picker"
|
||||
},
|
||||
"status": {
|
||||
"value": "all",
|
||||
"label": "Status",
|
||||
"options": [
|
||||
{ "label": "All", "value": "all" },
|
||||
{ "label": "Completed", "value": "completed" },
|
||||
{ "label": "Ongoing", "value": "ongoing" }
|
||||
],
|
||||
"type": "Picker"
|
||||
},
|
||||
"genres": {
|
||||
"value": "all",
|
||||
"label": "Genre",
|
||||
"options": [
|
||||
{ "label": "All", "value": "all" },
|
||||
{ "label": "Action", "value": "action" },
|
||||
{ "label": "Adventure", "value": "adventure" },
|
||||
{ "label": "Drama", "value": "drama" },
|
||||
{ "label": "Fantasy", "value": "fantasy" },
|
||||
{ "label": "Harem", "value": "harem" },
|
||||
{ "label": "Martial Arts", "value": "martial-arts" },
|
||||
{ "label": "Mature", "value": "mature" },
|
||||
{ "label": "Romance", "value": "romance" },
|
||||
{ "label": "Tragedy", "value": "tragedy" },
|
||||
{ "label": "Xuanhuan", "value": "xuanhuan" },
|
||||
{ "label": "Ecchi", "value": "ecchi" },
|
||||
{ "label": "Comedy", "value": "comedy" },
|
||||
{ "label": "Slice of Life", "value": "slice-of-life" },
|
||||
{ "label": "Mystery", "value": "mystery" },
|
||||
{ "label": "Supernatural", "value": "supernatural" },
|
||||
{ "label": "Psychological", "value": "psychological" },
|
||||
{ "label": "Sci-fi", "value": "sci-fi" },
|
||||
{ "label": "Xianxia", "value": "xianxia" },
|
||||
{ "label": "School Life", "value": "school-life" },
|
||||
{ "label": "Josei", "value": "josei" },
|
||||
{ "label": "Wuxia", "value": "wuxia" },
|
||||
{ "label": "Shounen", "value": "shounen" },
|
||||
{ "label": "Horror", "value": "horror" },
|
||||
{ "label": "Mecha", "value": "mecha" },
|
||||
{ "label": "Historical", "value": "historical" },
|
||||
{ "label": "Shoujo", "value": "shoujo" },
|
||||
{ "label": "Adult", "value": "adult" },
|
||||
{ "label": "Seinen", "value": "seinen" },
|
||||
{ "label": "Sports", "value": "sports" },
|
||||
{ "label": "Lolicon", "value": "lolicon" },
|
||||
{ "label": "Gender Bender", "value": "gender-bender" },
|
||||
{ "label": "Shounen Ai", "value": "shounen-ai" },
|
||||
{ "label": "Yaoi", "value": "yaoi" },
|
||||
{ "label": "Video Games", "value": "video-games" },
|
||||
{ "label": "Smut", "value": "smut" },
|
||||
{ "label": "Magical Realism", "value": "magical-realism" },
|
||||
{ "label": "Eastern Fantasy", "value": "eastern-fantasy" },
|
||||
{ "label": "Contemporary Romance", "value": "contemporary-romance" },
|
||||
{ "label": "Fantasy Romance", "value": "fantasy-romance" },
|
||||
{ "label": "Shoujo Ai", "value": "shoujo-ai" },
|
||||
{ "label": "Yuri", "value": "yuri" }
|
||||
],
|
||||
"type": "Picker"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import list from './sources.json' with { type: 'json' };
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
|
||||
const folder = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
export const generateAll = function () {
|
||||
return list.map(source => {
|
||||
const exist = existsSync(join(folder, 'filters', source.id + '.json'));
|
||||
if (exist) {
|
||||
const filters = readFileSync(
|
||||
join(folder, 'filters', source.id + '.json'),
|
||||
);
|
||||
source.filters = JSON.parse(filters).filters;
|
||||
}
|
||||
console.log(
|
||||
`[webnovelworld] Generating: ${source.id}${' '.repeat(20 - source.id.length)} ${source.filters ? '🔎with filters🔍' : '🚫no filters🚫'}`,
|
||||
);
|
||||
return generator(source);
|
||||
});
|
||||
};
|
||||
|
||||
const generator = function generator(source) {
|
||||
const LightNovelWPTemplate = readFileSync(join(folder, 'template.ts'), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
const pluginScript = `
|
||||
${LightNovelWPTemplate}
|
||||
const plugin = new WebNovelWorld(${JSON.stringify(source)});
|
||||
export default plugin;
|
||||
`.trim();
|
||||
|
||||
return {
|
||||
lang: source.options?.lang || 'English',
|
||||
filename: source.sourceName,
|
||||
pluginScript,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
[
|
||||
{
|
||||
"id": "webnovelworld",
|
||||
"sourceName": "Web Novel Pub",
|
||||
"sourceSite": "https://www.webnovelworld.org/",
|
||||
"options": {
|
||||
"down": true,
|
||||
"downSince": 1768289212945
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lightnovelpubvip",
|
||||
"sourceName": "LightNovelPub Vip",
|
||||
"sourceSite": "https://lightnovelpub.vip/",
|
||||
"options": {
|
||||
"down": true,
|
||||
"downSince": 1768289212945
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lightnovelcave",
|
||||
"sourceName": "LightNovelCave",
|
||||
"sourceSite": "https://www.lightnovelcave.com/",
|
||||
"options": {
|
||||
"down": true,
|
||||
"downSince": 1768289212945
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,198 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@/types/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
type WebNovelWorldOptions = {
|
||||
lang?: string;
|
||||
versionIncrements?: number;
|
||||
down?: boolean;
|
||||
downSince?: number;
|
||||
};
|
||||
|
||||
export type WebNovelWorldMetadata = {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: WebNovelWorldOptions;
|
||||
filters?: Filters;
|
||||
};
|
||||
|
||||
export class WebNovelWorld implements Plugin.PagePlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
site: string;
|
||||
version: string;
|
||||
icon: string;
|
||||
headers = {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
imageRequestInit?: Plugin.ImageRequestInit | undefined = {
|
||||
headers: this.headers,
|
||||
};
|
||||
options?: WebNovelWorldOptions;
|
||||
filters?: Filters;
|
||||
|
||||
constructor(metadata: WebNovelWorldMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName;
|
||||
this.icon = `multisrc/webnovelworld/${metadata.id.toLowerCase()}/icon.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
const versionIncrements = metadata.options?.versionIncrements || 0;
|
||||
this.version = `1.0.${2 + versionIncrements}`;
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}browse/`;
|
||||
link += `${filters?.genres?.value || 'all'}/`;
|
||||
link += `${filters?.order?.value || 'popular'}/`;
|
||||
link += `${filters?.status?.value || 'all'}/`;
|
||||
link += page;
|
||||
|
||||
const body = await fetchApi(link).then((r: Response) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.novel-item.ads').remove();
|
||||
|
||||
loadedCheerio('.novel-item').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).find('.novel-title').text().trim();
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('data-src');
|
||||
const novelUrl = loadedCheerio(ele)
|
||||
.find('.novel-title > a')
|
||||
.attr('href')
|
||||
?.substring(1);
|
||||
|
||||
if (!novelUrl) return;
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovel(
|
||||
novelPath: string,
|
||||
): Promise<Plugin.SourceNovel & { totalPages: number }> {
|
||||
const body = await fetchApi(this.site + novelPath).then((r: Response) =>
|
||||
r.text(),
|
||||
);
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const totalChapters = parseInt(
|
||||
loadedCheerio('.header-stats span:first strong').text(),
|
||||
10,
|
||||
);
|
||||
|
||||
const novel: Plugin.SourceNovel & { totalPages: number } = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1.novel-title').text().trim() || 'Untitled',
|
||||
cover: loadedCheerio('figure.cover > img').attr('data-src'),
|
||||
author: loadedCheerio('.author > a > span').text(),
|
||||
summary: loadedCheerio('.summary > .content').text().trim(),
|
||||
status: loadedCheerio('.header-stats span:last strong').text(),
|
||||
totalPages: Math.ceil(totalChapters / 100),
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.genres = loadedCheerio('.categories ul li')
|
||||
.map((a, ex) => loadedCheerio(ex).text().trim())
|
||||
.toArray()
|
||||
.join(',');
|
||||
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
|
||||
const url = this.site + novelPath + '/chapters/page-' + page;
|
||||
const body = await fetchApi(url).then((res: Response) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapter: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('.chapter-list li').each(function () {
|
||||
const chapterName =
|
||||
'Chapter ' +
|
||||
loadedCheerio(this).find('.chapter-no').text().trim() +
|
||||
' - ' +
|
||||
loadedCheerio(this).find('.chapter-title').text().trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('.chapter-update')
|
||||
.attr('datetime');
|
||||
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
?.substring(1);
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
path: chapterUrl,
|
||||
releaseTime: dayjs(releaseDate).toISOString(),
|
||||
});
|
||||
});
|
||||
const chapters = chapter;
|
||||
return { chapters };
|
||||
}
|
||||
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const body = await fetchApi(this.site + chapterPath).then((r: Response) =>
|
||||
r.text(),
|
||||
);
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio('#chapter-container').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}lnsearchlive`;
|
||||
const link = `${this.site}search`;
|
||||
const response = await fetchApi(link).then((r: Response) => r.text());
|
||||
const token = parseHTML(response);
|
||||
const verifytoken = token('#novelSearchForm > input').attr('value');
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('inputContent', searchTerm);
|
||||
|
||||
const results = await fetchApi(url, {
|
||||
method: 'POST',
|
||||
headers: { LNRequestVerifyToken: verifytoken! },
|
||||
body: formData,
|
||||
}).then((r: Response) => r.json());
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
const loadedCheerio = parseHTML(results.resultview);
|
||||
|
||||
loadedCheerio('.novel-item').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).find('h4.novel-title').text().trim();
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href')?.substring(1);
|
||||
if (!novelUrl) return;
|
||||
novels.push({
|
||||
name: novelName,
|
||||
path: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user