Add TopLiba (#1003)

* test

* cleanup

deleted unused `fetchFile` import
replaced fetch with `fetchApi`

* eslint

* fix

* fix multi

* Hmm, what to do next.

* test URLSearchParams

* fix
This commit is contained in:
Rider21
2024-06-30 07:28:11 +03:00
committed by GitHub
parent 938e3b16a3
commit fae73534dd
121 changed files with 10534 additions and 8079 deletions
+7 -10
View File
@@ -1,5 +1,5 @@
import { CheerioAPI, load as parseHTML } from 'cheerio';
import { fetchApi, fetchFile } from '@libs/fetch';
import { fetchApi } from '@libs/fetch';
import { Plugin } from '@typings/plugin';
import { Filters } from '@libs/filterInputs';
import { NovelStatus } from '@libs/novelStatus';
@@ -20,12 +20,9 @@ class LightNovelVN implements Plugin.PagePlugin {
icon = 'src/vi/lightnovelvn/icon.png';
filters?: Filters | undefined;
site = 'https://lightnovel.vn';
async popularNovels(
pageNo: number,
options: Plugin.PopularNovelsOptions<Filters>,
): Promise<Plugin.NovelItem[]> {
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
const url = `${this.site}/truyen-hot-ds?page=${pageNo}`;
const body = await fetch(url).then(r => r.text());
const body = await fetchApi(url).then(r => r.text());
const loadedCheerio = parseHTML(body);
@@ -73,9 +70,9 @@ class LightNovelVN implements Plugin.PagePlugin {
novelPath: string,
): Promise<Plugin.SourceNovel & { totalPages: number }> {
const url = this.site + novelPath;
const body = await fetch(url).then(r => r.text());
const body = await fetchApi(url).then(r => r.text());
let loadedCheerio = parseHTML(body);
const loadedCheerio = parseHTML(body);
const novel: Plugin.SourceNovel & { totalPages: number } = {
path: novelPath,
@@ -138,7 +135,7 @@ class LightNovelVN implements Plugin.PagePlugin {
const loadedCheerio = parseHTML(body);
let chapterText = loadedCheerio('div.chapter-content').html() || '';
const chapterText = loadedCheerio('div.chapter-content').html() || '';
return chapterText;
}
@@ -148,7 +145,7 @@ class LightNovelVN implements Plugin.PagePlugin {
): Promise<Plugin.NovelItem[]> {
if (pageNo > 1) return [];
const url = `${this.site}/api/book-search`;
let formData = new FormData();
const formData = new FormData();
formData.append('keyword', searchTerm);
const result: SearchedResult = await fetchApi(url, {