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:
@@ -1,5 +1,5 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchText, fetchFile } from '@libs/fetch';
|
||||
import { fetchText } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
@@ -35,7 +35,7 @@ class Shu69 implements Plugin.PluginBase {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('div.book-coverlist').each((i, el) => {
|
||||
let url = loadedCheerio(el).find('a.cover').attr('href');
|
||||
const url = loadedCheerio(el).find('a.cover').attr('href');
|
||||
|
||||
const novelName = loadedCheerio(el).find('h4.name').text().trim();
|
||||
const novelCover = loadedCheerio(el).find('a.cover > img').attr('src');
|
||||
@@ -59,7 +59,7 @@ class Shu69 implements Plugin.PluginBase {
|
||||
const body = await fetchText(url);
|
||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
@@ -84,7 +84,7 @@ class Shu69 implements Plugin.PluginBase {
|
||||
novel.genres = '';
|
||||
|
||||
// Table of Content is on a different page than the summary page
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
const allUrl = loadedCheerio('dd.all > a').attr('href');
|
||||
if (allUrl) {
|
||||
@@ -156,12 +156,12 @@ class Shu69 implements Plugin.PluginBase {
|
||||
});
|
||||
if (body === '') throw Error('无法获取搜索结果,请检查网络');
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('div.book-coverlist').each((i, el) => {
|
||||
let url = loadedCheerio(el).find('a.cover').attr('href');
|
||||
const url = loadedCheerio(el).find('a.cover').attr('href');
|
||||
|
||||
const novelName = loadedCheerio(el).find('h4.name').text().trim();
|
||||
const novelCover = loadedCheerio(el).find('a.cover > img').attr('src');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchText, fetchFile } from '@libs/fetch';
|
||||
import { fetchText } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
// import { encode } from 'urlencode';
|
||||
@@ -66,7 +66,7 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
const body = await fetchText(url, {}, 'gbk');
|
||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
@@ -97,7 +97,7 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
// Table of Content is on a different page than the summary page
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
const chaptersUrl = loadedCheerio('a.more-btn').attr('href');
|
||||
if (chaptersUrl) {
|
||||
@@ -160,7 +160,7 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
);
|
||||
if (body === '') throw Error('无法获取搜索结果,请检查网络');
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchText, fetchFile } from '@libs/fetch';
|
||||
import { fetchText } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
@@ -29,7 +29,7 @@ class Linovelib implements Plugin.PluginBase {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.module-rank-booklist .book-layout').each((i, el) => {
|
||||
let url = loadedCheerio(el).attr('href');
|
||||
const url = loadedCheerio(el).attr('href');
|
||||
|
||||
const novelName = loadedCheerio(el).find('.book-title').text();
|
||||
const novelCover = loadedCheerio(el)
|
||||
@@ -55,7 +55,7 @@ class Linovelib implements Plugin.PluginBase {
|
||||
const body = await fetchText(url);
|
||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
@@ -83,7 +83,7 @@ class Linovelib implements Plugin.PluginBase {
|
||||
.join(',');
|
||||
|
||||
// Table of Content is on a different page than the summary page
|
||||
let chapter: Plugin.ChapterItem[] = [];
|
||||
const chapter: Plugin.ChapterItem[] = [];
|
||||
|
||||
const idPattern = /\/(\d+)\.html/;
|
||||
const novelId = url.match(idPattern)?.[1];
|
||||
@@ -421,7 +421,7 @@ class Linovelib implements Plugin.PluginBase {
|
||||
};
|
||||
|
||||
let url = this.site + chapterPath;
|
||||
let baseUrl = url;
|
||||
const baseUrl = url;
|
||||
do {
|
||||
const page = await loadPage(url);
|
||||
hasNextPage = page.pageHasNextPage;
|
||||
@@ -502,7 +502,7 @@ class Linovelib implements Plugin.PluginBase {
|
||||
// await addPage(pageCheerio, redirect);
|
||||
|
||||
pageCheerio('.book-ol .book-layout').each((i, el) => {
|
||||
let nUrl = pageCheerio(el).attr('href');
|
||||
const nUrl = pageCheerio(el).attr('href');
|
||||
|
||||
const novelName = pageCheerio(el).find('.book-title').text();
|
||||
const novelCover = pageCheerio(el)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import qs from 'qs';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import qs from 'qs';
|
||||
@@ -48,7 +48,7 @@ class NovelsOnline implements Plugin.PluginBase {
|
||||
const result = await fetchApi(this.site + novelPath).then(res =>
|
||||
res.text(),
|
||||
);
|
||||
let $ = parseHTML(result);
|
||||
const $ = parseHTML(result);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
@@ -58,8 +58,8 @@ class NovelsOnline implements Plugin.PluginBase {
|
||||
};
|
||||
|
||||
$('.novel-detail-item').each((i, el) => {
|
||||
let detailName = $(el).find('h6').text();
|
||||
let detail = $(el).find('.novel-detail-body');
|
||||
const detailName = $(el).find('h6').text();
|
||||
const detail = $(el).find('.novel-detail-body');
|
||||
|
||||
switch (detailName) {
|
||||
case 'Description':
|
||||
@@ -111,11 +111,8 @@ class NovelsOnline implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi('https://novelsonline.net/sResults.php', {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi(this.site + '/sResults.php', {
|
||||
headers: {
|
||||
Accept: '*/*',
|
||||
'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
|
||||
@@ -8,54 +8,49 @@ class StorySeedlingPlugin implements Plugin.PluginBase {
|
||||
name = 'StorySeedling';
|
||||
icon = 'src/en/storyseedling/icon.png';
|
||||
site = 'https://storyseedling.com/';
|
||||
version = '1.0.1';
|
||||
version = '1.0.2';
|
||||
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
let url = 'https://storyseedling.com/ajax';
|
||||
|
||||
const postUrl = `https://storyseedling.com/browse/`;
|
||||
const body = await fetchApi(postUrl).then(r => r.text());
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const body = await fetchApi(this.site + 'browse').then(r => r.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
var postValue = loadedCheerio('div[ax-load][x-data]')
|
||||
const postValue = loadedCheerio('div[ax-load][x-data]')
|
||||
.attr('x-data')
|
||||
?.replace("browse('", '')
|
||||
.replace("')", '') as string;
|
||||
|
||||
var data = new FormData();
|
||||
const data = new FormData();
|
||||
data.append('search', '');
|
||||
data.append('orderBy', 'recent');
|
||||
data.append('curpage', pageNo.toString());
|
||||
data.append('post', postValue);
|
||||
data.append('action', 'fetch_browse');
|
||||
|
||||
var response = await (
|
||||
await fetchApi(url, { body: data, method: 'POST' })
|
||||
).json();
|
||||
const response: any = await fetchApi(this.site + 'ajax', {
|
||||
body: data,
|
||||
method: 'POST',
|
||||
}).then(res => res.json());
|
||||
|
||||
response.data.posts.forEach((element: any) => {
|
||||
const novel = {
|
||||
response.data.posts.forEach((element: any) =>
|
||||
novels.push({
|
||||
name: element.title,
|
||||
cover: element.thumbnail,
|
||||
path: element.permalink.replace(this.site, ''),
|
||||
};
|
||||
novels.push(novel);
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
var site = this.site;
|
||||
const site = this.site;
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: '',
|
||||
};
|
||||
|
||||
const body = await fetchApi(this.site + novelPath).then(r => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
novel.name = loadedCheerio('h1').text().trim();
|
||||
@@ -68,7 +63,8 @@ class StorySeedlingPlugin implements Plugin.PluginBase {
|
||||
if (!novel.cover) {
|
||||
novel.cover = defaultCover;
|
||||
}
|
||||
let genres: string[] = [];
|
||||
|
||||
const genres: string[] = [];
|
||||
loadedCheerio(
|
||||
'section[x-data="{ tab: location.hash.substr(1) || \'chapters\' }"].relative > div > div > div.flex.flex-wrap > a',
|
||||
).each(function () {
|
||||
@@ -81,7 +77,7 @@ class StorySeedlingPlugin implements Plugin.PluginBase {
|
||||
.trim()
|
||||
.replace(/(\r\n|\n|\r)/gm, '');
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio(
|
||||
'div.grid.w-full.grid-cols-1.gap-4.md\\:grid-cols-2 > a',
|
||||
@@ -89,20 +85,20 @@ class StorySeedlingPlugin implements Plugin.PluginBase {
|
||||
if (loadedCheerio(this).find('> div').length == 2) {
|
||||
return;
|
||||
}
|
||||
let name = loadedCheerio(this).find('.truncate').text().trim();
|
||||
let url = loadedCheerio(this).attr('href') as string;
|
||||
let releaseTime = loadedCheerio(this)
|
||||
const name = loadedCheerio(this).find('.truncate').text().trim();
|
||||
const url = loadedCheerio(this).attr('href') as string;
|
||||
const releaseTime = loadedCheerio(this)
|
||||
.find('div > div > small')
|
||||
.text()
|
||||
.trim();
|
||||
let chapterNumber = name.split('-')[0].trim().split(' ')[1];
|
||||
const chapter: Plugin.ChapterItem = {
|
||||
const chapterNumber = name.split('-')[0].trim().split(' ')[1];
|
||||
|
||||
chapters.push({
|
||||
name: name,
|
||||
path: url.replace(site, ''),
|
||||
releaseTime: releaseTime,
|
||||
releaseTime,
|
||||
chapterNumber: parseInt(chapterNumber),
|
||||
};
|
||||
chapters.push(chapter);
|
||||
});
|
||||
});
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
@@ -111,8 +107,8 @@ class StorySeedlingPlugin implements Plugin.PluginBase {
|
||||
const body = await fetchApi(this.site + chapterPath).then(r => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
let t = loadedCheerio('div.justify-center > div.mb-4');
|
||||
let chapterText = t.html() || '';
|
||||
const t = loadedCheerio('div.justify-center > div.mb-4');
|
||||
const chapterText = t.html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
@@ -121,38 +117,35 @@ class StorySeedlingPlugin implements Plugin.PluginBase {
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
let url = 'https://storyseedling.com/ajax';
|
||||
|
||||
const postUrl = `https://storyseedling.com/browse/`;
|
||||
const body = await fetchApi(postUrl).then(r => r.text());
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
const body = await fetchApi(this.site + 'browse').then(r => r.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
var postValue = loadedCheerio('div[ax-load][x-data]')
|
||||
const postValue = loadedCheerio('div[ax-load][x-data]')
|
||||
.attr('x-data')
|
||||
?.replace("browse('", '')
|
||||
.replace("')", '') as string;
|
||||
|
||||
var data = new FormData();
|
||||
const data = new FormData();
|
||||
data.append('search', searchTerm);
|
||||
data.append('orderBy', 'recent');
|
||||
data.append('curpage', pageNo.toString());
|
||||
data.append('post', postValue);
|
||||
data.append('action', 'fetch_browse');
|
||||
|
||||
var response = await (
|
||||
await fetchApi(url, { body: data, method: 'POST' })
|
||||
).json();
|
||||
const response: any = await fetchApi(this.site + 'ajax', {
|
||||
body: data,
|
||||
method: 'POST',
|
||||
}).then(res => res.json());
|
||||
|
||||
response.data.posts.forEach((element: any) => {
|
||||
const novel = {
|
||||
response.data.posts.forEach((element: any) =>
|
||||
novels.push({
|
||||
name: element.title,
|
||||
cover: element.thumbnail,
|
||||
path: element.permalink.replace(this.site, ''),
|
||||
};
|
||||
novels.push(novel);
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { isUrlAbsolute } from '@libs/isAbsoluteUrl';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
|
||||
@@ -48,7 +48,7 @@ class BLN implements Plugin.PluginBase {
|
||||
link += '&state=' + filters.status.value;
|
||||
link += '&page=' + page;
|
||||
|
||||
const result = await fetch(link);
|
||||
const result = await fetchApi(link);
|
||||
if (!result.ok) {
|
||||
console.error(await result.text());
|
||||
// TODO: Cloudflare protection or other error
|
||||
@@ -61,7 +61,7 @@ class BLN implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetch(this.site + novelPath);
|
||||
const result = await fetchApi(this.site + novelPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -146,7 +146,7 @@ class BLN implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetch(this.site + chapterPath);
|
||||
const result = await fetchApi(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -162,7 +162,7 @@ class BLN implements Plugin.PluginBase {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}search_novels/${searchTerm}?page=${page}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -52,7 +52,7 @@ class ComradeMaoPlugin implements Plugin.PluginBase {
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(novelUrl).then(result => result.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
|
||||
@@ -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 { defaultCover } from '@libs/defaultCover';
|
||||
|
||||
@@ -9,7 +9,6 @@ class DDLPlugin implements Plugin.PluginBase {
|
||||
site = 'https://www.divinedaolibrary.com/';
|
||||
version = '1.0.1';
|
||||
icon = 'src/en/divinedaolibrary/icon.png';
|
||||
filters?: undefined;
|
||||
|
||||
parseNovels(loadedCheerio: CheerioAPI, searchTerm?: string) {
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
@@ -40,11 +39,8 @@ class DDLPlugin implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = this.site + 'novels';
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const link = this.site + 'novels';
|
||||
|
||||
const body = await fetchApi(link).then(res => res.text());
|
||||
|
||||
@@ -56,7 +52,7 @@ class DDLPlugin implements Plugin.PluginBase {
|
||||
const result = await fetchApi(this.site + novelPath);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
@@ -116,11 +112,8 @@ class DDLPlugin implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + 'novels';
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + 'novels';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
|
||||
@@ -68,7 +68,7 @@ class EarlyNovelPlugin implements Plugin.PagePlugin {
|
||||
const result = await fetchApi(this.site + novelPath);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
loadedCheerio('.glyphicon-menu-right').closest('li').remove();
|
||||
const pagenav = loadedCheerio('.page-nav').prev().find('a');
|
||||
const lastPageStr = pagenav.attr('title')?.match(/(\d+)/);
|
||||
@@ -84,8 +84,8 @@ class EarlyNovelPlugin implements Plugin.PagePlugin {
|
||||
};
|
||||
|
||||
loadedCheerio('.info > div > h3').each(function () {
|
||||
let detailName = loadedCheerio(this).text();
|
||||
let detail = loadedCheerio(this)
|
||||
const detailName = loadedCheerio(this).text();
|
||||
const detail = loadedCheerio(this)
|
||||
.siblings()
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
@@ -127,10 +127,7 @@ class EarlyNovelPlugin implements Plugin.PagePlugin {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}search?keyword=${searchTerm}`;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
|
||||
@@ -43,10 +43,7 @@ class FaqWikiUs implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
{ showLatestNovels }: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const body = await fetchApi(this.site).then(res => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
@@ -79,7 +76,7 @@ class FaqWikiUs implements Plugin.PluginBase {
|
||||
|
||||
const div = loadedCheerio('.book-review-block__meta-item-value');
|
||||
|
||||
div.html(div.html()?.replace(/(?<=>)([^<]+)(?=<br\s*\/?>)/g, '<p>$1</p>')!);
|
||||
div.html(div.html()?.replace(/(?<=>)([^<]+)(?=<br\s*\/?>)/g, '<p>$1</p>'));
|
||||
|
||||
loadedCheerio('.book-review-block__meta-item-value strong').each(
|
||||
(i, el) => {
|
||||
|
||||
@@ -264,8 +264,7 @@ class Foxteller implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
resolveUrl = (path: string, isNovel?: boolean) =>
|
||||
this.site + '/novel/' + path;
|
||||
resolveUrl = (path: string) => this.site + '/novel/' + path;
|
||||
|
||||
filters = {
|
||||
order: {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import qs from 'qs';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Parser } from 'htmlparser2';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -85,7 +85,7 @@ class LightNovelPub implements Plugin.PagePlugin {
|
||||
let isSummary = false;
|
||||
let isGenres = false;
|
||||
let isTags = false;
|
||||
let genreArray: string[] = [];
|
||||
const genreArray: string[] = [];
|
||||
let isCover = false;
|
||||
const parser = new Parser({
|
||||
onopentag(name, attribs) {
|
||||
@@ -245,7 +245,7 @@ class LightNovelPub implements Plugin.PagePlugin {
|
||||
const parser = new Parser({
|
||||
onopentag(name, attribs) {
|
||||
if (isChapter && name === 'div') {
|
||||
let stylediv = attribs['style'];
|
||||
const stylediv = attribs['style'];
|
||||
if (stylediv) {
|
||||
chapterText += `<div style="${stylediv}">`;
|
||||
isStyleText = true;
|
||||
@@ -254,7 +254,7 @@ class LightNovelPub implements Plugin.PagePlugin {
|
||||
}
|
||||
}
|
||||
if (isChapter && name === 'table') {
|
||||
let w = attribs['width'];
|
||||
const w = attribs['width'];
|
||||
if (w) {
|
||||
chapterText += `<table width="${w}">`;
|
||||
} else {
|
||||
@@ -268,7 +268,7 @@ class LightNovelPub implements Plugin.PagePlugin {
|
||||
chapterText += `<tr>`;
|
||||
}
|
||||
if (isChapter && name === 'td') {
|
||||
let w1 = attribs['width'];
|
||||
const w1 = attribs['width'];
|
||||
if (w1) {
|
||||
chapterText += `<td width="${w1}">`;
|
||||
} else {
|
||||
@@ -334,10 +334,7 @@ class LightNovelPub implements Plugin.PagePlugin {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}lnsearchlive`;
|
||||
const link = `${this.site}search`;
|
||||
const response = await fetchApi(link).then(r => r.text());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Parser } from 'htmlparser2';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
|
||||
@@ -87,7 +87,7 @@ class LnMTLPlugin implements Plugin.PagePlugin {
|
||||
let isStatusKey = false;
|
||||
let isList = 0;
|
||||
let isGenres = false;
|
||||
let genreArray: string[] = [];
|
||||
const genreArray: string[] = [];
|
||||
const parser = new Parser({
|
||||
onopentag(name, attribs) {
|
||||
if (name === 'img' && attribs['class']?.includes('img-rounded')) {
|
||||
@@ -272,10 +272,7 @@ class LnMTLPlugin implements Plugin.PagePlugin {
|
||||
return chapterText.replace(/„/g, '“');
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const html = await fetchApi(this.site)
|
||||
.then(b => b.text())
|
||||
.then(r => r.replace(/>\s+</g, '><'));
|
||||
@@ -312,7 +309,7 @@ class LnMTLPlugin implements Plugin.PagePlugin {
|
||||
parser.write(html);
|
||||
parser.end();
|
||||
|
||||
const search = await fetch(`${this.site}${list}`);
|
||||
const search = await fetchApi(`${this.site}${list}`);
|
||||
const data = await search.json();
|
||||
|
||||
const nov = data.filter((res: { name: string }) =>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
|
||||
@@ -21,7 +21,9 @@ class MTLNovel implements Plugin.PluginBase {
|
||||
|
||||
const headers = new Headers();
|
||||
headers.append('Alt-Used', 'www.mtlnovel.com');
|
||||
const body = await fetch(link, { headers }).then(result => result.text());
|
||||
const body = await fetchApi(link, { headers }).then(result =>
|
||||
result.text(),
|
||||
);
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
@@ -50,7 +52,7 @@ class MTLNovel implements Plugin.PluginBase {
|
||||
headers.append('Referer', `${this.site}novel-list/`);
|
||||
headers.append('Alt-Used', 'www.mtlnovel.com');
|
||||
|
||||
const body = await fetch(this.site + novelPath, {
|
||||
const body = await fetchApi(this.site + novelPath, {
|
||||
headers,
|
||||
}).then(result => result.text());
|
||||
|
||||
@@ -70,7 +72,7 @@ class MTLNovel implements Plugin.PluginBase {
|
||||
const chapterListUrl = this.site + novelPath + 'chapter-list/';
|
||||
|
||||
const getChapters = async () => {
|
||||
const listResult = await fetch(chapterListUrl, { headers });
|
||||
const listResult = await fetchApi(chapterListUrl, { headers });
|
||||
const listBody = await listResult.text();
|
||||
|
||||
loadedCheerio = parseHTML(listBody);
|
||||
@@ -101,7 +103,7 @@ class MTLNovel implements Plugin.PluginBase {
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const headers = new Headers();
|
||||
headers.append('Alt-Used', 'www.mtlnovel.com');
|
||||
const body = await fetch(this.site + chapterPath, { headers }).then(r =>
|
||||
const body = await fetchApi(this.site + chapterPath, { headers }).then(r =>
|
||||
r.text(),
|
||||
);
|
||||
|
||||
@@ -112,19 +114,13 @@ class MTLNovel implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const headers = new Headers();
|
||||
headers.append('Alt-Used', 'www.mtlnovel.com');
|
||||
const searchUrl =
|
||||
this.site +
|
||||
'wp-admin/admin-ajax.php?action=autosuggest&q=' +
|
||||
searchTerm +
|
||||
'&__amp_source_origin=https%3A%2F%2Fwww.mtlnovel.com';
|
||||
this.site + 'wp-admin/admin-ajax.php?action=autosuggest&q=' + searchTerm;
|
||||
|
||||
const res = await fetch(searchUrl, { headers });
|
||||
const res = await fetchApi(searchUrl, { headers });
|
||||
const result = await res.json();
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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';
|
||||
|
||||
class MTLReader implements Plugin.PluginBase {
|
||||
id = 'mtlreader';
|
||||
@@ -9,6 +8,7 @@ class MTLReader implements Plugin.PluginBase {
|
||||
version = '1.0.0';
|
||||
icon = 'src/en/mtlreader/icon.png';
|
||||
site = 'https://mtlreader.com/';
|
||||
|
||||
parseNovels(loadedCheerio: CheerioAPI) {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
@@ -31,10 +31,7 @@ class MTLReader implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}novels?page=${pageNo}`;
|
||||
|
||||
const body = await fetchApi(url).then(r => r.text());
|
||||
@@ -90,10 +87,7 @@ class MTLReader implements Plugin.PluginBase {
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const body = await fetchApi(this.site).then(r => r.text());
|
||||
const tokenCheerio = parseHTML(body);
|
||||
const token = tokenCheerio('input[name="_token"]').attr('value');
|
||||
|
||||
@@ -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, FilterTypes } from '@libs/filterInputs';
|
||||
|
||||
@@ -73,8 +73,8 @@ class NovelBin implements Plugin.PluginBase {
|
||||
};
|
||||
|
||||
loadedCheerio('ul.info > li > h3').each(function () {
|
||||
let detailName = loadedCheerio(this).text();
|
||||
let detail = loadedCheerio(this)
|
||||
const detailName = loadedCheerio(this).text();
|
||||
const detail = loadedCheerio(this)
|
||||
.siblings()
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
@@ -137,10 +137,7 @@ class NovelBin implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}search/?keyword=${searchTerm}`;
|
||||
const body = await fetchApi(url).then(r => r.text());
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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';
|
||||
|
||||
class NovelBuddy implements Plugin.PluginBase {
|
||||
id = 'novelbuddy';
|
||||
@@ -9,7 +8,6 @@ class NovelBuddy implements Plugin.PluginBase {
|
||||
site = 'https://novelbuddy.io/';
|
||||
version = '1.0.0';
|
||||
icon = 'src/en/novelbuddy/icon.png';
|
||||
filters?: undefined; //TODO: Filters, Filters in Filters required
|
||||
|
||||
parseNovels(loadedCheerio: CheerioAPI) {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
@@ -33,10 +31,7 @@ class NovelBuddy implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}popular?page=${pageNo}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
|
||||
@@ -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, FilterTypes } from '@libs/filterInputs';
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { load, load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
|
||||
class NovelHall implements Plugin.PluginBase {
|
||||
@@ -9,13 +8,9 @@ class NovelHall implements Plugin.PluginBase {
|
||||
name = 'Novel Hall';
|
||||
version = '1.0.1';
|
||||
icon = 'src/en/novelhall/icon.png';
|
||||
filters?: Filters | undefined; //TODO: Filters Requires hideOnSelect
|
||||
site = 'https://novelhall.com/';
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(page: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}all2022-${page}.html`;
|
||||
|
||||
const body = await fetchApi(url).then(r => r.text());
|
||||
@@ -94,10 +89,7 @@ class NovelHall implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}index.php?s=so&module=book&keyword=${searchTerm}`;
|
||||
const body = await fetchApi(url).then(r => r.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
@@ -142,7 +143,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
|
||||
loadedCheerio = parseHTML(text);
|
||||
|
||||
const nameReplacements: { [key: string]: string } = {
|
||||
const nameReplacements: Record<string, string> = {
|
||||
'v': 'volume ',
|
||||
'c': ' chapter ',
|
||||
'part': 'part ',
|
||||
@@ -151,7 +152,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
|
||||
loadedCheerio('li.sp_li_chp').each((i, el) => {
|
||||
let chapterName = loadedCheerio(el).text();
|
||||
for (let name in nameReplacements) {
|
||||
for (const name in nameReplacements) {
|
||||
chapterName = chapterName.replace(name, nameReplacements[name]);
|
||||
}
|
||||
chapterName = chapterName.replace(/\b\w/g, l => l.toUpperCase()).trim();
|
||||
@@ -170,7 +171,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
getLocation(href: string) {
|
||||
var match = href.match(
|
||||
const match = href.match(
|
||||
/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/,
|
||||
);
|
||||
return match && `${match[1]}//${match[3]}`;
|
||||
@@ -198,7 +199,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
}
|
||||
break;
|
||||
case 'asuratls':
|
||||
let titleElementAsura = loadedCheerio('.post-body div b').first();
|
||||
const titleElementAsura = loadedCheerio('.post-body div b').first();
|
||||
chapterTitle = titleElementAsura.text()!;
|
||||
titleElementAsura.remove();
|
||||
chapterContent = loadedCheerio('.post-body').html()!;
|
||||
@@ -235,7 +236,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
loadedCheerio('#readerarea.rdminimal')
|
||||
.children()
|
||||
.each((idx, ele) => {
|
||||
let elementText = loadedCheerio(ele).text();
|
||||
const elementText = loadedCheerio(ele).text();
|
||||
if (elementText.includes(chapterStringHelScans)) {
|
||||
chapterTitle = elementText;
|
||||
loadedCheerio(ele).remove();
|
||||
@@ -295,12 +296,12 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
case 'ko-fi':
|
||||
chapterText = loadedCheerio('script:contains("shadowDom.innerHTML")')
|
||||
.html()
|
||||
?.match(/shadowDom\.innerHTML \+= '(<div.*?)';/)![1]!;
|
||||
?.match(/shadowDom\.innerHTML \+= '(<div.*?)';/)![1];
|
||||
break;
|
||||
case 'mirilu':
|
||||
bloatClasses = ['#jp-post-flair'];
|
||||
bloatClasses.map(tag => loadedCheerio(tag).remove());
|
||||
let titleElementMirilu = loadedCheerio(
|
||||
const titleElementMirilu = loadedCheerio(
|
||||
'.entry-content p strong',
|
||||
).first();
|
||||
chapterTitle = titleElementMirilu.text()!;
|
||||
@@ -360,10 +361,10 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
}
|
||||
break;
|
||||
case 'rainofsnow':
|
||||
let displayedDivSnow = loadedCheerio('.bb-item').filter(function () {
|
||||
const displayedDivSnow = loadedCheerio('.bb-item').filter(function () {
|
||||
return loadedCheerio(this).css('display') === 'block';
|
||||
});
|
||||
let loadedCheerioSnow = parseHTML(displayedDivSnow.html()!);
|
||||
const loadedCheerioSnow = parseHTML(displayedDivSnow.html()!);
|
||||
bloatClasses = [
|
||||
'.responsivevoice-button',
|
||||
'.zoomdesc-cont p img',
|
||||
@@ -371,7 +372,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
];
|
||||
bloatClasses.map(tag => loadedCheerioSnow(tag).remove());
|
||||
chapterContent = loadedCheerioSnow('.zoomdesc-cont').html()!;
|
||||
let titleElementSnow = loadedCheerioSnow('.scroller h2').first();
|
||||
const titleElementSnow = loadedCheerioSnow('.scroller h2').first();
|
||||
if (titleElementSnow.length) {
|
||||
chapterTitle = titleElementSnow.text()!;
|
||||
titleElementSnow.remove();
|
||||
@@ -473,7 +474,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
];
|
||||
bloatClasses.map(tag => loadedCheerioSyringe(tag).remove());
|
||||
chapterContent = loadedCheerioSyringe('.entry-content').html()!;
|
||||
let titleElementSyringe =
|
||||
const titleElementSyringe =
|
||||
loadedCheerioSyringe('.entry-content h3').first();
|
||||
if (titleElementSyringe.length) {
|
||||
chapterTitle = titleElementSyringe.text();
|
||||
@@ -535,7 +536,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
bloatClasses = ['hr', 'p:contains("\u00a0")'];
|
||||
bloatClasses.map(tag => loadedCheerio(tag).remove());
|
||||
chapterContent = loadedCheerio('.text-left').html()!;
|
||||
let titleElementZetro = loadedCheerio('.text-left h2').first();
|
||||
const titleElementZetro = loadedCheerio('.text-left h2').first();
|
||||
if (titleElementZetro.length) {
|
||||
chapterTitle = titleElementZetro.text()!;
|
||||
titleElementZetro.remove();
|
||||
@@ -590,7 +591,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
/**
|
||||
* Detect if the site is a Blogspot site
|
||||
*/
|
||||
let isBlogspotStr =
|
||||
const isBlogspotStr =
|
||||
loadedCheerio('meta[name="google-adsense-platform-domain"]').attr(
|
||||
'content',
|
||||
) || loadedCheerio('meta[name="generator"]').attr('content');
|
||||
@@ -604,7 +605,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
/**
|
||||
* Detect if the site is a WordPress site
|
||||
*/
|
||||
let isWordPressStr =
|
||||
const isWordPressStr =
|
||||
loadedCheerio('#dcl_comments-js-extra').html() ||
|
||||
loadedCheerio('meta[name="generator"]').attr('content') ||
|
||||
loadedCheerio('footer').text()!;
|
||||
@@ -726,7 +727,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
||||
loadedCheerio('.title_story').first().text() ||
|
||||
loadedCheerio('.active').first().text() ||
|
||||
loadedCheerio('head title').first().text()!;
|
||||
let chapterSubtitle = loadedCheerio('.cat-series').first().text() || '';
|
||||
const chapterSubtitle = loadedCheerio('.cat-series').first().text() || '';
|
||||
if (chapterSubtitle) {
|
||||
chapterTitle = chapterSubtitle;
|
||||
}
|
||||
|
||||
@@ -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, FilterTypes } from '@libs/filterInputs';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Parser } from 'htmlparser2';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
|
||||
class RanobesPlugin implements Plugin.PagePlugin {
|
||||
@@ -8,7 +7,6 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
name = 'Ranobes';
|
||||
icon = 'src/en/ranobes/icon.png';
|
||||
site = 'https://ranobes.top';
|
||||
filters?: Filters | undefined;
|
||||
version = '2.0.0';
|
||||
|
||||
async sleep(ms: number) {
|
||||
@@ -81,14 +79,8 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
return chapter.reverse();
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}/novels/page/${page}/`;
|
||||
async popularNovels(page: number): Promise<Plugin.NovelItem[]> {
|
||||
const link = `${this.site}/novels/page/${page}/`;
|
||||
const body = await fetchApi(link).then(r => r.text());
|
||||
|
||||
return this.parseNovels(body);
|
||||
@@ -107,7 +99,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
chapters: [],
|
||||
totalPages: 1,
|
||||
};
|
||||
let baseUrl = this.site;
|
||||
const baseUrl = this.site;
|
||||
let isCover = false;
|
||||
let isAuthor = false;
|
||||
let isSummary = false;
|
||||
@@ -115,7 +107,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
let isStatusText = false;
|
||||
let isGenres = false;
|
||||
let isGenresText = false;
|
||||
let genreArray: string[] = [];
|
||||
const genreArray: string[] = [];
|
||||
let novelId = '';
|
||||
const parser = new Parser({
|
||||
onopentag(name, attribs) {
|
||||
@@ -276,7 +268,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
const parser = new Parser({
|
||||
onopentag(name, attribs) {
|
||||
if (isChapter && name === 'div') {
|
||||
let stylediv = attribs['style'];
|
||||
const stylediv = attribs['style'];
|
||||
if (stylediv) {
|
||||
chapterText += `<div style="${stylediv}">`;
|
||||
isStyleText = true;
|
||||
@@ -285,7 +277,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
}
|
||||
}
|
||||
if (isChapter && name === 'table') {
|
||||
let w = attribs['width'];
|
||||
const w = attribs['width'];
|
||||
if (w) {
|
||||
chapterText += `<table width="${w}">`;
|
||||
} else {
|
||||
@@ -299,7 +291,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
chapterText += `<tr>`;
|
||||
}
|
||||
if (isChapter && name === 'td') {
|
||||
let w1 = attribs['width'];
|
||||
const w1 = attribs['width'];
|
||||
if (w1) {
|
||||
chapterText += `<td width="${w1}">`;
|
||||
} else {
|
||||
@@ -369,7 +361,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
searchTerm: string,
|
||||
page: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}/search/${searchTerm}/page/${page}`;
|
||||
const link = `${this.site}/search/${searchTerm}/page/${page}`;
|
||||
const body = await fetchApi(link).then(r => r.text());
|
||||
|
||||
return this.parseNovels(body);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { isUrlAbsolute } from '@libs/isAbsoluteUrl';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -152,10 +152,7 @@ class ReadLiteNovel implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url =
|
||||
this.site + `/search/autocomplete?dataType=json&query=${searchTerm}`;
|
||||
const result = await fetchApi(url);
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { fetchFile, fetchText } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { load as loadCheerio, CheerioAPI } from 'cheerio';
|
||||
import { load as loadCheerio } from 'cheerio';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { NovelItem } from '../../test_web/static/js';
|
||||
// import { isUrlAbsolute } from "@libs/isAbsoluteUrl";
|
||||
// import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
|
||||
interface FuzzySearchOptions {
|
||||
caseSensitive: boolean;
|
||||
@@ -69,8 +67,8 @@ class FuzzySearch<Item> {
|
||||
}
|
||||
const results: { item: Item; score: number }[] = [];
|
||||
|
||||
for (let item of this.haystack) {
|
||||
for (let value of this.getItems(item)) {
|
||||
for (const item of this.haystack) {
|
||||
for (const value of this.getItems(item)) {
|
||||
const score = this.isMatch(value, query);
|
||||
if (score !== undefined) {
|
||||
results.push({ item, score });
|
||||
@@ -112,11 +110,11 @@ class FuzzySearch<Item> {
|
||||
|
||||
nearestIndexesFor(item: string, query: string): number[] | undefined {
|
||||
const letters = query.split('');
|
||||
let indexes: number[][] = [];
|
||||
const indexes: number[][] = [];
|
||||
|
||||
const idxFL = this.idxFirstLetter(item, query);
|
||||
|
||||
for (let idx of idxFL) {
|
||||
for (const idx of idxFL) {
|
||||
indexes.push([idx]);
|
||||
for (let i = 1; i < letters.length; i++) {
|
||||
const letter = letters[i];
|
||||
@@ -139,8 +137,8 @@ class FuzzySearch<Item> {
|
||||
return a[0] - b[0];
|
||||
}
|
||||
|
||||
let res_a = a[a.length - 1] - a[0];
|
||||
let res_b = b[b.length - 1] - b[0];
|
||||
const res_a = a[a.length - 1] - a[0];
|
||||
const res_b = b[b.length - 1] - b[0];
|
||||
|
||||
return res_a - res_b;
|
||||
})[0];
|
||||
@@ -167,21 +165,20 @@ class ReLibraryPlugin implements Plugin.PluginBase {
|
||||
icon = 'src/en/relibrary/icon.png';
|
||||
site = 'https://re-library.com';
|
||||
version = '1.0.0';
|
||||
filters: Filters | undefined = undefined;
|
||||
|
||||
private searchFunc: FuzzySearch<Plugin.NovelItem> = new FuzzySearch(
|
||||
item => [item.name],
|
||||
{ sort: true, caseSensitive: false },
|
||||
);
|
||||
private searchFunc = new FuzzySearch<Plugin.NovelItem>(item => [item.name], {
|
||||
sort: true,
|
||||
caseSensitive: false,
|
||||
});
|
||||
|
||||
private async popularNovelsInner(url: string): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = loadCheerio(body);
|
||||
loadedCheerio('.entry-content > ol > li').each((_i, el) => {
|
||||
let novel: Partial<NovelItem> = {};
|
||||
const novel: Partial<NovelItem> = {};
|
||||
novel.name = loadedCheerio(el).find('h3 > a').text();
|
||||
novel.path = loadedCheerio(el)
|
||||
.find('table > tbody > tr > td > a')
|
||||
@@ -201,12 +198,12 @@ class ReLibraryPlugin implements Plugin.PluginBase {
|
||||
|
||||
private async lastestNovelsInner(url: string): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = loadCheerio(body);
|
||||
loadedCheerio('article.type-page.page').each((_i, el) => {
|
||||
let novel: Partial<Plugin.NovelItem> = {};
|
||||
const novel: Partial<Plugin.NovelItem> = {};
|
||||
novel.name = loadedCheerio(el).find('.entry-title').text();
|
||||
novel.path = loadedCheerio(el).find('.entry-title a').attr('href');
|
||||
if (novel.path === undefined || novel.name === undefined) return;
|
||||
@@ -224,10 +221,7 @@ class ReLibraryPlugin implements Plugin.PluginBase {
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
{ showLatestNovels }: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
// The most-popular page only has a single page, so we return an empty array in case you ask for the impossible
|
||||
// the lastest page do have paginated result, so we support that.
|
||||
@@ -241,7 +235,7 @@ class ReLibraryPlugin implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
let novel: Partial<Plugin.SourceNovel> = {
|
||||
const novel: Partial<Plugin.SourceNovel> = {
|
||||
path: novelPath,
|
||||
};
|
||||
// title: .entry-content > header.entry-header > .entry-title
|
||||
@@ -250,7 +244,7 @@ class ReLibraryPlugin implements Plugin.PluginBase {
|
||||
// synopis: .entry-content > div.su-box > div.su-box-content
|
||||
// chapters: .entry-content > div.su-accordion <then> li.page_item[]
|
||||
|
||||
const result = await fetch(`${this.site}/${novelPath}`);
|
||||
const result = await fetchApi(`${this.site}/${novelPath}`);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = loadCheerio(body);
|
||||
@@ -271,7 +265,7 @@ class ReLibraryPlugin implements Plugin.PluginBase {
|
||||
|
||||
// Genres in comma separated "list"
|
||||
novel.genres = (() => {
|
||||
let genres: string[] = [];
|
||||
const genres: string[] = [];
|
||||
loadedCheerio(
|
||||
'.entry-content > table > tbody > tr > td > p > span > a',
|
||||
).each((_i, el) => {
|
||||
@@ -303,7 +297,7 @@ class ReLibraryPlugin implements Plugin.PluginBase {
|
||||
'.entry-content > div.su-box > div.su-box-content',
|
||||
).text();
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
let chapter_idx = 0;
|
||||
loadedCheerio('.entry-content > div.su-accordion').each((_i1, el) => {
|
||||
@@ -336,16 +330,16 @@ class ReLibraryPlugin implements Plugin.PluginBase {
|
||||
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
// parse chapter text here
|
||||
const result = await fetch(`${this.site}/${chapterPath}`);
|
||||
const result = await fetchApi(`${this.site}/${chapterPath}`);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = loadCheerio(body);
|
||||
let text: string[] = [];
|
||||
const text: string[] = [];
|
||||
loadedCheerio('.entry-content > p')
|
||||
.slice(1)
|
||||
.each((_i, el) => {
|
||||
loadedCheerio(el).find('span').remove();
|
||||
let t = loadedCheerio(el).html();
|
||||
const t = loadedCheerio(el).html();
|
||||
if (t === undefined) return;
|
||||
text.push(`<p>${t}</p>`);
|
||||
});
|
||||
@@ -363,14 +357,14 @@ class ReLibraryPlugin implements Plugin.PluginBase {
|
||||
// We only want to serve a single "page" since we do the search client side.
|
||||
if (pageNo !== 1) return [];
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const req = await fetch(`${this.site}/translations/`);
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const req = await fetchApi(`${this.site}/translations/`);
|
||||
const body = await req.text();
|
||||
|
||||
const loadedCheerio = loadCheerio(body);
|
||||
|
||||
loadedCheerio('.entry-content table a').each((_i, el) => {
|
||||
let e = loadedCheerio(el);
|
||||
const e = loadedCheerio(el);
|
||||
if (e && e.attr('href') && e.text()) {
|
||||
let path = e.attr('href')!;
|
||||
if (path.startsWith(this.site)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Parser } from 'htmlparser2';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
@@ -86,7 +86,7 @@ class RoyalRoad implements Plugin.PluginBase {
|
||||
let isSpan = 0;
|
||||
let isTags = false;
|
||||
let isGenres = false;
|
||||
let genreArray: string[] = [];
|
||||
const genreArray: string[] = [];
|
||||
let isFooter = false;
|
||||
let isScript = false;
|
||||
let chapterJson: ChapterEntry[] = [];
|
||||
@@ -226,7 +226,7 @@ class RoyalRoad implements Plugin.PluginBase {
|
||||
const parser = new Parser({
|
||||
onopentag(name, attribs) {
|
||||
if (isChapter && name === 'div') {
|
||||
let stylediv = attribs['style'];
|
||||
const stylediv = attribs['style'];
|
||||
if (stylediv) {
|
||||
chapterText += `<div style="${stylediv}">`;
|
||||
isStyleText = true;
|
||||
@@ -235,7 +235,7 @@ class RoyalRoad implements Plugin.PluginBase {
|
||||
}
|
||||
}
|
||||
if (isChapter && name === 'table') {
|
||||
let w = attribs['width'];
|
||||
const w = attribs['width'];
|
||||
if (w) {
|
||||
chapterText += `<table width="${w}">`;
|
||||
} else {
|
||||
@@ -249,7 +249,7 @@ class RoyalRoad implements Plugin.PluginBase {
|
||||
chapterText += `<tr>`;
|
||||
}
|
||||
if (isChapter && name === 'td') {
|
||||
let w1 = attribs['width'];
|
||||
const w1 = attribs['width'];
|
||||
if (w1) {
|
||||
chapterText += `<td width="${w1}">`;
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -173,10 +173,7 @@ class ScribbleHubPlugin implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?s=${searchTerm}&post_type=fictionposts`;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
|
||||
@@ -25,7 +25,7 @@ class WTRLAB implements Plugin.PluginBase {
|
||||
link += `&page=${page}`; //TODO Genre & Advance Searching Filter. Ez to implement, too much manual work, too lazy.
|
||||
|
||||
if (showLatestNovels) {
|
||||
const response = await fetch('https://wtr-lab.com/api/home/recent', {
|
||||
const response = await fetchApi(this.site + 'api/home/recent', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -148,7 +148,7 @@ class WTRLAB implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const response = await fetch(this.site + 'api/search', {
|
||||
const response = await fetchApi(this.site + 'api/search', {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Referer: this.site + this.sourceLang,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile, fetchProto } from '@libs/fetch';
|
||||
import { fetchApi, fetchProto } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
@@ -105,6 +105,7 @@ class WuxiaWorld implements Plugin.PluginBase {
|
||||
name = 'Wuxia World';
|
||||
icon = 'src/en/wuxiaworld/icon.png';
|
||||
site = 'https://www.wuxiaworld.com/';
|
||||
apiSite = 'https://api2.wuxiaworld.com/wuxiaworld.api.v2.';
|
||||
filters?: Filters | undefined;
|
||||
version = '0.5.0';
|
||||
|
||||
@@ -126,10 +127,7 @@ class WuxiaWorld implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const link = `${this.site}api/novels`;
|
||||
|
||||
const result = await fetchApi(link);
|
||||
@@ -146,7 +144,7 @@ class WuxiaWorld implements Plugin.PluginBase {
|
||||
responseType: 'GetNovelResponse',
|
||||
requestData: { slug: novelPath.split('/')[1] },
|
||||
},
|
||||
'https://api2.wuxiaworld.com/wuxiaworld.api.v2.Novels/GetNovel',
|
||||
this.apiSite + 'Novels/GetNovel',
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/grpc-web+proto',
|
||||
@@ -201,7 +199,7 @@ class WuxiaWorld implements Plugin.PluginBase {
|
||||
responseType: 'GetChapterListResponse',
|
||||
requestData: { novelId: data.item?.id },
|
||||
},
|
||||
'https://api2.wuxiaworld.com/wuxiaworld.api.v2.Chapters/GetChapterList',
|
||||
this.apiSite + 'Chapters/GetChapterList',
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/grpc-web+proto',
|
||||
@@ -256,7 +254,7 @@ class WuxiaWorld implements Plugin.PluginBase {
|
||||
},
|
||||
},
|
||||
},
|
||||
'https://api2.wuxiaworld.com/wuxiaworld.api.v2.Chapters/GetChapter',
|
||||
this.apiSite + 'Chapters/GetChapter',
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/grpc-web+proto',
|
||||
@@ -271,13 +269,8 @@ class WuxiaWorld implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const searchUrl = 'https://www.wuxiaworld.com/api/novels/search?query=';
|
||||
|
||||
const url = searchUrl + searchTerm;
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + 'api/novels/search?query=' + searchTerm;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const data = await result.json();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CheerioAPI, load } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -27,7 +27,7 @@ class ChireadsPlugin implements Plugin.PluginBase {
|
||||
{ filters, showLatestNovels }: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site;
|
||||
let tag: string = 'all';
|
||||
let tag = 'all';
|
||||
if (showLatestNovels) url += '/category/translatedtales/page/' + pageNo;
|
||||
else {
|
||||
if (
|
||||
@@ -41,7 +41,7 @@ class ChireadsPlugin implements Plugin.PluginBase {
|
||||
}
|
||||
let $ = await this.getCheerio(url);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
let novel: Plugin.NovelItem;
|
||||
|
||||
if (showLatestNovels || tag !== 'all') {
|
||||
@@ -133,7 +133,7 @@ class ChireadsPlugin implements Plugin.PluginBase {
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = { path: novelPath, name: 'Sans titre' };
|
||||
|
||||
let $ = await this.getCheerio(this.site + novelPath);
|
||||
const $ = await this.getCheerio(this.site + novelPath);
|
||||
|
||||
novel.name =
|
||||
$('.inform-product-txt').first().text().trim() ||
|
||||
@@ -146,7 +146,7 @@ class ChireadsPlugin implements Plugin.PluginBase {
|
||||
$('.inform-inform-txt').text().trim() ||
|
||||
$('.inform-intr-txt').text().trim();
|
||||
|
||||
let infos =
|
||||
const infos =
|
||||
$('div.inform-product-txt > div.inform-intr-col').text().trim() ||
|
||||
$('div.inform-inform-data > h6').text().trim();
|
||||
if (infos.includes('Auteur : '))
|
||||
@@ -178,7 +178,7 @@ class ChireadsPlugin implements Plugin.PluginBase {
|
||||
break;
|
||||
}
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
let chapterList = $('.chapitre-table a');
|
||||
if (!chapterList.length) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CheerioAPI, load } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -12,7 +11,6 @@ class HarkenEliwoodPlugin implements Plugin.PluginBase {
|
||||
icon = 'src/fr/harkeneliwood/icon.png';
|
||||
site = 'https://harkeneliwood.wordpress.com';
|
||||
version = '1.0.0';
|
||||
filters: Filters | undefined = undefined;
|
||||
|
||||
async getCheerio(url: string): Promise<CheerioAPI> {
|
||||
const r = await fetchApi(url, {
|
||||
@@ -23,19 +21,13 @@ class HarkenEliwoodPlugin implements Plugin.PluginBase {
|
||||
return $;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo > 1) return [];
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
let novel: Plugin.NovelItem;
|
||||
let url = this.site;
|
||||
let $ = await this.getCheerio(url + '/projets/');
|
||||
const url = this.site;
|
||||
const $ = await this.getCheerio(url + '/projets/');
|
||||
$('#content .entry-content [href]')
|
||||
// We don't collect items for Facebook and Twitter.
|
||||
.not('[rel="nofollow noopener noreferrer"]')
|
||||
@@ -60,14 +52,14 @@ class HarkenEliwoodPlugin implements Plugin.PluginBase {
|
||||
name: 'Sans titre',
|
||||
};
|
||||
|
||||
let $ = await this.getCheerio(this.site + novelPath);
|
||||
const $ = await this.getCheerio(this.site + novelPath);
|
||||
novel.name = $('#content h1.entry-title').text().trim();
|
||||
novel.cover =
|
||||
$('#content .entry-content p img').first().attr('src') || defaultCover;
|
||||
novel.summary = this.getSummary($('#content .entry-content').text());
|
||||
novel.author = this.getAuthor($('#content .entry-content').text());
|
||||
novel.status = NovelStatus.Ongoing;
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
$('#content .entry-content p a').each((i, elem) => {
|
||||
const chapterName = $(elem).text().trim();
|
||||
const chapterUrl = $(elem).attr('href');
|
||||
@@ -88,14 +80,13 @@ class HarkenEliwoodPlugin implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
getSummary(text: string) {
|
||||
let resume: string = '';
|
||||
const regexResume1: RegExp = /Synopsis :([\s\S]*)Traduction anglaise/i;
|
||||
const regexResume2: RegExp = /Synopsis :([\s\S]*)Raw :/i;
|
||||
const regexResume3: RegExp =
|
||||
/Synopsis 1 :([\s\S]*)Synopsis 2 :([\s\S]*)Raw :/i;
|
||||
const regexResume4: RegExp = /Synopsis :([\s\S]*)Prélude/i;
|
||||
const regexResume5: RegExp = /Synospis :([\s\S]*)Original /i;
|
||||
const regexResume6: RegExp = /([\s\S]*)Raw :/i;
|
||||
let resume = '';
|
||||
const regexResume1 = /Synopsis :([\s\S]*)Traduction anglaise/i;
|
||||
const regexResume2 = /Synopsis :([\s\S]*)Raw :/i;
|
||||
const regexResume3 = /Synopsis 1 :([\s\S]*)Synopsis 2 :([\s\S]*)Raw :/i;
|
||||
const regexResume4 = /Synopsis :([\s\S]*)Prélude/i;
|
||||
const regexResume5 = /Synospis :([\s\S]*)Original /i;
|
||||
const regexResume6 = /([\s\S]*)Raw :/i;
|
||||
|
||||
const match1: RegExpExecArray | null = regexResume1.exec(text);
|
||||
const match2: RegExpExecArray | null = regexResume2.exec(text);
|
||||
@@ -151,12 +142,9 @@ class HarkenEliwoodPlugin implements Plugin.PluginBase {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo !== 1) return [];
|
||||
|
||||
let popularNovels = this.popularNovels(1, {
|
||||
showLatestNovels: true,
|
||||
filters: undefined,
|
||||
});
|
||||
const popularNovels = this.popularNovels(1);
|
||||
|
||||
let novels = (await popularNovels).filter(novel =>
|
||||
const novels = (await popularNovels).filter(novel =>
|
||||
novel.name
|
||||
.toLowerCase()
|
||||
.normalize('NFD')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CheerioAPI, load } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
|
||||
@@ -11,7 +10,6 @@ class KissWoodPlugin implements Plugin.PluginBase {
|
||||
icon = 'src/fr/kisswood/icon.png';
|
||||
site = 'https://kisswood.eu';
|
||||
version = '1.0.0';
|
||||
filters: Filters | undefined = undefined;
|
||||
|
||||
async getCheerio(url: string): Promise<CheerioAPI> {
|
||||
const r = await fetchApi(url);
|
||||
@@ -41,7 +39,7 @@ class KissWoodPlugin implements Plugin.PluginBase {
|
||||
novel: Plugin.SourceNovel,
|
||||
url: string,
|
||||
): Promise<Plugin.SourceNovel> {
|
||||
let $ = await this.getCheerio(url);
|
||||
const $ = await this.getCheerio(url);
|
||||
|
||||
const textArray: string[] = $('.entry-content p')
|
||||
.map((_, element) => $(element).text().trim())
|
||||
@@ -88,18 +86,12 @@ class KissWoodPlugin implements Plugin.PluginBase {
|
||||
return '';
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo > 1) return [];
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const $ = await this.getCheerio(this.site);
|
||||
var listUrlCover: string[] = [];
|
||||
const listUrlCover: string[] = [];
|
||||
$('nav div div ul li ul li').each((i, elem) => {
|
||||
if ($(elem).text().trim() === 'Sommaire') {
|
||||
const novelName = $(elem)
|
||||
@@ -137,7 +129,7 @@ class KissWoodPlugin implements Plugin.PluginBase {
|
||||
status: NovelStatus.Ongoing,
|
||||
};
|
||||
|
||||
let $ = await this.getCheerio(this.site + novelPath);
|
||||
const $ = await this.getCheerio(this.site + novelPath);
|
||||
let novelUrl = null;
|
||||
|
||||
$('nav div div ul li ul li').each((i, elem) => {
|
||||
@@ -160,7 +152,7 @@ class KissWoodPlugin implements Plugin.PluginBase {
|
||||
'.entry-content blockquote a',
|
||||
].join(', ');
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
$(chapterSelectors).each((i, elem) => {
|
||||
const chapterName = $(elem).text().trim();
|
||||
const chapterUrl = $(elem).attr('href')?.replace('http://', 'https://');
|
||||
@@ -224,12 +216,9 @@ class KissWoodPlugin implements Plugin.PluginBase {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo !== 1) return [];
|
||||
|
||||
let popularNovels = this.popularNovels(1, {
|
||||
showLatestNovels: true,
|
||||
filters: undefined,
|
||||
});
|
||||
const popularNovels = this.popularNovels(1);
|
||||
|
||||
let novels = (await popularNovels).filter(novel =>
|
||||
const novels = (await popularNovels).filter(novel =>
|
||||
novel.name
|
||||
.toLowerCase()
|
||||
.normalize('NFD')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { load, CheerioAPI } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
@@ -24,7 +24,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
parseDate(date: string): string {
|
||||
const monthMapping: { [key: string]: string } = {
|
||||
const monthMapping: Record<string, string> = {
|
||||
janvier: 'January',
|
||||
fevrier: 'February',
|
||||
mars: 'March',
|
||||
@@ -49,7 +49,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
$: CheerioAPI,
|
||||
showLatestNovels: boolean | undefined,
|
||||
): Plugin.NovelItem[] {
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
$('article').each((i, el) => {
|
||||
const cheerio = $(el);
|
||||
@@ -83,7 +83,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
let url = this.site;
|
||||
if (showLatestNovels) url += 'chapitre';
|
||||
else {
|
||||
let cat_gen: string = 'all';
|
||||
let cat_gen = 'all';
|
||||
if (filters && typeof filters.categorie_genre.value == 'string')
|
||||
cat_gen = filters.categorie_genre.value;
|
||||
if (
|
||||
@@ -98,7 +98,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
else url += 'roman';
|
||||
}
|
||||
url += '/page/' + pageNo;
|
||||
let $ = await this.getCheerio(url);
|
||||
const $ = await this.getCheerio(url);
|
||||
if (!$) return [];
|
||||
return this.parseNovels($, showLatestNovels);
|
||||
}
|
||||
@@ -107,16 +107,16 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
const $ = await this.getCheerio(this.site + novelPath);
|
||||
if (!$) throw new Error('Failed to load page (open in web view)');
|
||||
|
||||
let novel: Plugin.SourceNovel = { path: novelPath, name: 'Untitled' };
|
||||
const novel: Plugin.SourceNovel = { path: novelPath, name: 'Untitled' };
|
||||
|
||||
novel.name =
|
||||
(
|
||||
$('div.entry-content > div > strong')[0].nextSibling as Text | null
|
||||
$('div.entry-content > div > strong')[0].nextSibling as string | null
|
||||
)?.nodeValue?.trim() || 'Untitled';
|
||||
|
||||
novel.cover = $('.su-row > div > div > img').attr('src') || defaultCover;
|
||||
|
||||
let novelInfos = $('div[data-title=Tomes] >').toArray();
|
||||
const novelInfos = $('div[data-title=Tomes] >').toArray();
|
||||
novelInfos.pop();
|
||||
novelInfos.shift();
|
||||
novel.summary =
|
||||
@@ -149,7 +149,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
if (genres)
|
||||
novel.genres = novel.genres ? novel.genres + ',' + genres : genres;
|
||||
|
||||
let status = $("strong:contains('Statut :')").parent().attr('class');
|
||||
const status = $("strong:contains('Statut :')").parent().attr('class');
|
||||
switch (status) {
|
||||
case 'type etat0':
|
||||
case 'type etat1':
|
||||
@@ -169,13 +169,13 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
break;
|
||||
}
|
||||
|
||||
let novelChapters: Plugin.ChapterItem[] = [];
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
const volumes = $('div[data-title=Tomes] > div').last().contents();
|
||||
const hasMultipleVolumes = volumes.length > 1;
|
||||
|
||||
let chapterName = '';
|
||||
let site = this.site;
|
||||
const site = this.site;
|
||||
volumes.each((volumeIndex: number, el) => {
|
||||
if (hasMultipleVolumes) chapterName = 'T.' + (volumeIndex + 1) + ' ';
|
||||
$(el)
|
||||
@@ -189,20 +189,16 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
const dateHtml =
|
||||
cheerio.html()?.substring(cheerio.html()?.indexOf('</a>') || 0) ||
|
||||
'';
|
||||
let releaseDate =
|
||||
const releaseDate =
|
||||
dateHtml?.substring(
|
||||
dateHtml.indexOf('(') + 1,
|
||||
dateHtml.indexOf(')'),
|
||||
) || undefined;
|
||||
if (releaseDate)
|
||||
try {
|
||||
releaseDate = this.parseDate(releaseDate);
|
||||
} catch (e) {}
|
||||
const chapterUrl = cheerio.find('a').attr('href');
|
||||
if (chapterUrl) {
|
||||
const chapter: Plugin.ChapterItem = {
|
||||
name: newChapterName,
|
||||
releaseTime: releaseDate,
|
||||
releaseTime: this.parseDate(releaseDate),
|
||||
path: chapterUrl.replace(site, ''),
|
||||
chapterNumber: chapterIndex,
|
||||
};
|
||||
@@ -232,13 +228,9 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
});
|
||||
if (dates.length == hrefs.length)
|
||||
dates.forEach((date, index) => {
|
||||
let releaseDate = date;
|
||||
try {
|
||||
releaseDate = this.parseDate(date);
|
||||
} catch (e) {}
|
||||
const chapter: Plugin.ChapterItem = {
|
||||
name: newChapterName + ' (' + (index + 1) + ')',
|
||||
releaseTime: releaseDate,
|
||||
releaseTime: this.parseDate(date),
|
||||
path: hrefs[index].replace(site, ''),
|
||||
chapterNumber: chapterIndex + (index + 1) / 1000,
|
||||
};
|
||||
@@ -258,7 +250,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
if (!$) throw new Error('Failed to load page (open in web view)');
|
||||
|
||||
$('.mistape_caption').remove();
|
||||
let chapterText =
|
||||
const chapterText =
|
||||
$('.chapter-content').html() || $('.entry-content').html() || '';
|
||||
return chapterText;
|
||||
}
|
||||
@@ -268,7 +260,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
|
||||
num: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
if (num !== 1) return []; // only 1 page of results
|
||||
let url = this.site + 'roman';
|
||||
const url = this.site + 'roman';
|
||||
const $ = await this.getCheerio(url);
|
||||
if (!$) throw new Error('Failed to load page (open in web view)');
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CheerioAPI, load } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
|
||||
@@ -11,7 +10,6 @@ class NovhellPlugin implements Plugin.PluginBase {
|
||||
icon = 'src/fr/novhell/icon.png';
|
||||
site = 'https://novhell.org';
|
||||
version = '1.0.1';
|
||||
filters: Filters | undefined = undefined;
|
||||
|
||||
async getCheerio(url: string): Promise<CheerioAPI> {
|
||||
const r = await fetchApi(url, {
|
||||
@@ -22,19 +20,13 @@ class NovhellPlugin implements Plugin.PluginBase {
|
||||
return $;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo > 1) return [];
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
let novel: Plugin.NovelItem;
|
||||
let url = this.site;
|
||||
let $ = await this.getCheerio(url);
|
||||
const url = this.site;
|
||||
const $ = await this.getCheerio(url);
|
||||
$('article div div div figure').each((i, elem) => {
|
||||
let novelName = $(elem)
|
||||
.find('figcaption span strong')
|
||||
@@ -65,7 +57,7 @@ class NovhellPlugin implements Plugin.PluginBase {
|
||||
name: 'Sans titre',
|
||||
};
|
||||
|
||||
let $ = await this.getCheerio(this.site + novelPath);
|
||||
const $ = await this.getCheerio(this.site + novelPath);
|
||||
|
||||
novel.name =
|
||||
$('meta[property="og:title"]')
|
||||
@@ -114,7 +106,7 @@ class NovhellPlugin implements Plugin.PluginBase {
|
||||
.replace('Synopsis', '')
|
||||
.replace(':', '')
|
||||
.trim();
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
$('main div article div div section div div div div div p a').each(
|
||||
(i, elem) => {
|
||||
@@ -190,12 +182,9 @@ class NovhellPlugin implements Plugin.PluginBase {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo !== 1) return [];
|
||||
|
||||
let popularNovels = this.popularNovels(1, {
|
||||
showLatestNovels: true,
|
||||
filters: undefined,
|
||||
});
|
||||
const popularNovels = this.popularNovels(1);
|
||||
|
||||
let novels = (await popularNovels).filter(novel =>
|
||||
const novels = (await popularNovels).filter(novel =>
|
||||
novel.name
|
||||
.toLowerCase()
|
||||
.normalize('NFD')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CheerioAPI, load } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
@@ -39,7 +39,7 @@ class PhenixScansTradPlugin implements Plugin.PluginBase {
|
||||
const order = showLatestNovels ? 'update' : 'popular';
|
||||
const url = `${this.site}/manga/?page=${pageNo}${filter}&status=&type=novel&order=${order}`;
|
||||
|
||||
let $ = await this.getCheerio(url);
|
||||
const $ = await this.getCheerio(url);
|
||||
$('div div div div a').each((i, elem) => {
|
||||
const novelName = $(elem).attr('title')?.trim();
|
||||
const novelUrl = $(elem).attr('href');
|
||||
@@ -63,7 +63,7 @@ class PhenixScansTradPlugin implements Plugin.PluginBase {
|
||||
name: 'Sans titre',
|
||||
};
|
||||
|
||||
let $ = await this.getCheerio(this.site + novelPath);
|
||||
const $ = await this.getCheerio(this.site + novelPath);
|
||||
|
||||
novel.name = $('h1[itemprop=name]').text().replace('– Novel', '').trim();
|
||||
novel.cover =
|
||||
@@ -80,7 +80,7 @@ class PhenixScansTradPlugin implements Plugin.PluginBase {
|
||||
$('.tsinfo .imptdt:contains(Statut)').text().replace('Statut', '').trim(),
|
||||
);
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
$('ul li:has(div.chbox):has(div.eph-num)').each((i, elem) => {
|
||||
const chapterName = $(elem).find('a .chapternum').text().trim();
|
||||
const chapterUrl = $(elem).find('a').attr('href');
|
||||
@@ -98,7 +98,7 @@ class PhenixScansTradPlugin implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
parseDate(date: string): string {
|
||||
const monthMapping: { [key: string]: string } = {
|
||||
const monthMapping: Record<string, string> = {
|
||||
janvier: 'January',
|
||||
fevrier: 'February',
|
||||
mars: 'March',
|
||||
@@ -149,12 +149,12 @@ class PhenixScansTradPlugin implements Plugin.PluginBase {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo !== 1) return [];
|
||||
|
||||
let popularNovels = this.popularNovels(1, {
|
||||
const popularNovels = this.popularNovels(1, {
|
||||
showLatestNovels: true,
|
||||
filters: undefined,
|
||||
});
|
||||
|
||||
let novels = (await popularNovels).filter(novel =>
|
||||
const novels = (await popularNovels).filter(novel =>
|
||||
novel.name
|
||||
.toLowerCase()
|
||||
.normalize('NFD')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CheerioAPI, load } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -12,7 +11,6 @@ class WarriorLegendTradPlugin implements Plugin.PluginBase {
|
||||
icon = 'src/fr/warriorlegendtrad/icon.png';
|
||||
site = 'https://warriorlegendtrad.fr';
|
||||
version = '1.0.0';
|
||||
filters: Filters | undefined = undefined;
|
||||
|
||||
regexAuthors = [/Auteur\u00A0:([^\n]*)/];
|
||||
|
||||
@@ -27,13 +25,7 @@ class WarriorLegendTradPlugin implements Plugin.PluginBase {
|
||||
return $;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo > 2) return [];
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
@@ -48,7 +40,7 @@ class WarriorLegendTradPlugin implements Plugin.PluginBase {
|
||||
url = this.site + '/crea';
|
||||
}
|
||||
|
||||
let $ = await this.getCheerio(url);
|
||||
const $ = await this.getCheerio(url);
|
||||
$('div div div article').each((i, elem) => {
|
||||
const novelName = $(elem).find('.entry-wrapper h2').first().text().trim();
|
||||
const novelUrl = $(elem).find('.entry-wrapper h2 a').attr('href');
|
||||
@@ -73,7 +65,7 @@ class WarriorLegendTradPlugin implements Plugin.PluginBase {
|
||||
name: 'Sans titre',
|
||||
};
|
||||
|
||||
let $ = await this.getCheerio(this.site + novelPath);
|
||||
const $ = await this.getCheerio(this.site + novelPath);
|
||||
|
||||
novel.name = $('.site-main article header h1').text().trim();
|
||||
novel.cover =
|
||||
@@ -84,7 +76,7 @@ class WarriorLegendTradPlugin implements Plugin.PluginBase {
|
||||
novel.summary = this.extractInfo(entryContentText, this.regexSummary);
|
||||
novel.status = this.getStatus(entryContentText);
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
$('div div article div')
|
||||
.find('h2 a, h3 a')
|
||||
.each((i, elem) => {
|
||||
@@ -150,7 +142,7 @@ class WarriorLegendTradPlugin implements Plugin.PluginBase {
|
||||
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const $ = await this.getCheerio(this.site + chapterPath);
|
||||
var contenuHtml = '';
|
||||
let contenuHtml = '';
|
||||
$('.entry-content')
|
||||
.contents()
|
||||
.each(function () {
|
||||
@@ -171,12 +163,9 @@ class WarriorLegendTradPlugin implements Plugin.PluginBase {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo !== 1) return [];
|
||||
|
||||
let popularNovels = this.popularNovels(1, {
|
||||
showLatestNovels: true,
|
||||
filters: undefined,
|
||||
});
|
||||
const popularNovels = this.popularNovels(1);
|
||||
|
||||
let novels = (await popularNovels).filter(novel =>
|
||||
const novels = (await popularNovels).filter(novel =>
|
||||
novel.name
|
||||
.toLowerCase()
|
||||
.normalize('NFD')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CheerioAPI, load } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -12,7 +11,6 @@ class WuxialnscantradPlugin implements Plugin.PluginBase {
|
||||
icon = 'src/fr/wuxialnscantrad/icon.png';
|
||||
site = 'https://wuxialnscantrad.wordpress.com';
|
||||
version = '1.0.0';
|
||||
filters: Filters | undefined = undefined;
|
||||
|
||||
async getCheerio(url: string): Promise<CheerioAPI> {
|
||||
const r = await fetchApi(url, {
|
||||
@@ -23,19 +21,13 @@ class WuxialnscantradPlugin implements Plugin.PluginBase {
|
||||
return $;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo > 1) return [];
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
let novel: Plugin.NovelItem;
|
||||
let url = this.site;
|
||||
let $ = await this.getCheerio(url);
|
||||
const url = this.site;
|
||||
const $ = await this.getCheerio(url);
|
||||
$('#menu-item-2210 ul li').each((i, elem) => {
|
||||
const novelName = $(elem).first().text().trim();
|
||||
const novelUrl = $(elem).find('a').attr('href');
|
||||
@@ -58,7 +50,7 @@ class WuxialnscantradPlugin implements Plugin.PluginBase {
|
||||
name: 'Sans titre',
|
||||
};
|
||||
|
||||
let $ = await this.getCheerio(this.site + novelPath);
|
||||
const $ = await this.getCheerio(this.site + novelPath);
|
||||
|
||||
novel.name = $('.entry-title').text().trim();
|
||||
novel.cover =
|
||||
@@ -72,8 +64,8 @@ class WuxialnscantradPlugin implements Plugin.PluginBase {
|
||||
novel.summary = this.getSummary(entryContentText);
|
||||
novel.status = this.getStatus(entryContentText);
|
||||
|
||||
var pathChapter = $('.entry-content ul').first().children('li');
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const pathChapter = $('.entry-content ul').first().children('li');
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
pathChapter.each((i, elem) => {
|
||||
const chapterName = $(elem).text().trim();
|
||||
const chapterUrl = $(elem).find('a').attr('href');
|
||||
@@ -164,7 +156,7 @@ class WuxialnscantradPlugin implements Plugin.PluginBase {
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const $ = await this.getCheerio(this.site + chapterPath);
|
||||
|
||||
var contenuHtml = '';
|
||||
let contenuHtml = '';
|
||||
$('.entry-content')
|
||||
.contents()
|
||||
.each(function () {
|
||||
@@ -189,12 +181,9 @@ class WuxialnscantradPlugin implements Plugin.PluginBase {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
if (pageNo !== 1) return [];
|
||||
|
||||
let popularNovels = this.popularNovels(1, {
|
||||
showLatestNovels: true,
|
||||
filters: undefined,
|
||||
});
|
||||
const popularNovels = this.popularNovels(1);
|
||||
|
||||
let novels = (await popularNovels).filter(novel =>
|
||||
const novels = (await popularNovels).filter(novel =>
|
||||
novel.name
|
||||
.toLowerCase()
|
||||
.normalize('NFD')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Cheerio, CheerioAPI, load, Element } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
|
||||
@@ -11,7 +10,6 @@ class XiaowazPlugin implements Plugin.PluginBase {
|
||||
icon = 'src/fr/xiaowaz/icon.png';
|
||||
site = 'https://xiaowaz.fr';
|
||||
version = '1.0.1';
|
||||
filters: Filters | undefined = undefined;
|
||||
static novels: Plugin.NovelItem[] | undefined;
|
||||
|
||||
async getCheerio(url: string): Promise<CheerioAPI> {
|
||||
@@ -35,9 +33,9 @@ class XiaowazPlugin implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async getAllNovels(): Promise<Plugin.NovelItem[]> {
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
let novel: Plugin.NovelItem;
|
||||
let $ = await this.getCheerio(this.site);
|
||||
const $ = await this.getCheerio(this.site);
|
||||
|
||||
const categories: Cheerio<Element>[] = [
|
||||
$('li.page_item').find('a:contains("Séries")').parent(),
|
||||
@@ -78,7 +76,7 @@ class XiaowazPlugin implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async popularNovels(pageNo: number, {}: any): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const PAGE_SIZE = 5;
|
||||
|
||||
if (!XiaowazPlugin.novels) XiaowazPlugin.novels = await this.getAllNovels();
|
||||
@@ -99,7 +97,7 @@ class XiaowazPlugin implements Plugin.PluginBase {
|
||||
name: 'Sans titre',
|
||||
};
|
||||
|
||||
let $ = await this.getCheerio(this.site + novelPath);
|
||||
const $ = await this.getCheerio(this.site + novelPath);
|
||||
|
||||
novel.name = $('.card_title').text().trim();
|
||||
novel.cover =
|
||||
@@ -164,12 +162,12 @@ class XiaowazPlugin implements Plugin.PluginBase {
|
||||
|
||||
//Search for chapter links within ul/li tags; otherwise, within p/a tags,
|
||||
//but not both at the same time because otherwise, on the TDG page, it redirects to a PDF download link.
|
||||
var pathChapter = $('.entry-content ul li a');
|
||||
let pathChapter = $('.entry-content ul li a');
|
||||
if (pathChapter.length === 0) {
|
||||
pathChapter = $('.entry-content p a');
|
||||
}
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
pathChapter.each((i, elem) => {
|
||||
const chapterName = $(elem).text().trim();
|
||||
const chapterUrl = $(elem).attr('href');
|
||||
@@ -272,11 +270,11 @@ class XiaowazPlugin implements Plugin.PluginBase {
|
||||
if (pageNo !== 1) return [];
|
||||
|
||||
if (!XiaowazPlugin.novels) XiaowazPlugin.novels = await this.getAllNovels();
|
||||
let popularNovels = XiaowazPlugin.novels;
|
||||
const popularNovels = XiaowazPlugin.novels;
|
||||
|
||||
// Normalize the text to remove accents and other special characters
|
||||
// This ensures that the search term and novel names are compared accurately
|
||||
let novels = popularNovels.filter(novel =>
|
||||
const novels = popularNovels.filter(novel =>
|
||||
novel.name
|
||||
.toLowerCase()
|
||||
.normalize('NFD')
|
||||
|
||||
@@ -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, FilterTypes } from '@libs/filterInputs';
|
||||
|
||||
@@ -36,7 +36,7 @@ class IndoWebNovel implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
page: number = 1,
|
||||
page = 1,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
/*
|
||||
@@ -50,7 +50,7 @@ class IndoWebNovel implements Plugin.PluginBase {
|
||||
if (filters.genre.value.length)
|
||||
link += filters.genre.value.map(i => `&genre[]=${i}`).join('');
|
||||
*/
|
||||
let link = this.site + `page/${page}/?s`;
|
||||
const link = this.site + `page/${page}/?s`;
|
||||
const result = await fetchApi(link);
|
||||
const body = await result.text();
|
||||
|
||||
@@ -114,7 +114,7 @@ class IndoWebNovel implements Plugin.PluginBase {
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
page: number = 1,
|
||||
page = 1,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
/*
|
||||
let link = `${this.site}advanced-search/page/${page}/?title=${searchTerm}&author=&yearx=`;
|
||||
@@ -123,7 +123,7 @@ class IndoWebNovel implements Plugin.PluginBase {
|
||||
link += `&order=${this.filters.sort.value}`;
|
||||
link += this.filters.lang.value.map(i => `&country[]=${i}`).join('');
|
||||
*/
|
||||
let link = this.site + `page/${page}/?s=${searchTerm}`;
|
||||
const link = this.site + `page/${page}/?s=${searchTerm}`;
|
||||
const result = await fetchApi(link);
|
||||
const body = await result.text();
|
||||
|
||||
|
||||
@@ -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, FilterTypes } from '@libs/filterInputs';
|
||||
|
||||
@@ -80,8 +80,8 @@ class NovelRingan implements Plugin.PluginBase {
|
||||
loadedCheerio('img.ts-post-image').attr('data-sxrx');
|
||||
|
||||
loadedCheerio('.maininfo li').each(function () {
|
||||
let detailName = loadedCheerio(this).find('b').text().trim();
|
||||
let detail = loadedCheerio(this).find('b').remove().end().text().trim();
|
||||
const detailName = loadedCheerio(this).find('b').text().trim();
|
||||
const detail = loadedCheerio(this).find('b').remove().end().text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Status:':
|
||||
|
||||
@@ -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, FilterTypes } from '@libs/filterInputs';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { load, load as loadCheerio } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { load as loadCheerio } from 'cheerio';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
@@ -20,7 +20,7 @@ class Syosetu implements Plugin.PluginBase {
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||
};
|
||||
searchUrl = (pagenum?: number, order?: string) => {
|
||||
return `https://yomou.syosetu.com/search.php?order=${order || 'hyoka'}${
|
||||
return `${this.site}search.php?order=${order || 'hyoka'}${
|
||||
pagenum !== undefined
|
||||
? `&p=${pagenum <= 1 || pagenum > 100 ? '1' : pagenum}` // check if pagenum is between 1 and 100
|
||||
: '' // if isn't don't set ?p
|
||||
@@ -71,15 +71,15 @@ class Syosetu implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const result = await fetch(this.novelPrefix + novelPath, {
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
const result = await fetchApi(this.novelPrefix + novelPath, {
|
||||
headers: this.headers,
|
||||
});
|
||||
const body = await result.text();
|
||||
const loadedCheerio = loadCheerio(body, { decodeEntities: false });
|
||||
|
||||
// create novel object
|
||||
let novel: Plugin.SourceNovel = {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('.novel_title').text(),
|
||||
author: loadedCheerio('.novel_writername').text().replace('作者:', ''),
|
||||
@@ -93,7 +93,7 @@ class Syosetu implements Plugin.PluginBase {
|
||||
novel.summary = loadedCheerio('#novel_ex')
|
||||
.text()
|
||||
.replace(/<\s*br.*?>/g, '\n');
|
||||
cqGetChapters.each(function (i, e) {
|
||||
cqGetChapters.each(() => {
|
||||
const chapterA = loadedCheerio(this).find('a');
|
||||
const [chapterName, releaseDate, chapterUrl] = [
|
||||
// set the variables
|
||||
@@ -121,9 +121,12 @@ class Syosetu implements Plugin.PluginBase {
|
||||
*/
|
||||
// get summary for oneshot chapter
|
||||
|
||||
const nameResult = await fetch(this.searchUrl() + `&word=${novel.name}`, {
|
||||
headers: this.headers,
|
||||
});
|
||||
const nameResult = await fetchApi(
|
||||
this.searchUrl() + `&word=${novel.name}`,
|
||||
{
|
||||
headers: this.headers,
|
||||
},
|
||||
);
|
||||
const nameBody = await nameResult.text();
|
||||
const summaryQuery = loadCheerio(nameBody, {
|
||||
decodeEntities: false,
|
||||
@@ -148,7 +151,7 @@ class Syosetu implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetch(this.novelPrefix + chapterPath, {
|
||||
const result = await fetchApi(this.novelPrefix + chapterPath, {
|
||||
headers: this.headers,
|
||||
});
|
||||
const body = await result.text();
|
||||
@@ -158,7 +161,7 @@ class Syosetu implements Plugin.PluginBase {
|
||||
decodeEntities: false,
|
||||
});
|
||||
|
||||
let chapterText =
|
||||
const chapterText =
|
||||
cheerioQuery('#novel_honbun') // get chapter text
|
||||
.html() || '';
|
||||
return chapterText;
|
||||
@@ -173,12 +176,12 @@ class Syosetu implements Plugin.PluginBase {
|
||||
const getNovelsFromPage = async (pagenumber: number) => {
|
||||
// load page
|
||||
const url = this.searchUrl(pagenumber) + `&word=${searchTerm}`;
|
||||
const result = await fetch(url, { headers: this.headers });
|
||||
const result = await fetchApi(url, { headers: this.headers });
|
||||
const body = await result.text();
|
||||
// Cheerio it!
|
||||
const cheerioQuery = loadCheerio(body, { decodeEntities: false });
|
||||
|
||||
let pageNovels: Plugin.NovelItem[] = [];
|
||||
const pageNovels: Plugin.NovelItem[] = [];
|
||||
// find class=searchkekka_box
|
||||
cheerioQuery('.searchkekka_box').each((i, e) => {
|
||||
// get div with link and name
|
||||
@@ -218,7 +221,7 @@ class Syosetu implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
resolveUrl(path: string, isNovel?: boolean | undefined): string {
|
||||
resolveUrl(path: string): string {
|
||||
return this.novelPrefix + path;
|
||||
}
|
||||
filters = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fetchFile, fetchApi } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import qs from 'qs';
|
||||
@@ -7,12 +7,12 @@ class Agitoon implements Plugin.PluginBase {
|
||||
id = 'agit.xyz';
|
||||
name = 'Agitoon';
|
||||
icon = 'src/kr/agitoon/icon.png';
|
||||
site = 'https://agit659.xyz';
|
||||
version = '3.0.2';
|
||||
site = 'https://agit660.xyz';
|
||||
version = '3.0.3';
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ filters, showLatestNovels }: Plugin.PopularNovelsOptions,
|
||||
{ showLatestNovels }: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const res = await fetchApi(this.site + '/novel/index.update.php', {
|
||||
headers: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
@@ -100,11 +100,11 @@ class NovelkiPL implements Plugin.PluginBase {
|
||||
|
||||
//TODO: Dodać tłumacza danej serii :D
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
let chaptersList = loadedCheerio('.chapters > .col-md-3 > div').get();
|
||||
const chaptersList = loadedCheerio('.chapters > .col-md-3 > div').get();
|
||||
chaptersList.forEach((e, i) => {
|
||||
let urlChapters = loadedCheerio(e).find('a').attr('href') || '';
|
||||
const urlChapters = loadedCheerio(e).find('a').attr('href') || '';
|
||||
|
||||
const chapter: Plugin.ChapterItem = {
|
||||
name: loadedCheerio(e).find('a')?.text().trim(),
|
||||
@@ -125,8 +125,8 @@ class NovelkiPL implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
var pattern = /\/projekty\/([^\/]+)\/([^\/]+)/;
|
||||
let codeChapter = pattern.exec(chapterPath) || '';
|
||||
const pattern = /\/projekty\/([^/]+)\/([^/]+)/;
|
||||
const codeChapter = pattern.exec(chapterPath) || '';
|
||||
const body = await fetchApi(
|
||||
`${this.site}/api/reader/chapters/${codeChapter[2]}`,
|
||||
).then(res => {
|
||||
@@ -151,7 +151,7 @@ class NovelkiPL implements Plugin.PluginBase {
|
||||
});
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = loadedCheerio('#projects > div')
|
||||
const novels: Plugin.NovelItem[] = loadedCheerio('#projects > div')
|
||||
.map((index, element) => ({
|
||||
name: loadedCheerio(element)
|
||||
.find('.card-title')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -129,7 +128,7 @@ class freedlit implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
parseDate = (dateString: string | undefined = '') => {
|
||||
const months: { [key: string]: number } = {
|
||||
const months: Record<string, number> = {
|
||||
января: 1,
|
||||
февраля: 2,
|
||||
марта: 3,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { storage } from '@libs/storage';
|
||||
@@ -12,14 +12,15 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
name = 'Автор Тудей';
|
||||
icon = 'src/ru/authortoday/icon.png';
|
||||
site = 'https://author.today';
|
||||
apiUrl = 'https://api.author.today/v1/';
|
||||
apiSite = 'https://api.author.today/v1/';
|
||||
imageSite = 'https://cm.author.today/content/';
|
||||
version = '1.1.0';
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.apiUrl + 'catalog/search?page=' + pageNo;
|
||||
let url = this.apiSite + 'catalog/search?page=' + pageNo;
|
||||
if (filters?.genre?.value) {
|
||||
url += '&genre=' + filters.genre.value;
|
||||
}
|
||||
@@ -48,9 +49,7 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
result?.searchResults?.forEach(novel =>
|
||||
novels.push({
|
||||
name: novel.title,
|
||||
cover: novel.coverUrl
|
||||
? 'https://cm.author.today/content/' + novel.coverUrl
|
||||
: defaultCover,
|
||||
cover: novel.coverUrl ? this.imageSite + novel.coverUrl : defaultCover,
|
||||
path: novel.id.toString(),
|
||||
}),
|
||||
);
|
||||
@@ -61,7 +60,7 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
async parseNovel(workID: string): Promise<Plugin.SourceNovel> {
|
||||
if (!this.user) this.user = await this.getUser();
|
||||
const book: responseBook = await fetchApi(
|
||||
this.apiUrl + 'work/' + workID + '/details',
|
||||
this.apiSite + 'work/' + workID + '/details',
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + this.user?.token || 'guest',
|
||||
@@ -93,7 +92,7 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
const chaptersJSON: ChaptersEntity[] = await fetchApi(
|
||||
this.apiUrl + 'work/' + workID + '/content',
|
||||
this.apiSite + 'work/' + workID + '/content',
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + this.user?.token || 'guest',
|
||||
@@ -123,7 +122,7 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
const [workID, chapterID] = chapterPath.split('/');
|
||||
if (!this.user) this.user = await this.getUser();
|
||||
const result: encryptedСhapter = await fetchApi(
|
||||
this.apiUrl + `work/${workID}/chapter/${chapterID}/text`,
|
||||
this.apiSite + `work/${workID}/chapter/${chapterID}/text`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + this.user?.token || 'guest',
|
||||
@@ -183,7 +182,7 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
let user = storage.get('user') || { userId: '', token: 'guest' };
|
||||
if (user && user.userId && user.token) {
|
||||
const currentUser: currentUser = await fetchApi(
|
||||
this.apiUrl + 'account/current-user',
|
||||
this.apiSite + 'account/current-user',
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + user.token || 'guest',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -11,6 +11,7 @@ class Bookriver implements Plugin.PluginBase {
|
||||
id = 'bookriver';
|
||||
name = 'Bookriver';
|
||||
site = 'https://bookriver.ru';
|
||||
apiSite = 'https://api.bookriver.ru/api/v1/';
|
||||
version = '1.0.1';
|
||||
icon = 'src/ru/bookriver/icon.png';
|
||||
|
||||
@@ -99,7 +100,7 @@ class Bookriver implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = 'https://api.bookriver.ru/api/v1/books/chapter/text/';
|
||||
const url = this.apiSite + 'books/chapter/text/';
|
||||
const { data }: responseChapter = await fetchApi(
|
||||
url + chapterPath.split('/').pop(),
|
||||
).then(res => res.json());
|
||||
@@ -117,7 +118,8 @@ class Bookriver implements Plugin.PluginBase {
|
||||
pageNo: number | undefined = 1,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url =
|
||||
'https://api.bookriver.ru/api/v1/search/autocomplete?keyword=' +
|
||||
this.apiSite +
|
||||
'search/autocomplete?keyword=' +
|
||||
searchTerm +
|
||||
'&page=' +
|
||||
pageNo +
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
@@ -10,12 +10,13 @@ class ficbook implements Plugin.PluginBase {
|
||||
id = 'ficbook';
|
||||
name = 'ficbook';
|
||||
site = 'https://ficbook.net';
|
||||
imageSite = 'https://images.ficbook.net/fanfic-covers/';
|
||||
version = '1.0.1';
|
||||
icon = 'src/ru/ficbook/icon.png';
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions,
|
||||
{ filters }: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site;
|
||||
|
||||
@@ -162,9 +163,7 @@ class ficbook implements Plugin.PluginBase {
|
||||
data?.data?.forEach(novel => {
|
||||
const name = novel.title.trim();
|
||||
const path = '/readfic/' + novel.slug;
|
||||
const cover = novel.cover
|
||||
? 'https://images.ficbook.net/fanfic-covers/' + novel.cover
|
||||
: defaultCover;
|
||||
const cover = novel.cover ? this.imageSite + novel.cover : defaultCover;
|
||||
|
||||
novels.push({ name, cover, path });
|
||||
});
|
||||
@@ -173,7 +172,7 @@ class ficbook implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
parseDate = (dateString: string | undefined = '') => {
|
||||
const months: { [key: string]: number } = {
|
||||
const months: Record<string, number> = {
|
||||
января: 1,
|
||||
февраля: 2,
|
||||
марта: 3,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -84,7 +84,7 @@ class Jaomix implements Plugin.PluginBase {
|
||||
};
|
||||
|
||||
loadedCheerio('#info-book > p').each(function () {
|
||||
let text = loadedCheerio(this).text().replace(/,/g, '').split(' ');
|
||||
const text = loadedCheerio(this).text().replace(/,/g, '').split(' ');
|
||||
if (text[0] === 'Автор:') {
|
||||
novel.author = text.splice(1).join(' ');
|
||||
} else if (text[0] === 'Жанры:') {
|
||||
@@ -168,7 +168,7 @@ class Jaomix implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
parseDate = (dateString: string | undefined = '') => {
|
||||
const months: { [key: string]: number } = {
|
||||
const months: Record<string, number> = {
|
||||
Янв: 1,
|
||||
Фев: 2,
|
||||
Мар: 3,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
|
||||
const statusKey: { [key: string]: string } = {
|
||||
const statusKey: Record<string, string> = {
|
||||
'0': NovelStatus.Unknown,
|
||||
'1': NovelStatus.Ongoing,
|
||||
'2': NovelStatus.Completed,
|
||||
@@ -16,6 +16,7 @@ class Neobook implements Plugin.PluginBase {
|
||||
id = 'neobook';
|
||||
name = 'Neobook';
|
||||
site = 'https://neobook.org';
|
||||
apiSite = 'https://api.neobook.org/';
|
||||
version = '1.0.1';
|
||||
icon = 'src/ru/neobook/icon.png';
|
||||
|
||||
@@ -47,7 +48,7 @@ class Neobook implements Plugin.PluginBase {
|
||||
formData.append('filter_timeread', filters?.timeread?.value || '0-999999');
|
||||
|
||||
const { bundle_books }: { bundle_books: BundleBooks } = await fetchApi(
|
||||
'https://api.neobook.org/',
|
||||
this.apiSite,
|
||||
{
|
||||
method: 'post',
|
||||
body: formData,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -8,6 +8,7 @@ class novelOvh implements Plugin.PluginBase {
|
||||
id = 'novelovh';
|
||||
name = 'НовелОВХ';
|
||||
site = 'https://novel.ovh';
|
||||
apiSite = 'https://api.novel.ovh/v2/';
|
||||
version = '1.0.2';
|
||||
icon = 'src/ru/novelovh/icon.png';
|
||||
|
||||
@@ -61,8 +62,10 @@ class novelOvh implements Plugin.PluginBase {
|
||||
switch (person.type) {
|
||||
case 'AUTHOR':
|
||||
novel.author = person.publisher.name;
|
||||
break;
|
||||
case 'ARTIST':
|
||||
novel.artist = person.publisher.name;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -89,7 +92,7 @@ class novelOvh implements Plugin.PluginBase {
|
||||
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const book: responseChapter = await fetchApi(
|
||||
'https://api.novel.ovh/v2/chapters/' + chapterPath.split('/')[1],
|
||||
this.apiSite + 'chapters/' + chapterPath.split('/')[1],
|
||||
).then(res => res.json());
|
||||
|
||||
const image = Object.fromEntries(
|
||||
@@ -101,7 +104,7 @@ class novelOvh implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `https://api.novel.ovh/v2/books?type=NOVEL&search=${searchTerm}`;
|
||||
const url = this.apiSite + 'books?type=NOVEL&search=' + searchTerm;
|
||||
const books: BooksEntity[] = await fetchApi(url).then(res => res.json());
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
@@ -118,8 +121,8 @@ class novelOvh implements Plugin.PluginBase {
|
||||
|
||||
jsonToHtml = (
|
||||
json: ContentEntity[],
|
||||
image: { [key: string]: string },
|
||||
html: string = '',
|
||||
image: Record<string, string>,
|
||||
html = '',
|
||||
) => {
|
||||
json.forEach(element => {
|
||||
switch (element.type) {
|
||||
@@ -158,8 +161,7 @@ class novelOvh implements Plugin.PluginBase {
|
||||
return html;
|
||||
};
|
||||
|
||||
resolveUrl = (path: string, isNovel?: boolean) =>
|
||||
this.site + '/novel/' + path;
|
||||
resolveUrl = (path: string) => this.site + '/novel/' + path;
|
||||
|
||||
filters = {
|
||||
sort: {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const statusKey: { [key: string]: string } = {
|
||||
const statusKey: Record<string, string> = {
|
||||
'active': NovelStatus.Ongoing,
|
||||
'completed': NovelStatus.Completed,
|
||||
'freezed': NovelStatus.OnHiatus,
|
||||
@@ -195,7 +195,7 @@ class TL implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
resolveUrl = (path: string, isNovel?: boolean) => 'https://' + path;
|
||||
resolveUrl = (path: string) => 'https://' + path;
|
||||
|
||||
filters = {
|
||||
tags: {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const statusKey: { [key: number]: string } = {
|
||||
const statusKey: Record<number, string> = {
|
||||
1: NovelStatus.Ongoing,
|
||||
2: NovelStatus.Completed,
|
||||
3: NovelStatus.OnHiatus,
|
||||
@@ -133,7 +133,7 @@ class RNBH implements Plugin.PluginBase {
|
||||
.substring(indexA, indexB)
|
||||
.replace(
|
||||
/<img data-media-id="(.*?)".*?>/g,
|
||||
`<img src="${this.site}/api/media/$1"/>`,
|
||||
`<img src="${this.site}/api/media/$1">`,
|
||||
);
|
||||
|
||||
return chapterText;
|
||||
@@ -164,8 +164,7 @@ class RNBH implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
resolveUrl = (path: string, isNovel?: boolean) =>
|
||||
this.site + '/ranobe/' + path;
|
||||
resolveUrl = (path: string) => this.site + '/ranobe/' + path;
|
||||
|
||||
filters = {
|
||||
sort: {
|
||||
@@ -1236,10 +1235,6 @@ interface GenresOrEntity {
|
||||
description?: string | null;
|
||||
}
|
||||
|
||||
interface responseChapters {
|
||||
marked_chapters_ids?: null[] | null;
|
||||
volumes?: VolumesEntity[] | null;
|
||||
}
|
||||
interface VolumesEntity {
|
||||
id: number;
|
||||
num: number;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { storage, localStorage } from '@libs/storage';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const statusKey: { [key: number]: string } = {
|
||||
const statusKey: Record<number, string> = {
|
||||
1: NovelStatus.Ongoing,
|
||||
2: NovelStatus.Completed,
|
||||
3: NovelStatus.OnHiatus,
|
||||
@@ -126,7 +126,7 @@ class RLIB implements Plugin.PluginBase {
|
||||
novel.genres = genres.join(', ');
|
||||
}
|
||||
|
||||
const branch_id: { [key: number]: string } = {};
|
||||
const branch_id: Record<number, string> = {};
|
||||
if (data.teams.length) {
|
||||
data.teams.forEach(
|
||||
({ name, details }) => (branch_id[details?.branch_id || '0'] = name),
|
||||
@@ -477,7 +477,7 @@ class RLIB implements Plugin.PluginBase {
|
||||
|
||||
export default new RLIB();
|
||||
|
||||
function jsonToHtml(json: HTML[], html: string = '') {
|
||||
function jsonToHtml(json: HTML[], html = '') {
|
||||
json.forEach(element => {
|
||||
switch (element.type) {
|
||||
case 'hardBreak':
|
||||
@@ -592,12 +592,6 @@ interface User {
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface Rating {
|
||||
average: string;
|
||||
votes: number;
|
||||
votesFormated: string;
|
||||
}
|
||||
|
||||
interface DataClass {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -717,10 +711,3 @@ interface DataChapter {
|
||||
branches_count: number;
|
||||
branches: Branch[];
|
||||
}
|
||||
interface BranchesEntity {
|
||||
id: number;
|
||||
branch_id?: number;
|
||||
created_at: string;
|
||||
teams?: BranchTeam[];
|
||||
user: User;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -97,7 +97,7 @@ class RNRF implements Plugin.PluginBase {
|
||||
|
||||
const jsonRaw = body.match(regex);
|
||||
if (jsonRaw instanceof Array && jsonRaw[1]) {
|
||||
let chapter: string =
|
||||
const chapter: string =
|
||||
JSON.parse(jsonRaw[1])?.props?.pageProps?.chapter?.content?.text || '';
|
||||
|
||||
if (chapter.includes('<img')) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -147,8 +147,7 @@ class ReN implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
resolveUrl = (path: string, isNovel?: boolean) =>
|
||||
this.site + '/novel/' + path;
|
||||
resolveUrl = (path: string) => this.site + '/novel/' + path;
|
||||
|
||||
filters = {
|
||||
sort: {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
//import dayjs from 'dayjs';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
class RV implements Plugin.PluginBase {
|
||||
id = 'RV';
|
||||
@@ -85,7 +85,7 @@ class RV implements Plugin.PluginBase {
|
||||
chapters.push({
|
||||
name: 'Глава ' + chapter.number + ' ' + (chapter.name || ''),
|
||||
path: novelPath + '/' + chapter.id,
|
||||
//releaseTime: dayjs(chapter.created_at).format('LLL'),
|
||||
releaseTime: dayjs(chapter.created_at).format('LLL'),
|
||||
chapterNumber: chapterIndex + 1,
|
||||
});
|
||||
}
|
||||
@@ -176,7 +176,7 @@ interface chapters {
|
||||
}
|
||||
|
||||
function unicodeToUtf8(unicode: string) {
|
||||
return unicode.replace(/\\u([\d\w]{4})/gi, (match, hex) => {
|
||||
return String.fromCharCode(parseInt(hex, 16));
|
||||
});
|
||||
return unicode.replace(/\\u([\d\w]{4})/gi, (match, hex) =>
|
||||
String.fromCharCode(parseInt(hex, 16)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
|
||||
class TopLiba implements Plugin.PluginBase {
|
||||
id = 'TopLiba';
|
||||
name = 'ТопЛиба';
|
||||
site = 'https://topliba.com';
|
||||
version = '1.0.0';
|
||||
icon = 'src/ru/topliba/icon.png';
|
||||
_token = ''; //I think it's permanent?
|
||||
//PgRebp4cULzQKfJBjsEPeECcDQyrVfP5DvcxIxRo
|
||||
|
||||
async fetchNovels(
|
||||
page: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
searchTerm?: string,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const data = new URLSearchParams({
|
||||
order_field: showLatestNovels ? 'date' : filters?.sort?.value || 'rating',
|
||||
p: page,
|
||||
});
|
||||
|
||||
if (searchTerm) data.append('q', searchTerm);
|
||||
|
||||
const body = await fetchApi(this.site + '/?' + data.toString()).then(res =>
|
||||
res.text(),
|
||||
);
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
this._token = body.match(/<meta name="_token" content="(.*?)"/)?.[1];
|
||||
|
||||
const elements = body.match(/<img class="cover" data-original=".*>/g) || [];
|
||||
elements.forEach(element => {
|
||||
const [, path, name] =
|
||||
element.match(/data-original=".*covers\/(.*?)_.*title="(.*?)"/) || [];
|
||||
if (path && name) {
|
||||
novels.push({
|
||||
name,
|
||||
cover: this.site + '/covers/' + path + '.jpg',
|
||||
path,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
popularNovels = this.fetchNovels;
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
page: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const defaultOptions: any = {
|
||||
showLatestNovels: false,
|
||||
filters: {},
|
||||
};
|
||||
return this.fetchNovels(page, defaultOptions, searchTerm);
|
||||
}
|
||||
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(this.resolveUrl(novelPath, true)).then(res =>
|
||||
res.text(),
|
||||
);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('div > h1').text().trim(),
|
||||
cover: this.site + '/covers/' + novelPath + '.jpg',
|
||||
summary: loadedCheerio('.description').text().trim(),
|
||||
author: loadedCheerio('.book-author > a').text().trim(),
|
||||
genres: loadedCheerio('.book-genres > div > a')
|
||||
.map((index, element) => loadedCheerio(element).text())
|
||||
.get()
|
||||
.join(','),
|
||||
};
|
||||
|
||||
const chaptersHTML = await fetchApi(this.resolveUrl(novelPath)).then(res =>
|
||||
res.text(),
|
||||
);
|
||||
|
||||
this._token =
|
||||
chaptersHTML.match(/<meta name="_token" content="(.*?)"/)?.[1] ||
|
||||
body.match(/<meta name="_token" content="(.*?)"/)?.[1] ||
|
||||
this._token;
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
const elements =
|
||||
chaptersHTML.match(
|
||||
/<li class="padding-\d+" data-capter="\d+">([\s\S]*?)</g,
|
||||
) || [];
|
||||
elements.forEach((chapter, chapterIndex) => {
|
||||
const [, padding, capter, name] =
|
||||
chapter.match(
|
||||
/class="padding-(\d+)" data-capter="(\d+)">([\s\S]*?)</,
|
||||
) || [];
|
||||
|
||||
if (padding && capter && name) {
|
||||
const id =
|
||||
padding === '0' ? capter : padding + '-' + (parseInt(capter, 10) - 1);
|
||||
|
||||
chapters.push({
|
||||
name: name.trim(),
|
||||
path: novelPath + '?' + id,
|
||||
releaseTime: null,
|
||||
chapterNumber: chapterIndex + 1,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const [bookID, chapterID] = chapterPath.split('?');
|
||||
if (!this._token) {
|
||||
const chaptersHTML = await fetchApi(this.resolveUrl(bookID)).then(res =>
|
||||
res.text(),
|
||||
);
|
||||
this._token = chaptersHTML.match(
|
||||
/<meta name="_token" content="(.*?)"/,
|
||||
)?.[1];
|
||||
}
|
||||
|
||||
const chapterText = await fetchApi(this.resolveUrl(bookID) + '/chapter', {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
Referer: this.resolveUrl(bookID),
|
||||
Origin: this.site,
|
||||
},
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({
|
||||
chapter: chapterID,
|
||||
_token: this._token,
|
||||
}).toString(),
|
||||
}).then(res => res.text());
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
resolveUrl = (path: string, isNovel?: boolean) =>
|
||||
this.site + (isNovel ? '/books/' + path : '/reader/' + path.split('?')[0]);
|
||||
|
||||
filters = {
|
||||
sort: {
|
||||
label: 'Сортировка:',
|
||||
value: 'rating',
|
||||
options: [
|
||||
{ label: 'По рейтингу', value: 'rating' },
|
||||
{ label: 'По популярности', value: 'num_downloads' },
|
||||
{ label: 'По году выхода', value: 'year' },
|
||||
{ label: 'По дате добавления', value: 'date' },
|
||||
{ label: 'По названию', value: 'title' },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new TopLiba();
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import dayjs from 'dayjs';
|
||||
import qs from 'qs';
|
||||
|
||||
class Zelluloza implements Plugin.PluginBase {
|
||||
id = 'zelluloza';
|
||||
@@ -30,12 +29,12 @@ class Zelluloza implements Plugin.PluginBase {
|
||||
Origin: this.site,
|
||||
},
|
||||
method: 'POST',
|
||||
body: qs.stringify({
|
||||
body: new URLSearchParams({
|
||||
op: 'morebooks',
|
||||
par1: '',
|
||||
par2: `125:0:${genres}:0.${sort}.0.0.0.0.0.0.0.0.0.1.s.1..:${pageNo}`,
|
||||
par4: '',
|
||||
}),
|
||||
}).toString(),
|
||||
}).then(res => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
@@ -109,11 +108,11 @@ class Zelluloza implements Plugin.PluginBase {
|
||||
Origin: this.site,
|
||||
},
|
||||
method: 'POST',
|
||||
body: qs.stringify({
|
||||
body: new URLSearchParams({
|
||||
op: 'getbook',
|
||||
par1: bookID,
|
||||
par2: chapterID,
|
||||
}),
|
||||
}).toString(),
|
||||
}).then(res => res.text());
|
||||
|
||||
const encrypted = body.split('<END>')[0].split('\n');
|
||||
@@ -152,12 +151,12 @@ class Zelluloza implements Plugin.PluginBase {
|
||||
Origin: this.site,
|
||||
},
|
||||
method: 'POST',
|
||||
body: qs.stringify({
|
||||
body: new URLSearchParams({
|
||||
op: 'morebooks',
|
||||
par1: searchTerm,
|
||||
par1: searchTerm || '',
|
||||
par2: '206:0:0:0.0.0.0.0.0.0.10.0.0.0.0.0..0..:' + pageNo,
|
||||
par4: '',
|
||||
}),
|
||||
}).toString(),
|
||||
}).then(res => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
@@ -190,8 +189,7 @@ class Zelluloza implements Plugin.PluginBase {
|
||||
return null;
|
||||
};
|
||||
|
||||
resolveUrl = (path: string, isNovel?: boolean) =>
|
||||
this.site + '/books/' + path;
|
||||
resolveUrl = (path: string) => this.site + '/books/' + path;
|
||||
|
||||
filters = {
|
||||
sort: {
|
||||
@@ -358,7 +356,7 @@ class Zelluloza implements Plugin.PluginBase {
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
const alphabet: { [key: string]: string } = {
|
||||
const alphabet: Record<string, string> = {
|
||||
'~': '0',
|
||||
'H': '1',
|
||||
'^': '2',
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
|
||||
class HasulTL implements Plugin.PluginBase {
|
||||
id = 'HasuTL';
|
||||
@@ -10,24 +9,21 @@ class HasulTL implements Plugin.PluginBase {
|
||||
site = 'https://hasutl.wordpress.com/';
|
||||
version = '1.0.0';
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + 'light-novels-activas/';
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + 'light-novels-activas/';
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('div.wp-block-columns').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).find('.wp-block-button').text();
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(ele)
|
||||
const novelUrl = loadedCheerio(ele)
|
||||
.find('.wp-block-button > a')
|
||||
.attr('href');
|
||||
|
||||
@@ -46,21 +42,21 @@ class HasulTL implements Plugin.PluginBase {
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('.post-header').text(),
|
||||
};
|
||||
novel.cover = loadedCheerio('.featured-media > img').attr('src');
|
||||
|
||||
let novelSummary = loadedCheerio('.post-content').find('p').html()!;
|
||||
const novelSummary = loadedCheerio('.post-content').find('p').html()!;
|
||||
novel.summary = novelSummary;
|
||||
|
||||
let novelChapters: Plugin.ChapterItem[] = [];
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio('.wp-block-media-text__content')
|
||||
.find('a')
|
||||
@@ -69,7 +65,7 @@ class HasulTL implements Plugin.PluginBase {
|
||||
|
||||
const releaseDate = null;
|
||||
|
||||
let chapterUrl = loadedCheerio(ele).attr('href');
|
||||
const chapterUrl = loadedCheerio(ele).attr('href');
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
@@ -89,27 +85,24 @@ class HasulTL implements Plugin.PluginBase {
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = this.site + chapterPath;
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText = loadedCheerio('.post-content').html() || '';
|
||||
const chapterText = loadedCheerio('.post-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?s=${searchTerm}&post_type=wp-manga`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.post-container').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).find('.post-header').text();
|
||||
@@ -120,7 +113,7 @@ class HasulTL implements Plugin.PluginBase {
|
||||
) {
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
|
||||
@@ -11,18 +11,13 @@ class Ligera implements Plugin.PluginBase {
|
||||
filters?: Filters | undefined;
|
||||
version = '1.0.0';
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site;
|
||||
|
||||
const result = await fetch(url);
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.elementor-column').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele)
|
||||
@@ -33,7 +28,7 @@ class Ligera implements Plugin.PluginBase {
|
||||
.find('a > img')
|
||||
.attr('data-lazy-src');
|
||||
|
||||
let novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
if (!novelUrl) return;
|
||||
const novel = {
|
||||
name: novelName,
|
||||
@@ -52,12 +47,12 @@ class Ligera implements Plugin.PluginBase {
|
||||
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1').text(),
|
||||
};
|
||||
@@ -92,7 +87,7 @@ class Ligera implements Plugin.PluginBase {
|
||||
'.elementor-text-editor.elementor-clearfix',
|
||||
).text();
|
||||
|
||||
let novelChapters: Plugin.ChapterItem[] = [];
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio('.elementor-accordion-item').remove();
|
||||
|
||||
@@ -120,30 +115,27 @@ class Ligera implements Plugin.PluginBase {
|
||||
const url = this.site + chapterPath;
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
loadedCheerio('.osny-nightmode.osny-nightmode--left').remove();
|
||||
loadedCheerio('.code-block.code-block-1').remove();
|
||||
loadedCheerio('.adsb30').remove();
|
||||
loadedCheerio('.saboxplugin-wrap').remove();
|
||||
loadedCheerio('.wp-post-navigation').remove();
|
||||
|
||||
let chapterText = loadedCheerio('.entry-content').html() || '';
|
||||
const chapterText = loadedCheerio('.entry-content').html() || '';
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + '?s=' + searchTerm + '&post_type=wp-manga';
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
@@ -14,20 +14,17 @@ class ReinoWuxia implements Plugin.PluginBase {
|
||||
getNovelName(y: string | undefined) {
|
||||
return y?.replace(/-/g, ' ').replace(/(?:^|\s)\S/g, a => a.toUpperCase());
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + 'p/todas-las-novelas.html';
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + 'p/todas-las-novelas.html';
|
||||
|
||||
const result = await fetchApi(url, {
|
||||
method: 'GET',
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.post-body.entry-content')
|
||||
.find('a')
|
||||
@@ -40,7 +37,7 @@ class ReinoWuxia implements Plugin.PluginBase {
|
||||
novelName = this.getNovelName(novelName);
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(ele).attr('href');
|
||||
const novelUrl = loadedCheerio(ele).attr('href');
|
||||
|
||||
if (!novelName || !novelUrl) return;
|
||||
|
||||
@@ -61,9 +58,9 @@ class ReinoWuxia implements Plugin.PluginBase {
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1.post-title').text().trim(),
|
||||
};
|
||||
@@ -74,7 +71,7 @@ class ReinoWuxia implements Plugin.PluginBase {
|
||||
|
||||
loadedCheerio('div > b').each(function () {
|
||||
const detailName = loadedCheerio(this).text();
|
||||
let detail = loadedCheerio(this)[0].nextSibling;
|
||||
const detail = loadedCheerio(this)[0].nextSibling;
|
||||
|
||||
if (detailName && detail) {
|
||||
const text = loadedCheerio(detail).text();
|
||||
@@ -92,7 +89,7 @@ class ReinoWuxia implements Plugin.PluginBase {
|
||||
}
|
||||
});
|
||||
|
||||
let novelChapters: Plugin.ChapterItem[] = [];
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio('div').each((idx, rootEle) => {
|
||||
const detailName = loadedCheerio(rootEle).text();
|
||||
@@ -150,24 +147,21 @@ class ReinoWuxia implements Plugin.PluginBase {
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText = loadedCheerio('.post-body.entry-content').html() || '';
|
||||
const chapterText = loadedCheerio('.post-body.entry-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}search?q=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.date-outer').each((idx, ele) => {
|
||||
let novelName = loadedCheerio(ele)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fetchFile, fetchApi } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
@@ -9,18 +9,13 @@ class Oasis implements Plugin.PluginBase {
|
||||
version = '1.0.0';
|
||||
filters?: Filters | undefined;
|
||||
icon = 'src/es/oasistranslations/icon.png';
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.menu-item-1819')
|
||||
.find('.sub-menu > li')
|
||||
@@ -29,7 +24,7 @@ class Oasis implements Plugin.PluginBase {
|
||||
if (!novelName.match(/Activas|Finalizadas|Dropeadas/)) {
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
@@ -51,9 +46,9 @@ class Oasis implements Plugin.PluginBase {
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1.entry-title')
|
||||
.text()
|
||||
@@ -62,7 +57,7 @@ class Oasis implements Plugin.PluginBase {
|
||||
};
|
||||
novel.cover = loadedCheerio('img[loading="lazy"]').attr('src');
|
||||
|
||||
loadedCheerio('.entry-content > p').each(function (res) {
|
||||
loadedCheerio('.entry-content > p').each(() => {
|
||||
if (loadedCheerio(this).text().includes('Autor')) {
|
||||
const details = loadedCheerio(this)
|
||||
.html()
|
||||
@@ -80,13 +75,12 @@ class Oasis implements Plugin.PluginBase {
|
||||
// let novelSummary = $(this).next().html();
|
||||
novel.summary = '';
|
||||
|
||||
let novelChapters: Plugin.ChapterItem[] = [];
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
// if ($(".entry-content").find("li").length) {
|
||||
loadedCheerio('.entry-content')
|
||||
.find('a')
|
||||
.each((idx, ele) => {
|
||||
let chapterUrl = loadedCheerio(ele).attr('href');
|
||||
const chapterUrl = loadedCheerio(ele).attr('href');
|
||||
|
||||
if (chapterUrl && chapterUrl.includes(this.site)) {
|
||||
const chapterName = loadedCheerio(ele).text();
|
||||
@@ -112,26 +106,21 @@ class Oasis implements Plugin.PluginBase {
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('div#jp-post-flair').remove();
|
||||
|
||||
let chapterText = loadedCheerio('.entry-content').html() || '';
|
||||
const chapterText = loadedCheerio('.entry-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
searchTerm = searchTerm.toLowerCase();
|
||||
|
||||
let url = this.site;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio('.menu-item-1819')
|
||||
@@ -141,7 +130,7 @@ class Oasis implements Plugin.PluginBase {
|
||||
if (!novelName.match(/Activas|Finalizadas|Dropeadas/)) {
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
|
||||
class SkyNovels implements Plugin.PluginBase {
|
||||
id = 'skynovels';
|
||||
name = 'SkyNovels';
|
||||
site = 'https://www.skynovels.net/';
|
||||
apiSite = 'https://api.skynovels.net/api/';
|
||||
version = '1.0.0';
|
||||
icon = 'src/es/skynovels/icon.png';
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = 'https://api.skynovels.net/api/novels?&q';
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.apiSite + 'novels?&q';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = (await result.json()) as response;
|
||||
@@ -21,48 +18,39 @@ class SkyNovels implements Plugin.PluginBase {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
body.novels?.forEach(res => {
|
||||
const novelName = res.nvl_title;
|
||||
const novelCover =
|
||||
'https://api.skynovels.net/api/get-image/' +
|
||||
res.image +
|
||||
'/novels/false';
|
||||
const name = res.nvl_title;
|
||||
const cover = this.apiSite + 'get-image/' + res.image + '/novels/false';
|
||||
const path = 'novelas/' + res.id + '/' + res.nvl_name + '/';
|
||||
|
||||
const novel = { name: novelName, path, cover: novelCover };
|
||||
|
||||
novels.push(novel);
|
||||
novels.push({ name, cover, path });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const novelId = novelPath.split('/')[1];
|
||||
const url =
|
||||
'https://api.skynovels.net/api/novel/' + novelId + '/reading?&q';
|
||||
const url = this.apiSite + 'novel/' + novelId + '/reading?&q';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = (await result.json()) as responseBook;
|
||||
|
||||
const item = body?.novel?.[0];
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: item?.nvl_title || 'Untitled',
|
||||
};
|
||||
|
||||
novel.cover =
|
||||
'https://api.skynovels.net/api/get-image/' +
|
||||
item?.image +
|
||||
'/novels/false';
|
||||
novel.cover = this.apiSite + 'get-image/' + item?.image + '/novels/false';
|
||||
|
||||
let genres: string[] = [];
|
||||
const genres: string[] = [];
|
||||
item?.genres?.forEach(genre => genres.push(genre.genre_name));
|
||||
novel.genres = genres.join(',');
|
||||
novel.author = item?.nvl_writer;
|
||||
novel.summary = item?.nvl_content;
|
||||
novel.status = item?.nvl_status;
|
||||
|
||||
let novelChapters: Plugin.ChapterItem[] = [];
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
item?.volumes?.forEach(volume => {
|
||||
volume?.chapters?.forEach(chapter => {
|
||||
@@ -70,13 +58,11 @@ class SkyNovels implements Plugin.PluginBase {
|
||||
const releaseDate = new Date(chapter.createdAt).toDateString();
|
||||
const chapterPath = novelPath + chapter.id + '/' + chapter.chp_name;
|
||||
|
||||
const chap = {
|
||||
novelChapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
path: chapterPath,
|
||||
};
|
||||
|
||||
novelChapters.push(chap);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -85,45 +71,38 @@ class SkyNovels implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
let chapterId: string = chapterPath.split('/')[3];
|
||||
const url = `https://api.skynovels.net/api/novel-chapter/${chapterId}`;
|
||||
const chapterId: string = chapterPath.split('/')[3];
|
||||
const url = `${this.apiSite}novel-chapter/${chapterId}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = (await result.json()) as responseChapter;
|
||||
|
||||
const item = body?.chapter?.[0];
|
||||
|
||||
let chapterText = item?.chp_content || '404';
|
||||
const chapterText = item?.chp_content || '404';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
searchTerm = searchTerm.toLowerCase();
|
||||
const url = 'https://api.skynovels.net/api/novels?&q';
|
||||
const url = this.apiSite + 'novels?&q';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = (await result.json()) as response;
|
||||
|
||||
let results = body?.novels?.filter(novel =>
|
||||
const results = body?.novels?.filter(novel =>
|
||||
novel.nvl_title.toLowerCase().includes(searchTerm),
|
||||
);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
results?.forEach(res => {
|
||||
const novelName = res.nvl_title;
|
||||
const novelCover =
|
||||
'https://api.skynovels.net/api/get-image/' +
|
||||
res.image +
|
||||
'/novels/false';
|
||||
const name = res.nvl_title;
|
||||
const cover = this.apiSite + 'get-image/' + res.image + '/novels/false';
|
||||
const path = 'novelas/' + res.id + '/' + res.nvl_name + '/';
|
||||
|
||||
const novel = { name: novelName, path, cover: novelCover };
|
||||
|
||||
novels.push(novel);
|
||||
novels.push({ name, cover, path });
|
||||
});
|
||||
|
||||
return novels;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
@@ -73,7 +73,7 @@ class TuNovelaLigera implements Plugin.PagePlugin {
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
let lastPage = 1;
|
||||
loadedCheerio('ul.lcp_paginator > li > a').each(function () {
|
||||
const page = Number(this.attribs['title']);
|
||||
@@ -88,7 +88,7 @@ class TuNovelaLigera implements Plugin.PagePlugin {
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
let novelCover = loadedCheerio('.summary_image > a > img');
|
||||
const novelCover = loadedCheerio('.summary_image > a > img');
|
||||
|
||||
novel.cover =
|
||||
novelCover.attr('data-src') ||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
@@ -11,18 +11,13 @@ class Yuuki implements Plugin.PluginBase {
|
||||
filters?: Filters | undefined;
|
||||
version = '1.0.0';
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.quadmenu-navbar-collapse ul li:nth-child(2)')
|
||||
.find('li')
|
||||
@@ -32,7 +27,7 @@ class Yuuki implements Plugin.PluginBase {
|
||||
.replace(/[\s\n]+/g, ' ');
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
if (!novelUrl) return;
|
||||
const novel = {
|
||||
name: novelName,
|
||||
@@ -51,9 +46,9 @@ class Yuuki implements Plugin.PluginBase {
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1.entry-title')
|
||||
.text()
|
||||
@@ -83,13 +78,13 @@ class Yuuki implements Plugin.PluginBase {
|
||||
}
|
||||
});
|
||||
|
||||
let novelChapters: Plugin.ChapterItem[] = [];
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
if (loadedCheerio('.entry-content').find('li').length) {
|
||||
loadedCheerio('.entry-content')
|
||||
.find('li')
|
||||
.each((idx, ele) => {
|
||||
let chapterUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
const chapterUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (chapterUrl && chapterUrl.includes(this.site)) {
|
||||
const chapterName = loadedCheerio(ele).text();
|
||||
@@ -108,7 +103,7 @@ class Yuuki implements Plugin.PluginBase {
|
||||
loadedCheerio('.entry-content')
|
||||
.find('p')
|
||||
.each((idx, ele) => {
|
||||
let chapterUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
const chapterUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (chapterUrl && chapterUrl.includes(this.site)) {
|
||||
const chapterName = loadedCheerio(ele).text();
|
||||
@@ -135,23 +130,18 @@ class Yuuki implements Plugin.PluginBase {
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
let chapterText = loadedCheerio('.entry-content').html() || '';
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText = loadedCheerio('.entry-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
searchTerm = searchTerm.toLowerCase();
|
||||
|
||||
let url = this.site;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
@@ -161,7 +151,7 @@ class Yuuki implements Plugin.PluginBase {
|
||||
const novelName = loadedCheerio(ele).text();
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
|
||||
class EpikNovel implements Plugin.PluginBase {
|
||||
id = 'epiknovel';
|
||||
@@ -9,18 +8,15 @@ class EpikNovel implements Plugin.PluginBase {
|
||||
icon = 'src/tr/epiknovel/icon.png';
|
||||
site = 'https://www.epiknovel.com/';
|
||||
version = '1.0.0';
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + 'seri-listesi?Sayfa=' + pageNo;
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + 'seri-listesi?Sayfa=' + pageNo;
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('div.col-lg-12.col-md-12').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).find('h3').text();
|
||||
@@ -46,12 +42,12 @@ class EpikNovel implements Plugin.PluginBase {
|
||||
const url = this.site + novelPath;
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1#tables').text().trim(),
|
||||
};
|
||||
@@ -75,7 +71,7 @@ class EpikNovel implements Plugin.PluginBase {
|
||||
.replace(/Publisher:|\s/g, '')
|
||||
.trim();
|
||||
|
||||
let novelChapters: Plugin.ChapterItem[] = [];
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio('table').find('tr').first().remove();
|
||||
|
||||
@@ -113,14 +109,14 @@ class EpikNovel implements Plugin.PluginBase {
|
||||
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText = '';
|
||||
|
||||
if (result.url === 'https://www.epiknovel.com/login') {
|
||||
if (result.url === this.site + 'login') {
|
||||
chapterText = 'Premium Chapter';
|
||||
} else {
|
||||
chapterText = loadedCheerio('div#icerik').html() || '';
|
||||
@@ -134,12 +130,12 @@ class EpikNovel implements Plugin.PluginBase {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + 'seri-listesi?q=' + searchTerm + '&Sayfa=' + pageNo;
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('div.col-lg-12.col-md-12').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).find('h3').text();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
|
||||
@@ -38,7 +38,7 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
|
||||
loadedCheerio('article.bs').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.ntitle').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
const novelUrl = loadedCheerio(this).find('a').attr('href');
|
||||
@@ -63,7 +63,7 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
const result = await fetchApi(url, { headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url,
|
||||
@@ -99,7 +99,7 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
.end()
|
||||
.text();
|
||||
|
||||
let chapter: Plugin.ChapterItem[] = [];
|
||||
const chapter: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio('.eplister')
|
||||
.find('li')
|
||||
@@ -133,7 +133,7 @@ class LSHNovel implements Plugin.PluginBase {
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText = loadedCheerio('.epcontent').html() || '';
|
||||
const chapterText = loadedCheerio('.epcontent').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -7,18 +7,17 @@ class Smakolykytl implements Plugin.PluginBase {
|
||||
id = 'smakolykytl';
|
||||
name = 'Смаколики';
|
||||
site = 'https://smakolykytl.site/';
|
||||
version = '1.0.0';
|
||||
apiSite = 'https://api.smakolykytl.site/api/user';
|
||||
version = '1.0.1';
|
||||
icon = 'src/uk/smakolykytl/icon.png';
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions,
|
||||
{ showLatestNovels }: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = showLatestNovels
|
||||
? 'https://api.smakolykytl.site/api/user/updates'
|
||||
: 'https://api.smakolykytl.site/api/user/projects';
|
||||
const sort = showLatestNovels ? '/updates' : '/projects';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const result = await fetchApi(this.apiSite + sort);
|
||||
const json = (await result.json()) as response;
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
@@ -35,9 +34,7 @@ class Smakolykytl implements Plugin.PluginBase {
|
||||
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const id = novelPath.split('/').pop();
|
||||
const result = await fetchApi(
|
||||
'https://api.smakolykytl.site/api/user/projects/' + id,
|
||||
);
|
||||
const result = await fetchApi(this.apiSite + '/projects/' + id);
|
||||
const book = (await result.json()) as response;
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
@@ -60,9 +57,7 @@ class Smakolykytl implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
const res = await fetchApi(
|
||||
'https://api.smakolykytl.site/api/user/projects/' + id + '/books',
|
||||
);
|
||||
const res = await fetchApi(this.apiSite + '/projects/' + id + '/books');
|
||||
const data = (await res.json()) as response;
|
||||
data?.books?.forEach(volume =>
|
||||
volume?.chapters?.forEach(chapter =>
|
||||
@@ -81,9 +76,7 @@ class Smakolykytl implements Plugin.PluginBase {
|
||||
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const id = chapterPath.split('/').pop();
|
||||
const result = await fetchApi(
|
||||
'https://api.smakolykytl.site/api/user/chapters/' + id,
|
||||
);
|
||||
const result = await fetchApi(this.apiSite + '/chapters/' + id);
|
||||
const json = (await result.json()) as response;
|
||||
const chapterRaw: HTML[] = JSON.parse(json?.chapter?.content || '[]');
|
||||
|
||||
@@ -92,9 +85,7 @@ class Smakolykytl implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi(
|
||||
'https://api.smakolykytl.site/api/user/projects',
|
||||
);
|
||||
const result = await fetchApi(this.apiSite + '/projects');
|
||||
const json = (await result.json()) as response;
|
||||
const searchTitle = searchTerm.toLowerCase();
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
@@ -117,7 +108,7 @@ class Smakolykytl implements Plugin.PluginBase {
|
||||
|
||||
export default new Smakolykytl();
|
||||
|
||||
function jsonToHtml(json: HTML[], html: string = '') {
|
||||
function jsonToHtml(json: HTML[], html = '') {
|
||||
json.forEach(element => {
|
||||
switch (element.type) {
|
||||
case 'hardBreak':
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Parser } from 'htmlparser2';
|
||||
import { HTMLParser2Util, Plugin } from '@typings/plugin';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
@@ -20,7 +21,7 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
site = 'https://ln.hako.vn';
|
||||
version = '1.1.0';
|
||||
parseNovels(url: string) {
|
||||
return fetch(url)
|
||||
return fetchApi(url)
|
||||
.then(res => res.text())
|
||||
.then(html => {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
@@ -57,10 +58,7 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
}
|
||||
popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = this.site + '/danh-sach';
|
||||
if (filters) {
|
||||
@@ -96,7 +94,7 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
const getNameHandler: HTMLParser2Util.Handler = {
|
||||
isDone: false,
|
||||
isStarted: false,
|
||||
onopentag(name, attribs) {
|
||||
onopentag(name) {
|
||||
if (name === 'a') {
|
||||
this.isStarted = true;
|
||||
}
|
||||
@@ -104,7 +102,7 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
ontext(data) {
|
||||
novel.name += data;
|
||||
},
|
||||
onclosetag(name) {
|
||||
onclosetag() {
|
||||
if (this.isStarted) {
|
||||
this.isDone = true;
|
||||
}
|
||||
@@ -122,7 +120,7 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
novel.summary += data;
|
||||
}
|
||||
},
|
||||
onclosetag(name) {
|
||||
onclosetag() {
|
||||
this.newLine = true;
|
||||
},
|
||||
};
|
||||
@@ -341,12 +339,13 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
if (this.handlers.GetVolumes?.isDone) {
|
||||
this.action = ParseNovelAction.Unknown;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
};
|
||||
return fetch(this.site + novelPath)
|
||||
return fetchApi(this.site + novelPath)
|
||||
.then(res => res.text())
|
||||
.then(html => {
|
||||
const parser = new Parser({
|
||||
@@ -400,7 +399,7 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
});
|
||||
}
|
||||
parseChapter(chapterPath: string): Promise<string> {
|
||||
return fetch(this.site + chapterPath)
|
||||
return fetchApi(this.site + chapterPath)
|
||||
.then(res => res.text())
|
||||
.then(
|
||||
html =>
|
||||
@@ -419,7 +418,7 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
}
|
||||
imageRequestInit: Plugin.ImageRequestInit = {
|
||||
headers: {
|
||||
Referer: 'https://ln.hako.vn',
|
||||
Referer: this.site,
|
||||
},
|
||||
};
|
||||
filters = {
|
||||
|
||||
@@ -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 { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
@@ -67,7 +67,7 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
link += '?page=' + pageNo;
|
||||
}
|
||||
|
||||
const body = await fetch(link).then(r => r.text());
|
||||
const body = await fetchApi(link).then(r => r.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio, selector);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
if (chapterId) {
|
||||
url = url.replace(chapterId + '-', '') + '-' + chapterId;
|
||||
}
|
||||
let num = url.match(/chuong-(\d+)/)?.[1];
|
||||
const num = url.match(/chuong-(\d+)/)?.[1];
|
||||
chapters.push({
|
||||
path: url.replace(this.site, ''),
|
||||
name: loadedCheerio(ele).text().trim(),
|
||||
@@ -104,7 +104,7 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
const chapterId = firstChapterUrl.match(/-(\d+)$/)?.[1];
|
||||
if (!chapterId) throw new Error('Không tìm thấy chương');
|
||||
const url = this.site + '/truyen/get-chap-selector?chap=' + chapterId;
|
||||
const data: ChapterSelect = await fetch(url).then(r => r.json());
|
||||
const data: ChapterSelect = await fetchApi(url).then(r => r.json());
|
||||
const volumeList: VolumeList = {
|
||||
chapters: this.parseChapters(parseHTML(data.chap_selector)),
|
||||
};
|
||||
@@ -119,10 +119,10 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
novelPath: string,
|
||||
): Promise<Plugin.SourceNovel & { totalPages: number }> {
|
||||
const url = this.site + novelPath;
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel & { totalPages: number } = {
|
||||
name: loadedCheerio('.post-title > h1').text().trim(),
|
||||
@@ -157,13 +157,20 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
novel.artist = loadedCheerio(detail).text().trim();
|
||||
break;
|
||||
case 'Trạng thái':
|
||||
const status = detail.trim();
|
||||
if (status === 'Full') novel.status = NovelStatus.Completed;
|
||||
else if (status === 'Tạm ngưng') novel.status = NovelStatus.OnHiatus;
|
||||
else if (status === 'Đang tiến hành')
|
||||
novel.status = NovelStatus.Ongoing;
|
||||
else novel.status = NovelStatus.Unknown;
|
||||
break;
|
||||
switch (detail.trim()) {
|
||||
case 'Full':
|
||||
novel.status = NovelStatus.Completed;
|
||||
break;
|
||||
case 'Tạm ngưng':
|
||||
novel.status = NovelStatus.OnHiatus;
|
||||
break;
|
||||
case 'Đang tiến hành':
|
||||
novel.status = NovelStatus.Ongoing;
|
||||
break;
|
||||
default:
|
||||
novel.status = NovelStatus.Unknown;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -187,9 +194,9 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
}
|
||||
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
|
||||
const url = this.site + novelPath;
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const firstChapLink = loadedCheerio('#init-links > a').first().attr('href');
|
||||
if (!firstChapLink) throw new Error('Không tìm thấy truyện');
|
||||
await this.sleep(1000);
|
||||
@@ -202,7 +209,7 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
const query = `dataEpisodes=${volume.value}&datastory=${volume.story}&dataNavigation=${encodeURIComponent(volume.navigation)}`;
|
||||
const chaptersUrl = `${this.site}/truyen/getreadingchapAction?${query}`;
|
||||
await this.sleep(1000);
|
||||
const res: { err: number; html: string } = await fetch(chaptersUrl).then(
|
||||
const res: { err: number; html: string } = await fetchApi(chaptersUrl).then(
|
||||
r => r.json(),
|
||||
);
|
||||
if (res.err) throw new Error(res.html);
|
||||
@@ -211,11 +218,11 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
};
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetch(this.site + chapterPath);
|
||||
const result = await fetchApi(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
let chapterText = loadedCheerio('.reading-content').html() || '';
|
||||
const chapterText = loadedCheerio('.reading-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
@@ -224,7 +231,7 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?key=${searchTerm}&page=${pageNo}`;
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
@@ -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, {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { fetchFile } from '@libs/fetch';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
@@ -26,12 +25,9 @@ class Nettruyen implements Plugin.PagePlugin {
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}/xem-nhieu/trang-${pageNo}.html`;
|
||||
const body = await fetch(url).then(r => r.text());
|
||||
const body = await fetchApi(url).then(r => r.text());
|
||||
return this.parseNovels(parseHTML(body));
|
||||
}
|
||||
parseChapters(loadedCheerio: CheerioAPI) {
|
||||
@@ -52,7 +48,7 @@ class Nettruyen 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());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const novel: Plugin.SourceNovel & { totalPages: number } = {
|
||||
path: novelPath,
|
||||
@@ -71,7 +67,7 @@ class Nettruyen implements Plugin.PagePlugin {
|
||||
.text()
|
||||
.replace(/Tác giả\s+\n?:/, '');
|
||||
break;
|
||||
case 'Trạng thái':
|
||||
case 'Trạng thái': {
|
||||
const text = loadedCheerio(ele).text();
|
||||
if (text.includes('Đang ra')) {
|
||||
novel.status = NovelStatus.Ongoing;
|
||||
@@ -81,6 +77,7 @@ class Nettruyen implements Plugin.PagePlugin {
|
||||
novel.status = NovelStatus.Unknown;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'Thể loại':
|
||||
novel.genres = loadedCheerio('a > span')
|
||||
.toArray()
|
||||
@@ -101,7 +98,7 @@ class Nettruyen implements Plugin.PagePlugin {
|
||||
const id = novelPath.match(/-(\d+)\//)?.[1];
|
||||
if (!id) throw new Error('Cant parse page');
|
||||
const url = `${this.site}/ajax.chuong.php?id=${id}&page=${page}&url=${novelPath.replace(/\//g, '')}&loai=truyendich`;
|
||||
const body = await fetch(url).then(r => r.text());
|
||||
const body = await fetchApi(url).then(r => r.text());
|
||||
const chapters = this.parseChapters(parseHTML(body));
|
||||
return {
|
||||
chapters,
|
||||
@@ -109,14 +106,11 @@ class Nettruyen implements Plugin.PagePlugin {
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = this.site + chapterPath;
|
||||
const body = await fetch(url).then(r => r.text());
|
||||
const body = await fetchApi(url).then(r => r.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return loadedCheerio('#noidungchap').html() || '';
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(): Promise<Plugin.NovelItem[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
|
||||
class TruyenFull implements Plugin.PagePlugin {
|
||||
@@ -55,12 +54,9 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
});
|
||||
return chapters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}/danh-sach/truyen-hot?page=${pageNo}`;
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
@@ -71,10 +67,10 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
): Promise<Plugin.SourceNovel & { totalPages: number }> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
let lastPage = 1;
|
||||
const regex = new RegExp(`${novelPath}\\?page=\\d+`, 'g');
|
||||
body.match(regex)?.forEach(v => {
|
||||
@@ -119,7 +115,7 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
}
|
||||
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
|
||||
const url = `${this.site}${novelPath}?page=${page}`;
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const chapters = this.parseChapters(body);
|
||||
@@ -128,12 +124,12 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
};
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetch(this.site + chapterPath);
|
||||
const result = await fetchApi(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText =
|
||||
const chapterText =
|
||||
(loadedCheerio('.chapter-title').html() || '') +
|
||||
(loadedCheerio('#chapter-c').html() || '');
|
||||
|
||||
@@ -145,7 +141,7 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const searchUrl = `${this.site}/tim-kiem?tukhoa=${searchTerm}&page=${pageNo}`;
|
||||
|
||||
const result = await fetch(searchUrl);
|
||||
const result = await fetchApi(searchUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchFile } from '@libs/fetch';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
|
||||
class TruyenFull implements Plugin.PagePlugin {
|
||||
@@ -45,13 +44,10 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
};
|
||||
});
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions<Filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async popularNovels(pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}/danh-sach/truyen-hot/trang-${pageNo}/`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -63,10 +59,10 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
): Promise<Plugin.SourceNovel & { totalPages: number }> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
let lastPage = 1;
|
||||
loadedCheerio('ul.pagination.pagination-sm > li > a').each(function () {
|
||||
const page = Number(this.attribs['href'].match(/\/trang-(\d+)\//)?.[1]);
|
||||
@@ -109,7 +105,7 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
}
|
||||
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
|
||||
const url = `${this.site}${novelPath}trang-${page}/#list-chapter`;
|
||||
const result = await fetch(url);
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -119,12 +115,12 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
};
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetch(this.site + chapterPath);
|
||||
const result = await fetchApi(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText =
|
||||
const chapterText =
|
||||
(loadedCheerio('.chapter-title').html() || '') +
|
||||
(loadedCheerio('#chapter-c').html() || '');
|
||||
|
||||
@@ -136,7 +132,7 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const searchUrl = `${this.site}/tim-kiem?tukhoa=${searchTerm}&page=${pageNo}`;
|
||||
|
||||
const result = await fetch(searchUrl);
|
||||
const result = await fetchApi(searchUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
Reference in New Issue
Block a user