added EpikNovel (#909)

This commit is contained in:
nyagami
2024-04-26 23:16:54 +07:00
committed by GitHub
parent 293c70c08f
commit dfb3f0a011
2 changed files with 27 additions and 30 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@@ -4,17 +4,16 @@ import { Plugin } from '@typings/plugin';
import { Filters } from '@libs/filterInputs'; import { Filters } from '@libs/filterInputs';
class EpikNovel implements Plugin.PluginBase { class EpikNovel implements Plugin.PluginBase {
id = 'epiknovel.com'; id = 'epiknovel';
name = 'EpikNovel'; name = 'EpikNovel';
icon = 'src/tr/epiknovel/icon.png'; icon = 'src/tr/epiknovel/icon.png';
site = 'https://www.epiknovel.com/'; site = 'https://www.epiknovel.com/';
version = '1.0.0'; version = '1.0.0';
baseUrl = this.site;
async popularNovels( async popularNovels(
pageNo: number, pageNo: number,
options: Plugin.PopularNovelsOptions<Filters>, options: Plugin.PopularNovelsOptions<Filters>,
): Promise<Plugin.NovelItem[]> { ): Promise<Plugin.NovelItem[]> {
let url = this.baseUrl + 'seri-listesi?Sayfa=' + pageNo; let url = this.site + 'seri-listesi?Sayfa=' + pageNo;
const result = await fetch(url); const result = await fetch(url);
const body = await result.text(); const body = await result.text();
@@ -23,17 +22,17 @@ class EpikNovel implements Plugin.PluginBase {
let novels: Plugin.NovelItem[] = []; let novels: Plugin.NovelItem[] = [];
loadedCheerio('div.col-lg-12.col-md-12').each(function () { loadedCheerio('div.col-lg-12.col-md-12').each((idx, ele) => {
const novelName = loadedCheerio(this).find('h3').text(); const novelName = loadedCheerio(ele).find('h3').text();
const novelCover = loadedCheerio(this).find('img').attr('data-src'); const novelCover = loadedCheerio(ele).find('img').attr('data-src');
const novelUrl = loadedCheerio(this).find('h3 > a').attr('href'); const novelUrl = loadedCheerio(ele).find('h3 > a').attr('href');
if (!novelUrl) return; if (!novelUrl) return;
const novel = { const novel = {
name: novelName, name: novelName,
cover: novelCover, cover: novelCover,
url: novelUrl, path: novelUrl.replace(this.site, ''),
}; };
novels.push(novel); novels.push(novel);
@@ -43,8 +42,8 @@ class EpikNovel implements Plugin.PluginBase {
return novels; return novels;
} }
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> { async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
const url = novelUrl; const url = this.site + novelPath;
// console.log(url); // console.log(url);
const result = await fetch(url); const result = await fetch(url);
@@ -52,9 +51,10 @@ class EpikNovel implements Plugin.PluginBase {
let loadedCheerio = parseHTML(body); let loadedCheerio = parseHTML(body);
let novel: Plugin.SourceNovel = { url }; let novel: Plugin.SourceNovel = {
path: novelPath,
novel.name = loadedCheerio('h1#tables').text().trim(); name: loadedCheerio('h1#tables').text().trim(),
};
novel.cover = loadedCheerio('img.manga-cover').attr('src'); novel.cover = loadedCheerio('img.manga-cover').attr('src');
@@ -81,18 +81,16 @@ class EpikNovel implements Plugin.PluginBase {
loadedCheerio('table') loadedCheerio('table')
.find('tr') .find('tr')
.each(function () { .each((idx, ele) => {
const releaseDate = loadedCheerio(this).find('td:nth-child(3)').text(); const releaseDate = loadedCheerio(ele).find('td:nth-child(3)').text();
let chapterName = loadedCheerio(this) let chapterName = loadedCheerio(ele).find('td:nth-child(1) > a').text();
.find('td:nth-child(1) > a')
.text();
if (loadedCheerio(this).find('td:nth-child(1) > span').length > 0) { if (loadedCheerio(ele).find('td:nth-child(1) > span').length > 0) {
chapterName = '🔒 ' + chapterName; chapterName = '🔒 ' + chapterName;
} }
const chapterUrl = loadedCheerio(this) const chapterUrl = loadedCheerio(ele)
.find(' td:nth-child(1) > a') .find(' td:nth-child(1) > a')
.attr('href'); .attr('href');
@@ -100,7 +98,7 @@ class EpikNovel implements Plugin.PluginBase {
novelChapters.push({ novelChapters.push({
name: chapterName, name: chapterName,
url: chapterUrl, path: chapterUrl.replace(this.site, ''),
releaseTime: releaseDate, releaseTime: releaseDate,
}); });
}); });
@@ -110,8 +108,8 @@ class EpikNovel implements Plugin.PluginBase {
return novel; return novel;
} }
async parseChapter(chapterUrl: string): Promise<string> { async parseChapter(chapterPath: string): Promise<string> {
const url = chapterUrl; const url = this.site + chapterPath;
// console.log(url); // console.log(url);
@@ -134,8 +132,7 @@ class EpikNovel implements Plugin.PluginBase {
searchTerm: string, searchTerm: string,
pageNo: number, pageNo: number,
): Promise<Plugin.NovelItem[]> { ): Promise<Plugin.NovelItem[]> {
const url = const url = this.site + 'seri-listesi?q=' + searchTerm + '&Sayfa=' + pageNo;
this.baseUrl + 'seri-listesi?q=' + searchTerm + '&Sayfa=' + pageNo;
const result = await fetch(url); const result = await fetch(url);
const body = await result.text(); const body = await result.text();
@@ -144,17 +141,17 @@ class EpikNovel implements Plugin.PluginBase {
let novels: Plugin.NovelItem[] = []; let novels: Plugin.NovelItem[] = [];
loadedCheerio('div.col-lg-12.col-md-12').each(function () { loadedCheerio('div.col-lg-12.col-md-12').each((idx, ele) => {
const novelName = loadedCheerio(this).find('h3').text(); const novelName = loadedCheerio(ele).find('h3').text();
const novelCover = loadedCheerio(this).find('img').attr('data-src'); const novelCover = loadedCheerio(ele).find('img').attr('data-src');
const novelUrl = loadedCheerio(this).find('h3 > a').attr('href'); const novelUrl = loadedCheerio(ele).find('h3 > a').attr('href');
if (!novelUrl) return; if (!novelUrl) return;
const novel = { const novel = {
name: novelName, name: novelName,
cover: novelCover, cover: novelCover,
url: novelUrl, path: novelUrl.replace(this.site, ''),
}; };
novels.push(novel); novels.push(novel);