refactor: Overhaul Plugin Architecture & Playground UI (#1846)
* refactor: Move Plugins Out and Consolidate with Multisrc * feat: Overhaul Playground UI * feat: Add Filters to New UI * feat: Persist Selected Plugin * feat: Add Direct Parse Novel/Chapter Options and Feedback Toasts [skip ci] * feat: UX Improvements * chore: Update Plugin Path in Publish Workflow * fix: Add Backward Compatibility * chore: Update Plugin Publishing Script
This commit is contained in:
committed by
GitHub
parent
252beff0bf
commit
20c2b75b01
@@ -0,0 +1,134 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@/types/plugin';
|
||||
|
||||
class HasulTL implements Plugin.PluginBase {
|
||||
id = 'HasuTL';
|
||||
name = 'Hasu Translations';
|
||||
icon = 'src/es/hasutl/icon.jpg';
|
||||
site = 'https://hasutl.wordpress.com/';
|
||||
version = '1.0.0';
|
||||
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + 'light-novels-activas/';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
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');
|
||||
|
||||
const novelUrl = loadedCheerio(ele)
|
||||
.find('.wp-block-button > a')
|
||||
.attr('href');
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('.post-header').text(),
|
||||
};
|
||||
novel.cover = loadedCheerio('.featured-media > img').attr('src');
|
||||
|
||||
const novelSummary = loadedCheerio('.post-content').find('p').html()!;
|
||||
novel.summary = novelSummary;
|
||||
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio('.wp-block-media-text__content')
|
||||
.find('a')
|
||||
.each((idx, ele) => {
|
||||
const chapterName = loadedCheerio(ele).text().trim();
|
||||
|
||||
const releaseDate = null;
|
||||
|
||||
const chapterUrl = loadedCheerio(ele).attr('href');
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
path: chapterUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = this.site + chapterPath;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio('.post-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}?s=${searchTerm}&post_type=wp-manga`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.post-container').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).find('.post-header').text();
|
||||
if (
|
||||
!novelName.includes('Cap') &&
|
||||
!novelName.includes('Vol') &&
|
||||
!novelName.includes('Light Novels')
|
||||
) {
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
}
|
||||
|
||||
export default new HasulTL();
|
||||
@@ -0,0 +1,173 @@
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@/types/plugin';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
|
||||
class Ligera implements Plugin.PluginBase {
|
||||
id = 'novelasligera';
|
||||
name = 'Novelas Ligera';
|
||||
icon = 'src/es/novelasligera/icon.png';
|
||||
site = 'https://novelasligera.com/';
|
||||
filters?: Filters | undefined;
|
||||
version = '1.0.0';
|
||||
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.elementor-column').each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele)
|
||||
.find('.widget-image-caption.wp-caption-text')
|
||||
.text();
|
||||
if (novelName) {
|
||||
const novelCover = loadedCheerio(ele)
|
||||
.find('a > img')
|
||||
.attr('data-lazy-src');
|
||||
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
if (!novelUrl) return;
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1').text(),
|
||||
};
|
||||
|
||||
novel.cover = loadedCheerio('.elementor-widget-container')
|
||||
.find('img')
|
||||
.attr('data-lazy-src');
|
||||
|
||||
loadedCheerio('.elementor-row')
|
||||
.find('p')
|
||||
.each(function () {
|
||||
if (loadedCheerio(this).text().includes('Autor:')) {
|
||||
novel.author = loadedCheerio(this)
|
||||
.text()
|
||||
.replace('Autor:', '')
|
||||
.trim();
|
||||
}
|
||||
if (loadedCheerio(this).text().includes('Estado:')) {
|
||||
novel.status = loadedCheerio(this)
|
||||
.text()
|
||||
.replace('Estado: ', '')
|
||||
.trim();
|
||||
}
|
||||
|
||||
if (loadedCheerio(this).text().includes('Género:')) {
|
||||
loadedCheerio(this).find('span').remove();
|
||||
novel.genres = loadedCheerio(this).text().replace(/,\s/g, ',');
|
||||
}
|
||||
});
|
||||
|
||||
novel.summary = loadedCheerio(
|
||||
'.elementor-text-editor.elementor-clearfix',
|
||||
).text();
|
||||
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio('.elementor-accordion-item').remove();
|
||||
|
||||
loadedCheerio('.elementor-tab-content')
|
||||
.find('li')
|
||||
.each((idx, ele) => {
|
||||
const chapterName = loadedCheerio(ele).text();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
if (!chapterUrl) return;
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
path: chapterUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = this.site + chapterPath;
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
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();
|
||||
|
||||
const chapterText = loadedCheerio('.entry-content').html() || '';
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + '?s=' + searchTerm + '&post_type=wp-manga';
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.inside-article').each((idx, ele) => {
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
let novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
let novelName;
|
||||
|
||||
if (novelUrl) {
|
||||
novelName = novelUrl.replace(/-/g, ' ').replace(/^./, function (x) {
|
||||
return x.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
novelUrl += '/';
|
||||
|
||||
if (!novelName || !novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
novels = [{ ...novels[1] }];
|
||||
|
||||
return novels;
|
||||
}
|
||||
}
|
||||
|
||||
export default new Ligera();
|
||||
@@ -0,0 +1,198 @@
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@/types/plugin';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
|
||||
class ReinoWuxia implements Plugin.PluginBase {
|
||||
id = 'reinowuxia';
|
||||
name = 'ReinoWuxia';
|
||||
icon = 'src/es/reinowuxia/icon.png';
|
||||
filters?: Filters | undefined;
|
||||
version = '1.0.0';
|
||||
site = 'http://www.reinowuxia.com/';
|
||||
getNovelName(y: string | undefined) {
|
||||
return y?.replace(/-/g, ' ').replace(/(?:^|\s)\S/g, a => a.toUpperCase());
|
||||
}
|
||||
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();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.post-body.entry-content')
|
||||
.find('a')
|
||||
.each((idx, ele) => {
|
||||
let novelName = loadedCheerio(ele)
|
||||
.attr('href')
|
||||
?.split('/')
|
||||
.pop()
|
||||
?.replace('.html', '');
|
||||
novelName = this.getNovelName(novelName);
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
const novelUrl = loadedCheerio(ele).attr('href');
|
||||
|
||||
if (!novelName || !novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1.post-title').text().trim(),
|
||||
};
|
||||
|
||||
novel.cover = loadedCheerio('div.separator').find('a').attr('href');
|
||||
|
||||
novel.status = '';
|
||||
|
||||
loadedCheerio('div > b').each(function () {
|
||||
const detailName = loadedCheerio(this).text();
|
||||
const detail = loadedCheerio(this)[0].nextSibling;
|
||||
|
||||
if (detailName && detail) {
|
||||
const text = loadedCheerio(detail).text();
|
||||
|
||||
if (detailName.includes('Autor')) {
|
||||
novel.author = text.replace('Autor:', '');
|
||||
}
|
||||
|
||||
if (detailName.includes('Estatus')) {
|
||||
novel.status = text.replace('Estatus: ', '');
|
||||
}
|
||||
if (detailName.includes('Géneros:')) {
|
||||
novel.genres = text.replace('Géneros: ', '').replace(/,\s/g, ',');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio('div').each((idx, rootEle) => {
|
||||
const detailName = loadedCheerio(rootEle).text();
|
||||
if (detailName.includes('Sinopsis')) {
|
||||
novel.summary =
|
||||
loadedCheerio(rootEle).next().text() !== ''
|
||||
? loadedCheerio(rootEle)
|
||||
.next()
|
||||
.text()
|
||||
.replace('Sinopsis', '')
|
||||
.trim()
|
||||
: loadedCheerio(rootEle)
|
||||
.next()
|
||||
.next()
|
||||
.text()
|
||||
.replace('Sinopsis', '')
|
||||
.trim();
|
||||
}
|
||||
|
||||
if (detailName.includes('Lista de Capítulos')) {
|
||||
loadedCheerio(rootEle)
|
||||
.find('a')
|
||||
.each((idx, ele) => {
|
||||
const chapterName = loadedCheerio(ele).text();
|
||||
const chapterPath = loadedCheerio(ele)
|
||||
.attr('href')
|
||||
?.replace(this.site, '');
|
||||
const releaseDate = null;
|
||||
|
||||
if (
|
||||
chapterName &&
|
||||
chapterPath &&
|
||||
chapterPath !== '/' &&
|
||||
!novelChapters.some(chap => chap.name === chapterName)
|
||||
) {
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
path: chapterPath,
|
||||
};
|
||||
|
||||
novelChapters.push(chapter);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = this.site + chapterPath;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio('.post-body.entry-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}search?q=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.date-outer').each((idx, ele) => {
|
||||
let novelName = loadedCheerio(ele)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
?.split('/')
|
||||
.pop()
|
||||
?.replace(/-capitulo(.*?).html/, '');
|
||||
|
||||
const novelUrl = novelName + '.html/';
|
||||
|
||||
novelName = this.getNovelName(novelName);
|
||||
|
||||
const exists = novels.some(novel => novel.name === novelName);
|
||||
|
||||
if (!exists) {
|
||||
const novelCover = defaultCover;
|
||||
|
||||
if (!novelUrl || !novelName) return;
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
}
|
||||
|
||||
export default new ReinoWuxia();
|
||||
@@ -0,0 +1,155 @@
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@/types/plugin';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
class Oasis implements Plugin.PluginBase {
|
||||
id = 'oasistranslations';
|
||||
name = 'Oasis Translations';
|
||||
site = 'https://oasistranslations.wordpress.com/';
|
||||
version = '1.0.0';
|
||||
filters?: Filters | undefined;
|
||||
icon = 'src/es/oasistranslations/icon.png';
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.menu-item-1819')
|
||||
.find('.sub-menu > li')
|
||||
.each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).text();
|
||||
if (!novelName.match(/Activas|Finalizadas|Dropeadas/)) {
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1.entry-title')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim(),
|
||||
};
|
||||
novel.cover = loadedCheerio('img[loading="lazy"]').attr('src');
|
||||
|
||||
loadedCheerio('.entry-content > p').each(() => {
|
||||
if (loadedCheerio(this).text().includes('Autor')) {
|
||||
const details = loadedCheerio(this)
|
||||
.html()
|
||||
?.match(/<\/strong>(.|\n)*?<br>/g)
|
||||
?.map(detail => detail.replace(/<strong>|<\/strong>|<br>|:\s/g, ''));
|
||||
|
||||
novel.genres = '';
|
||||
if (details) {
|
||||
novel.author = details[2];
|
||||
novel.genres = details[4].replace(/\s| /g, '');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// let novelSummary = $(this).next().html();
|
||||
novel.summary = '';
|
||||
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio('.entry-content')
|
||||
.find('a')
|
||||
.each((idx, ele) => {
|
||||
const chapterUrl = loadedCheerio(ele).attr('href');
|
||||
|
||||
if (chapterUrl && chapterUrl.includes(this.site)) {
|
||||
const chapterName = loadedCheerio(ele).text();
|
||||
const releaseDate = null;
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
path: chapterUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novelChapters.push(chapter);
|
||||
}
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = this.site + chapterPath;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('div#jp-post-flair').remove();
|
||||
|
||||
const chapterText = loadedCheerio('.entry-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
searchTerm = searchTerm.toLowerCase();
|
||||
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio('.menu-item-1819')
|
||||
.find('.sub-menu > li')
|
||||
.each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).text();
|
||||
if (!novelName.match(/Activas|Finalizadas|Dropeadas/)) {
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
novels = novels.filter(novel =>
|
||||
novel.name.toLowerCase().includes(searchTerm),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
}
|
||||
|
||||
export default new Oasis();
|
||||
@@ -0,0 +1,245 @@
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@/types/plugin';
|
||||
|
||||
class SkyNovels implements Plugin.PluginBase {
|
||||
id = 'skynovels';
|
||||
name = 'SkyNovels';
|
||||
site = 'https://www.skynovels.net/';
|
||||
apiSite = 'https://api.skynovels.net/api/';
|
||||
version = '1.0.1';
|
||||
icon = 'src/es/skynovels/icon.png';
|
||||
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.apiSite + 'novels?&q';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = (await result.json()) as response;
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
body.novels?.forEach(res => {
|
||||
const name = res.nvl_title;
|
||||
const cover = this.apiSite + 'get-image/' + res.image + '/novels/false';
|
||||
const path = 'novelas/' + res.id + '/' + res.nvl_name + '/';
|
||||
|
||||
novels.push({ name, cover, path });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const novelId = novelPath.split('/')[1];
|
||||
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];
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: item?.nvl_title || 'Untitled',
|
||||
};
|
||||
|
||||
novel.cover = this.apiSite + 'get-image/' + item?.image + '/novels/false';
|
||||
|
||||
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;
|
||||
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
item?.volumes?.forEach(volume => {
|
||||
volume?.chapters?.forEach(chapter => {
|
||||
const chapterName = chapter.chp_index_title;
|
||||
const releaseDate = new Date(chapter.createdAt).toDateString();
|
||||
const chapterPath = novelPath + chapter.id + '/' + chapter.chp_name;
|
||||
|
||||
novelChapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
path: chapterPath,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
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];
|
||||
|
||||
const chapterText = item?.chp_content || '';
|
||||
|
||||
return chapterText.replace(/\n/g, '<br>');
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
searchTerm = searchTerm.toLowerCase();
|
||||
const url = this.apiSite + 'novels?&q';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = (await result.json()) as response;
|
||||
|
||||
const results = body?.novels?.filter(novel =>
|
||||
novel.nvl_title.toLowerCase().includes(searchTerm),
|
||||
);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
results?.forEach(res => {
|
||||
const name = res.nvl_title;
|
||||
const cover = this.apiSite + 'get-image/' + res.image + '/novels/false';
|
||||
const path = 'novelas/' + res.id + '/' + res.nvl_name + '/';
|
||||
|
||||
novels.push({ name, cover, path });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
}
|
||||
|
||||
export default new SkyNovels();
|
||||
|
||||
type response = {
|
||||
novels?: NovelsEntity[] | null;
|
||||
};
|
||||
type NovelsEntity = {
|
||||
id: number;
|
||||
nvl_author?: number | null;
|
||||
nvl_content: string;
|
||||
nvl_title: string;
|
||||
nvl_acronym?: string | null;
|
||||
nvl_status: string;
|
||||
nvl_publication_date?: string | null;
|
||||
nvl_name: string;
|
||||
nvl_recommended: number;
|
||||
nvl_writer: string;
|
||||
nvl_translator?: string | null;
|
||||
nvl_translator_eng?: string | null;
|
||||
image: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
nvl_chapters: number;
|
||||
nvl_last_update: string;
|
||||
nvl_rating?: number | null;
|
||||
nvl_ratings_count: number;
|
||||
genres?: GenresEntity[] | null;
|
||||
};
|
||||
type GenresEntity = {
|
||||
id: number;
|
||||
genre_name: string;
|
||||
};
|
||||
|
||||
type responseBook = {
|
||||
novel?: NovelEntity[] | null;
|
||||
};
|
||||
type NovelEntity = {
|
||||
id: number;
|
||||
nvl_author: number;
|
||||
nvl_content: string;
|
||||
nvl_title: string;
|
||||
nvl_acronym: string;
|
||||
nvl_status: string;
|
||||
nvl_publication_date: string;
|
||||
nvl_name: string;
|
||||
nvl_recommended: number;
|
||||
nvl_writer: string;
|
||||
nvl_translator: string;
|
||||
nvl_translator_eng: string;
|
||||
image: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
nvl_chapters: number;
|
||||
nvl_last_update: string;
|
||||
nvl_rating: number;
|
||||
bookmarks?: BookmarksEntity[] | null;
|
||||
volumes?: VolumesEntity[] | null;
|
||||
novel_ratings?: NovelRatingsEntity[] | null;
|
||||
collaborators?: CollaboratorsEntity[] | null;
|
||||
genres?: GenresEntity[] | null;
|
||||
};
|
||||
type BookmarksEntity = {
|
||||
id: number;
|
||||
user_id: number;
|
||||
chp_id: number;
|
||||
chp_name: string;
|
||||
};
|
||||
type VolumesEntity = {
|
||||
vlm_title: string;
|
||||
id: number;
|
||||
nvl_id: number;
|
||||
user_id?: number | null;
|
||||
chapters?: ChaptersEntity[] | null;
|
||||
};
|
||||
type ChaptersEntity = {
|
||||
id: number;
|
||||
chp_index_title: string;
|
||||
chp_name: string;
|
||||
chp_number: number;
|
||||
chp_status: string;
|
||||
createdAt: string;
|
||||
};
|
||||
type NovelRatingsEntity = {
|
||||
user_id: number;
|
||||
rate_value: number;
|
||||
rate_comment: string;
|
||||
replys_count: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
id: number;
|
||||
user_login: string;
|
||||
image?: string | null;
|
||||
likes?: (LikesEntity | null)[] | null;
|
||||
};
|
||||
type LikesEntity = {
|
||||
id: number;
|
||||
user_id: number;
|
||||
user_login: string;
|
||||
};
|
||||
type CollaboratorsEntity = {
|
||||
user_id: number;
|
||||
user_login: string;
|
||||
};
|
||||
|
||||
type responseChapter = {
|
||||
chapter?: ChapterEntity[] | null;
|
||||
};
|
||||
type ChapterEntity = {
|
||||
id: number;
|
||||
chp_author: number;
|
||||
chp_translator?: null;
|
||||
nvl_id: number;
|
||||
vlm_id: number;
|
||||
chp_number: number;
|
||||
chp_content: string;
|
||||
chp_review?: null;
|
||||
chp_title?: null;
|
||||
chp_index_title: string;
|
||||
chp_status: string;
|
||||
chp_name: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
nvl_title: string;
|
||||
nvl_name: string;
|
||||
user_login: string;
|
||||
reactions_count: number;
|
||||
comments?: null[] | null;
|
||||
reactions?: null[] | null;
|
||||
total_reactions?: TotalReactionsEntity[] | null;
|
||||
};
|
||||
type TotalReactionsEntity = {
|
||||
reaction_id: number;
|
||||
reaction_name: string;
|
||||
reaction_count: number;
|
||||
};
|
||||
@@ -0,0 +1,257 @@
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@/types/plugin';
|
||||
import { defaultCover } from '@libs/defaultCover';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
|
||||
class TuNovelaLigera implements Plugin.PagePlugin {
|
||||
id = 'tunovelaligera';
|
||||
name = 'TuNovelaLigera';
|
||||
icon = 'src/es/tunovelaligera/icon.png';
|
||||
site = 'https://tunovelaligera.com';
|
||||
version = '1.1.0';
|
||||
|
||||
async sleep(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = this.site;
|
||||
|
||||
link += filters?.genres?.value
|
||||
? '/genero' + filters.genres.value
|
||||
: '/novelas';
|
||||
link += `/page/${pageNo}?m_orderby=`;
|
||||
link += showLatestNovels ? 'latest' : filters?.order?.value || 'rating';
|
||||
|
||||
const result = await fetchApi(link).then(res => res.text());
|
||||
const loadedCheerio = parseHTML(result);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.page-item-detail').each((i, el) => {
|
||||
const name = loadedCheerio(el).find('.h5 > a').text();
|
||||
const cover = loadedCheerio(el).find('img').attr('src');
|
||||
const url = loadedCheerio(el).find('.h5 > a').attr('href');
|
||||
if (!url) return;
|
||||
|
||||
novels.push({ name, cover, path: url.replace(this.site, '') });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
parseChapters(loadedCheerio: CheerioAPI): Plugin.ChapterItem[] {
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio('#lcp_instance_0 li').each((i, el) => {
|
||||
const chapterName = loadedCheerio(el)
|
||||
.find('a')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
const chapterUrl = loadedCheerio(el).find('a').attr('href');
|
||||
if (!chapterUrl) return;
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
path: chapterUrl.replace(this.site, ''),
|
||||
});
|
||||
});
|
||||
return chapters;
|
||||
}
|
||||
|
||||
async parseNovel(
|
||||
novelPath: string,
|
||||
): Promise<Plugin.SourceNovel & { totalPages: number }> {
|
||||
const novelUrl = this.site + novelPath;
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
let lastPage = 1;
|
||||
loadedCheerio('ul.lcp_paginator > li > a').each(function () {
|
||||
const page = Number(this.attribs['title']);
|
||||
if (page && page > lastPage) lastPage = page;
|
||||
});
|
||||
const novel: Plugin.SourceNovel & { totalPages: number } = {
|
||||
path: novelPath,
|
||||
chapters: [],
|
||||
totalPages: lastPage,
|
||||
name: loadedCheerio('.post-title > h1').text().trim(),
|
||||
};
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
const novelCover = loadedCheerio('.summary_image > a > img');
|
||||
|
||||
novel.cover =
|
||||
novelCover.attr('data-src') ||
|
||||
novelCover.attr('src') ||
|
||||
novelCover.attr('data-cfsrc') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Género(s)':
|
||||
novel.genres = detail.replace(/, /g, ',');
|
||||
break;
|
||||
case 'Autor(es)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Estado':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('Updating')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.summary = loadedCheerio('div.summary__content > p').text().trim();
|
||||
|
||||
novel.chapters = this.parseChapters(loadedCheerio);
|
||||
const latestChapterEle = loadedCheerio('#lcp_instance_0 li').first();
|
||||
const latestChapterUrl = loadedCheerio(latestChapterEle)
|
||||
.find('a')
|
||||
.attr('href');
|
||||
const latestChapterName = loadedCheerio(latestChapterEle)
|
||||
.find('a')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
novel.latestChapter = latestChapterUrl
|
||||
? {
|
||||
path: latestChapterUrl.replace(this.site, ''),
|
||||
name: latestChapterName,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
|
||||
const pageUrl = this.site + novelPath + '?lcp_page0=' + page;
|
||||
const pageText = await fetchApi(pageUrl).then(res => res.text());
|
||||
const chapters = this.parseChapters(parseHTML(pageText));
|
||||
return {
|
||||
chapters,
|
||||
};
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetchApi(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio('.c-blog-post.post').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}/?s=${searchTerm}&post_type=wp-manga`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each((i, el) => {
|
||||
const name = loadedCheerio(el).find('.h4 > a').text();
|
||||
const cover = loadedCheerio(el).find('img').attr('src');
|
||||
const url = loadedCheerio(el).find('.h4 > a').attr('href');
|
||||
if (!url) return;
|
||||
|
||||
novels.push({ name, cover, path: url.replace(this.site, '') });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
filters = {
|
||||
order: {
|
||||
value: 'rating',
|
||||
label: 'Ordenado por',
|
||||
options: [
|
||||
{ label: 'Lo mas reciente', value: 'latest' },
|
||||
{ label: 'A-Z', value: 'alphabet' },
|
||||
{ label: 'Clasificación', value: 'rating' },
|
||||
{ label: 'Trending', value: 'trending' },
|
||||
{ label: 'Mas visto', value: 'views' },
|
||||
{ label: 'Nuevo', value: 'new-manga' },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
genres: {
|
||||
value: '',
|
||||
label: 'Generos',
|
||||
options: [
|
||||
{ label: 'None', value: '' },
|
||||
{ label: 'Acción', value: 'accion' },
|
||||
{ label: 'Adulto', value: 'adulto' },
|
||||
{ label: 'Artes Marciales', value: 'artes-marciales' },
|
||||
{ label: 'Aventura', value: 'aventura' },
|
||||
{ label: 'Ciencia Ficción', value: 'ciencia-ficcion' },
|
||||
{ label: 'Comedia', value: 'comedia' },
|
||||
{ label: 'Deportes', value: 'deportes' },
|
||||
{ label: 'Drama', value: 'drama' },
|
||||
{ label: 'Eastern Fantasy', value: 'eastern-fantasy' },
|
||||
{ label: 'Ecchi', value: 'ecchi' },
|
||||
{ label: 'FanFiction', value: 'fan-fiction' },
|
||||
{ label: 'Fantasía', value: 'fantasia' },
|
||||
{ label: 'Fantasía oriental', value: 'fantasia-oriental' },
|
||||
{ label: 'Ficción Romántica', value: 'ficcion-romantica' },
|
||||
{ label: 'Gender Bender', value: 'gender-bender' },
|
||||
{ label: 'Harem', value: 'harem' },
|
||||
{ label: 'Histórico', value: 'historico' },
|
||||
{ label: 'Horror', value: 'horror' },
|
||||
{ label: 'Josei', value: 'josei' },
|
||||
{ label: 'Maduro', value: 'maduro' },
|
||||
{ label: 'Mecha', value: 'mecha' },
|
||||
{ label: 'Misterio', value: 'misterio' },
|
||||
{ label: 'Novela China', value: 'novela-china' },
|
||||
{ label: 'Novela FanFiction', value: 'novela-fanfiction' },
|
||||
{ label: 'Novela Japonesa', value: 'novela-japonesa' },
|
||||
{ label: 'Novela Koreana', value: 'novela-koreana' },
|
||||
{ label: 'Novela ligera', value: 'novela-ligera' },
|
||||
{ label: 'Novela original', value: 'novela-original' },
|
||||
{ label: 'Novela Web', value: 'web-novel' },
|
||||
{ label: 'Psicológico', value: 'psicologico' },
|
||||
{ label: 'Realismo Mágico', value: 'realismo-magico' },
|
||||
{ label: 'Recuento de vida', value: 'recuento-de-vida' },
|
||||
{ label: 'Romance', value: 'romance' },
|
||||
{ label: 'Romance contemporáneo', value: 'romance-contemporaneo' },
|
||||
{ label: 'Romance Moderno', value: 'romance-moderno' },
|
||||
{ label: 'Seinen', value: 'seinen' },
|
||||
{ label: 'Shoujo', value: 'shoujo' },
|
||||
{ label: 'Shounen', value: 'shounen' },
|
||||
{ label: 'Sobrenatural', value: 'sobrenatural' },
|
||||
{ label: 'Tragedia', value: 'tragedia' },
|
||||
{ label: 'Vampiros', value: 'vampiros' },
|
||||
{ label: 'Vida Escolar', value: 'vida-escolar' },
|
||||
{ label: 'Western Fantasy', value: 'western-fantasy' },
|
||||
{ label: 'Wuxia', value: 'wuxia' },
|
||||
{ label: 'Xianxia', value: 'xianxia' },
|
||||
{ label: 'Xuanhuan', value: 'xuanhuan' },
|
||||
{ label: 'Yaoi', value: 'yaoi' },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new TuNovelaLigera();
|
||||
@@ -0,0 +1,174 @@
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Filters } from '@libs/filterInputs';
|
||||
import { Plugin } from '@/types/plugin';
|
||||
import { load as parseHTML } from 'cheerio';
|
||||
|
||||
class Yuuki implements Plugin.PluginBase {
|
||||
id = 'yuukitls';
|
||||
name = 'Yuuki Tls';
|
||||
icon = 'src/es/yuukitls/icon.png';
|
||||
site = 'https://yuukitls.com/';
|
||||
filters?: Filters | undefined;
|
||||
version = '1.0.0';
|
||||
|
||||
async popularNovels(): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.quadmenu-navbar-collapse ul li:nth-child(2)')
|
||||
.find('li')
|
||||
.each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele)
|
||||
.text()
|
||||
.replace(/[\s\n]+/g, ' ');
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
if (!novelUrl) return;
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('h1.entry-title')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim(),
|
||||
};
|
||||
|
||||
novel.cover = loadedCheerio('img[loading="lazy"]').attr('src');
|
||||
|
||||
loadedCheerio('.entry-content')
|
||||
.find('div')
|
||||
.each(function () {
|
||||
if (loadedCheerio(this).text().includes('Escritor:')) {
|
||||
novel.author = loadedCheerio(this)
|
||||
.text()
|
||||
.replace('Escritor: ', '')
|
||||
.trim();
|
||||
}
|
||||
if (loadedCheerio(this).text().includes('Género:')) {
|
||||
novel.genres = loadedCheerio(this)
|
||||
.text()
|
||||
.replace(/Género: |\s/g, '');
|
||||
}
|
||||
|
||||
if (loadedCheerio(this).text().includes('Sinopsis:')) {
|
||||
novel.summary = loadedCheerio(this).next().text();
|
||||
}
|
||||
});
|
||||
|
||||
const novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
if (loadedCheerio('.entry-content').find('li').length) {
|
||||
loadedCheerio('.entry-content')
|
||||
.find('li')
|
||||
.each((idx, ele) => {
|
||||
const chapterUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (chapterUrl && chapterUrl.includes(this.site)) {
|
||||
const chapterName = loadedCheerio(ele).text();
|
||||
const releaseDate = null;
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
path: chapterUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novelChapters.push(chapter);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
loadedCheerio('.entry-content')
|
||||
.find('p')
|
||||
.each((idx, ele) => {
|
||||
const chapterUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
|
||||
if (chapterUrl && chapterUrl.includes(this.site)) {
|
||||
const chapterName = loadedCheerio(ele).text();
|
||||
const releaseDate = null;
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
path: chapterUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novelChapters.push(chapter);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = this.site + chapterPath;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText = loadedCheerio('.entry-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
searchTerm = searchTerm.toLowerCase();
|
||||
|
||||
const result = await fetchApi(this.site);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('.menu-item-2869')
|
||||
.find('.menu-item.menu-item-type-post_type.menu-item-object-post')
|
||||
.each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).text();
|
||||
const novelCover = loadedCheerio(ele).find('img').attr('src');
|
||||
|
||||
const novelUrl = loadedCheerio(ele).find('a').attr('href');
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
novels = novels.filter(novel =>
|
||||
novel.name.toLowerCase().includes(searchTerm),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
}
|
||||
|
||||
export default new Yuuki();
|
||||
Reference in New Issue
Block a user