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,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 = {
|
||||
|
||||
Reference in New Issue
Block a user