Beta phase (#801)

* beta host

* Refactor: url -> path (#757)

* refactor: url -> path

* clean up

* fix: json branch

* PagePlugin (#769)

* paginated novel support

* fix: truyenfull

* fix: tunovel, remove pageList

* parsePage support for webtest (#773)

* add parsePage api

* add parsePage UI

* add totalPages

* (FR src) Beta plugin & Added filters (#775)

* noveldeglace:
 - added filters
 - added latest
 - defaultCover fallback
 - change id to noveldeglace.com
 - added complementary infos in summary
 - added cover artist
 - chapters are now parts
 - show volume number for multi volume novels
 - better search
 - fix search page number
 - refactored for plugin beta
 - releaseDate as Date.toString()
 - separted parseNovels
 - separated getCheerio
 - loadedCheerio => $ for shorter lines & simpler test on web

* chireads:
 - fix different parsing for mobile version
 - added filters
 - added author
 - added status
 - added released date
 - refactored for plugin beta
 - separted parseNovels
 - separated getCheerio
 - loadedCheerio => $ for shorter lines & simpler test on web

* wpmangastream => lightnovelwp rework & new sources (#776)

* Added sources:
 - Knoxt (EN)
 - Baca Light Novel (ID)
 - AllNovelRead (ES)
 - DaoTranslate (EN)
 - جنة الروايات (AR)
 - Universal Novel (EN)
 - NovelTR (TR)
old sources auto-generated:
 - GenesisTls (EN)
 - NobleMTL (EN)
wpmangastream => lightnovelwp:
 - added doc
 - added filters in a separte file
 - semi-automatic filter generator
 - made it compatible with version 1.0.X and 1.1.X versions of the theme
 - loadedCheerio => $
 - icons in "/icons/lightnovel/id.png"
 - code cleanup

* removed auto-implemented sources

* Added README.md to lightnovelwp

* removed ai generated text for kolnovel

* added novelsknight

* added centralNovel

* pandamtl accual name

* adding folder plugin/arabic

* Fix: Vietnamese plugins (#777)

* fix: lightnovelvn

* add nettruyen

* add truyenchu

* fix: truyenconect

* Fix: Migrate plugins (#771)

* Add novel.ovh (#756)

* fix

* test

* fix

* date fix + master merge (#761)

* date fix

* Added Brazilian Portuguese E-Novel (#758)

* fixed single digit dates (#767)

Co-authored-by: NaddH1 <naderhorani@hotmail.com>

* fix

* test

* fix order

* Update renovels.ts

* require_chapters

* Delete plugins/english/genesistl.broken.ts

* Update novelTL.ts

---------

Co-authored-by: NaddH1 <naderhorani@hotmail.com>

* (src update) ENG (#772)

* allnovelfull

* bestlightnovel

* divinedaolibrary

* earlynovel

* lightnovelpub

* L

* M

* novelbin

* novelfull

* novelbuddy

* N S

* novel updates

* async sleep

* rename file

* pagePlugin

* Feat: minify js dir (#781)

* Multisrc: HotNovelPub (#784)

* HotNovelPub

* fix search

* Squashed commit of the following:

commit 3b759c68eddc06c0adfb959f775de069a85adca7
Author: nyagami <hoangquan05112002@gmail.com>
Date:   Sat Feb 17 20:33:47 2024 +0700

    Feat: minify js dir (#781)

* jsmin changed to terser

* test

* why I did it.

* test

* Update ranobelib.ts

* fix page

* Update ranobelib.ts

* updated modules

* Update terser.json

Co-authored-by: nyagami <hoangquan05112002@gmail.com>

* Update scripts/multisrc/hotnovelpub/template.ts

Co-authored-by: nyagami <hoangquan05112002@gmail.com>

* terser api

---------

Co-authored-by: nyagami <hoangquan05112002@gmail.com>

* Added sources & fix sources (#787)

* lightnovelwp:
 - fix author name
 - added more localisation of strings
 - README typo
 - error on !r.ok new message

* noveldeglace:
 - fix chapterNumber for parts
 - better dates
 - better search

* Added sources:
 - White Moonlight Novels (EN)
 - System Translation (EN)

* Resized centralnovel.png

* Add Faqwiki.us source (#792)

* Add Faqwiki.us source (beta branch)

* Fix Path, Fix Chapter Parsing, Fix Novel Title

* search novel path fix

* fix chapter parsing. some chapter in this site store their whole text in 1-4 <p>,

* Add WTR-LAB Source (#797)

* Add WTR-LAB Source (Beta Branch)

* Add other language from WTR-LAB source

* change lang to sourceLang

* remove id es tr lang from WTR-LAB

* Update plugins/english/wtrlab.ts

agree

Co-authored-by: nyagami <hoangquan05112002@gmail.com>

* Update plugins/english/wtrlab.ts

agree

Co-authored-by: nyagami <hoangquan05112002@gmail.com>

---------

Co-authored-by: nyagami <hoangquan05112002@gmail.com>

* revert: scripts to master

---------

Co-authored-by: Justin COLLON <48163201+error7404@users.noreply.github.com>
Co-authored-by: Rider21 <58046032+Rider21@users.noreply.github.com>
Co-authored-by: NaddH1 <naderhorani@hotmail.com>
Co-authored-by: K1ngfish3r <trulyihu@gmail.com>
Co-authored-by: bregassa <bregas.sat1@gmail.com>
This commit is contained in:
nyagami
2024-02-25 14:52:37 +07:00
committed by GitHub
parent 2b9c8f7d2a
commit d818d1758f
147 changed files with 10278 additions and 5758 deletions
+43 -39
View File
@@ -18,10 +18,6 @@ class HakoPlugin implements Plugin.PluginBase {
.find("div.thumb_attr.series-title > a")
.attr("href");
if (url && !isUrlAbsolute(url)) {
url = this.site + url;
}
if (url) {
const name = loadedCheerio(ele)
.find(".series-title")
@@ -35,7 +31,7 @@ class HakoPlugin implements Plugin.PluginBase {
cover = this.site + cover;
}
const novel = { name, url, cover };
const novel = { name, path: url.replace(this.site, ''), cover };
novels.push(novel);
}
@@ -64,11 +60,12 @@ class HakoPlugin implements Plugin.PluginBase {
const loadedCheerio = parseHTML(body);
return this.parseNovels(loadedCheerio);
}
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
const novel: Plugin.SourceNovel = {
url: novelUrl,
path: novelPath,
name: 'Không có tiêu đề',
};
const result = await fetch(novelUrl);
const result = await fetch(this.site + novelPath);
const body = await result.text();
let loadedCheerio = parseHTML(body);
@@ -121,39 +118,46 @@ class HakoPlugin implements Plugin.PluginBase {
novel.status = NovelStatus.Unknown;
}
let num = 0, part = 1;
const chapters: Plugin.ChapterItem[] = loadedCheerio('.list-chapters li').toArray().map((ele) => {
let chapterUrl = this.site + loadedCheerio(ele).find("a").attr("href");
const chapterName = loadedCheerio(ele)
.find(".chapter-name")
.text()
.trim();
let chapterNumber = Number(chapterName.match(/Chương\s*(\d+)/i)?.[1]);
if(chapterNumber){
num = chapterNumber;
part = 1;
}else{
chapterNumber = num + part / 10;
part ++;
}
const chapterTime = loadedCheerio(ele)
.find(".chapter-time")
.text()
.split('/')
.map(x => Number(x));
return {
url: chapterUrl || '',
name: chapterName,
releaseTime: new Date(chapterTime[2], chapterTime[1], chapterTime[0]).toISOString(),
chapterNumber: chapterNumber,
};
}).filter(c => c.url);
novel.chapters = chapters;
novel.chapters = [];
loadedCheerio('.volume-list').each((idx, ele) => {
const customPage = loadedCheerio(ele).find('.sect-title').text().trim();
let num = 0, part = 1;
loadedCheerio(ele).find('.list-chapters > li').each((idx, chapterEle) => {
const path = loadedCheerio(chapterEle).find("a").attr("href");
const chapterName = loadedCheerio(chapterEle)
.find(".chapter-name")
.text()
.trim();
let chapterNumber = Number(chapterName.match(/Chương\s*(\d+)/i)?.[1]);
if(chapterNumber){
num = chapterNumber;
part = 1;
}else{
chapterNumber = num + part / 10;
part ++;
}
const chapterTime = loadedCheerio(chapterEle)
.find(".chapter-time")
.text()
.split('/')
.map(x => Number(x));
if(path){
novel.chapters?.push(
{
page: customPage,
path,
name: chapterName,
releaseTime: new Date(chapterTime[2], chapterTime[1], chapterTime[0]).toISOString(),
chapterNumber: chapterNumber,
}
);
}
});
});
return novel;
}
async parseChapter(chapterUrl: string): Promise<string> {
const result = await fetch(chapterUrl);
async parseChapter(chapterPath: string): Promise<string> {
const result = await fetch(this.site + chapterPath);
const body = await result.text();
const loadedCheerio = parseHTML(body);
-228
View File
@@ -1,228 +0,0 @@
import { CheerioAPI, load as parseHTML } from "cheerio";
import { fetchApi, fetchFile } from "@libs/fetch";
import { Plugin } from "@typings/plugin";
import { FilterTypes, Filters } from "@libs/filterInputs";
class TruyenConect implements Plugin.PluginBase {
id = "truyenconect";
name = "Truyen Conect";
icon = "src/vi/truyenconect/icon.png";
site = "https://truyenconect.com";
version = "1.0.0";
parseNovels(loadedCheerio: CheerioAPI, selector: string){
const novels: Plugin.NovelItem[] = [];
loadedCheerio(selector).each(function () {
const url = loadedCheerio(this).find('a').attr('href');
if(url){
novels.push({
name: loadedCheerio(this).find('img').attr('alt') || '',
url,
cover: loadedCheerio(this).find('img').attr('data-src'),
})
}
});
return novels;
}
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions<typeof this.filters>): Promise<Plugin.NovelItem[]> {
let link = this.site;
let selector = '.c-page__content > .grid9.block .item-thumb.c-image-hover';
if(showLatestNovels){
selector = '.c-page__content .page-content-listing.item-big_thumbnail .item-thumb.c-image-hover';
}
if(filters.category.value){
link += '/' + filters.category.value;
selector = 'table.manga-shortcodes.manga-chapters-listing td[width="10%"]';
if(filters.category.value === 'the-loai'){
selector = '.item-thumb.hover-details.c-image-hover'
link += '/' + filters.genre.value;
}
link += '?page=' + pageNo;
}
const body = await fetch(link).then(r => r.text());
const loadedCheerio = parseHTML(body);
return this.parseNovels(loadedCheerio, selector);
}
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
const url = novelUrl;
const result = await fetchApi(url);
const body = await result.text();
let loadedCheerio = parseHTML(body);
const novel: Plugin.SourceNovel = {
url,
chapters: [],
};
novel.name = loadedCheerio(".post-title > h1").text().trim();
novel.cover = loadedCheerio(".summary_image > a > img").attr(
"data-src"
);
loadedCheerio(".post-content_item").each(function () {
const detailName = loadedCheerio(this)
.find(".summary-heading > h5")
.text()
.trim();
const detail = loadedCheerio(this).find(".summary-content").html();
if (!detail) return;
switch (detailName) {
case "Genre":
novel.genres = loadedCheerio(detail)
.children("a")
.map((i, el) => loadedCheerio(el).text())
.toArray()
.join(",");
break;
case "Author":
novel.author = loadedCheerio(detail)
.children("a")
.map((i, el) => loadedCheerio(el).text())
.toArray()
.join(", ");
break;
case "Novel":
novel.status = detail?.trim().replace(/G/g, "g");
break;
}
});
loadedCheerio(
".description-summary > div.summary__content > div"
).remove();
novel.summary = loadedCheerio(
".description-summary > div.summary__content"
)
.text()
.trim();
let chapter: Plugin.ChapterItem[] = [];
loadedCheerio(".wp-manga-chapter").each(function () {
const chapterName = loadedCheerio(this)
.find("a")
.text()
.replace(/[\t\n]/g, "")
.trim();
const releaseDate = loadedCheerio(this).find("span").text().trim();
const chapterUrl = loadedCheerio(this).find("a").attr("href");
if (!chapterUrl) return;
chapter.push({
name: chapterName,
releaseTime: releaseDate,
url: chapterUrl,
});
});
novel.chapters = chapter.reverse();
return novel;
}
async parseChapter(chapterUrl: string): Promise<string> {
const result = await fetchApi(chapterUrl);
const body = await result.text();
const loadedCheerio = parseHTML(body);
loadedCheerio("img").removeAttr("srcset");
let chapterText = loadedCheerio(".reading-content").html() || '';
return chapterText;
}
async searchNovels(searchTerm: string, pageNo: number): 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(function () {
const novelName = loadedCheerio(this).find(".h4 > a").text();
const novelCover = loadedCheerio(this).find("img").attr("data-src");
const novelUrl = loadedCheerio(this).find(".h4 > a").attr("href");
if (!novelUrl) return;
novels.push({
name: novelName,
url: novelUrl,
cover: novelCover,
});
});
return novels;
}
async fetchImage(url: string): Promise<string | undefined> {
return fetchFile(url);
}
filters = {
category: {
label: "Lọc theo",
value: '',
type: FilterTypes.Picker,
options: [
{label: '', value: ''},
{label: 'Thể loại', value: 'the-loai'},
{label: 'Truyện dịch', value: 'truyen-dich'},
{label: 'Truyện convert', value: 'convert'}
]
},
genre: {
label: 'Thể loại',
value: 'action',
type: FilterTypes.Picker,
options: [
{label: 'Action', value: 'action'},
{label: 'Adult', value: 'adult'},
{label: 'Adventure', value: 'adventure'},
{label: 'Chinese novel', value: 'chinese-novel'},
{label: 'Chuyển Sinh', value: 'chuyen-sinh'},
{label: 'English Novel', value: 'english-novel'},
{label: 'Harem', value: 'harem'},
{label: 'Ecchi', value: 'ecchi'},
{label: 'Fantasy', value: 'fantasy'},
{label: 'Drama', value: 'drama'},
{label: 'Game', value: 'game'},
{label: 'Tiên hiệp', value: 'tien-hiep'},
{label: 'Kiếm Hiệp', value: 'kiem-hiep'},
{label: 'Ngôn Tình', value: 'ngon-tinh'},
{label: 'Isekai', value: 'isekai'},
{label: 'Lịch Sử', value: 'lich-su'},
{label: 'Web Novel', value: 'web-novel'},
{label: 'Xuyên không', value: 'xuyen-khong'},
{label: 'Trọng sinh', value: 'trong-sinh'},
{label: 'Trinh thám', value: 'trinh-tham'},
{label: 'Dị giới', value: 'di-gioi'},
{label: 'Huyền ảo', value: 'huyen-ao'},
{label: 'Sắc Hiệp', value: 'sac-hiep'},
{label: 'Dị năng', value: 'di-nang'},
{label: 'Linh dị', value: 'linh-di'},
{label: 'Đô thị', value: 'do-thi'},
{label: 'Comedy', value: 'comedy'},
{label: 'School Life', value: 'school-life'},
{label: 'Romance', value: 'romance'},
{label: 'Martial-arts', value: 'martial-arts'},
{label: 'Light Novel', value: 'light-novel'},
{label: 'Huyền huyễn', value: 'huyen-huyen'},
{label: 'Kỳ Huyễn', value: 'ky-huyen'},
{label: 'Khoa Huyễn', value: 'khoa-huyen'},
{label: 'Võng Du', value: 'vong-du'},
{label: 'Đồng Nhân', value: 'dong-nhan'},
]
}
} satisfies Filters;
}
export default new TruyenConect();
+299
View File
@@ -0,0 +1,299 @@
import { CheerioAPI, load as parseHTML } from "cheerio";
import { fetchApi, fetchFile } from "@libs/fetch";
import { Plugin } from "@typings/plugin";
import { FilterTypes, Filters } from "@libs/filterInputs";
import { NovelStatus } from "@libs/novelStatus";
interface VolumeData {
story: string;
navigation: string;
value: string
}
interface ChapterSelect {
chap_selector: string;
eps_selector: boolean | string;
}
interface VolumeList {
chapters: Plugin.ChapterItem[],
volumes?: VolumeData[]
}
class TruyenConect implements Plugin.PagePlugin {
id = "truyenconect";
name = "Truyen Conect";
icon = "src/vi/truyenconect/icon.png";
site = "https://truyenconect.com";
version = "1.0.0";
async sleep (ms: number) {
return new Promise(resolve => setTimeout(resolve, ms))
}
parseNovels(loadedCheerio: CheerioAPI, selector: string){
const novels: Plugin.NovelItem[] = [];
loadedCheerio(selector).each((idx, ele) => {
const url = loadedCheerio(ele).find('a').attr('href');
if(url){
novels.push({
name: loadedCheerio(ele).find('img').attr('alt') || '',
path: url.replace(this.site, ''),
cover: loadedCheerio(ele).find('img').attr('data-src'),
})
}
});
return novels;
}
async popularNovels(pageNo: number, {filters, showLatestNovels}: Plugin.PopularNovelsOptions<typeof this.filters>): Promise<Plugin.NovelItem[]> {
let link = this.site;
let selector = '.c-page__content > .grid9.block .item-thumb.c-image-hover';
if(showLatestNovels){
selector = '.c-page__content .page-content-listing.item-big_thumbnail .item-thumb.c-image-hover';
}else if(filters.category.value){
link += '/' + filters.category.value;
selector = 'table.manga-shortcodes.manga-chapters-listing td[width="10%"]';
if(filters.category.value === 'the-loai'){
selector = '.item-thumb.hover-details.c-image-hover'
link += '/' + filters.genre.value;
}
link += '?page=' + pageNo;
}
const body = await fetch(link).then(r => r.text());
const loadedCheerio = parseHTML(body);
return this.parseNovels(loadedCheerio, selector);
}
parseChapters(loadedCheerio: CheerioAPI) {
const chapters: Plugin.ChapterItem[] = [];
loadedCheerio('option').each((idx, ele) => {
let url = ele.attribs['value'];
if(!url) return;
const chapterId = url.match(/\/(\d+)-/)?.[1];
if(chapterId){
url = url.replace(chapterId+'-', '') + '-' + chapterId;
}
let num = url.match(/chuong-(\d+)/)?.[1];
chapters.push({
path: url.replace(this.site, ''),
name: loadedCheerio(ele).text().trim(),
chapterNumber: Number(num) || undefined,
})
})
return chapters.reverse();
}
parseVolumes(loadedCheerio: CheerioAPI) {
const volumes: VolumeData[] = [];
loadedCheerio('option').each((idx, ele) => {
volumes.push({
story: ele.attribs['data-story'],
navigation: ele.attribs['data-navigation'],
value: ele.attribs['value'],
})
})
return volumes;
}
async getVolumes (firstChapterUrl: string) {
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 volumeList: VolumeList = {
chapters: this.parseChapters(parseHTML(data.chap_selector))
}
if(data.eps_selector){
volumeList.volumes = this.parseVolumes(parseHTML(data.eps_selector as string))
}
return volumeList
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel & { totalPages: number; }> {
const url = this.site + novelPath;
const result = await fetch(url);
const body = await result.text();
let loadedCheerio = parseHTML(body);
const novel: Plugin.SourceNovel & { totalPages: number; }= {
name: loadedCheerio(".post-title > h1").text().trim(),
path: novelPath,
chapters: [],
totalPages: 1
};
novel.cover = loadedCheerio(".summary_image > a > img").attr(
"data-src"
);
loadedCheerio(".post-content_item").each(function () {
const detailName = loadedCheerio(this)
.find(".summary-heading > h5")
.text()
.trim();
const detail = loadedCheerio(this).find(".summary-content").html();
if (!detail) return;
switch (detailName) {
case "Thể loại":
novel.genres = loadedCheerio(detail)
.children("a")
.map((i, el) => loadedCheerio(el).text())
.toArray()
.join(",");
break;
case "Tác giả":
novel.author = loadedCheerio(detail).text().trim();
break;
case "Hoạ sĩ":
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;
}
});
loadedCheerio(
".description-summary > div.summary__content > div"
).remove();
novel.summary = loadedCheerio(
".description-summary > div.summary__content"
)
.text()
.trim();
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);
const volumeList = await this.getVolumes(firstChapLink);
if(volumeList.volumes) {
novel.totalPages = volumeList.volumes.length;
novel.chapters = volumeList.chapters
}else{
novel.totalPages = 1;
novel.chapters = volumeList.chapters;
}
return novel;
}
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
const url = this.site + novelPath;
const result = await fetch(url);
const body = await result.text();
let 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);
const volumeList = await this.getVolumes(firstChapLink);
const volumeIndex = Number(page) - 1;
if(!volumeList.volumes) throw new Error("Không tìm thấy truyện");
if(volumeIndex >= volumeList.volumes.length) throw new Error("Không tìm thấy volume");
const volume = volumeList.volumes[volumeIndex];
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(r => r.json());
if(res.err) throw new Error(res.html);
return {
chapters: this.parseChapters(parseHTML(res.html))
}
}
async parseChapter(chapterPath: string): Promise<string> {
const result = await fetch(this.site + chapterPath);
const body = await result.text();
const loadedCheerio = parseHTML(body);
let chapterText = loadedCheerio(".reading-content").html() || '';
return chapterText;
}
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
const url = `${this.site}?key=${searchTerm}&page=${pageNo}`;
const result = await fetch(url);
const body = await result.text();
const loadedCheerio = parseHTML(body);
const novels: Plugin.NovelItem[] = [];
loadedCheerio(".tab-thumb.c-image-hover > a").each((idx, ele) => {
const novelName = ele.attribs['title'];
const novelCover = loadedCheerio(ele).find('img').first().attr('src');
const novelUrl = ele.attribs['href'];
if (!novelUrl) return;
novels.push({
name: novelName,
path: novelUrl.replace(this.site, ''),
cover: novelCover,
});
});
return novels;
}
async fetchImage(url: string): Promise<string | undefined> {
return fetchFile(url);
}
filters = {
category: {
label: "Lọc theo",
value: '',
type: FilterTypes.Picker,
options: [
{label: '', value: ''},
{label: 'Thể loại', value: 'the-loai'},
{label: 'Truyện dịch', value: 'truyen-dich'},
{label: 'Truyện convert', value: 'convert'}
]
},
genre: {
label: 'Thể loại',
value: 'action',
type: FilterTypes.Picker,
options: [
{label: 'Action', value: 'action'},
{label: 'Adult', value: 'adult'},
{label: 'Adventure', value: 'adventure'},
{label: 'Chinese novel', value: 'chinese-novel'},
{label: 'Chuyển Sinh', value: 'chuyen-sinh'},
{label: 'English Novel', value: 'english-novel'},
{label: 'Harem', value: 'harem'},
{label: 'Ecchi', value: 'ecchi'},
{label: 'Fantasy', value: 'fantasy'},
{label: 'Drama', value: 'drama'},
{label: 'Game', value: 'game'},
{label: 'Tiên hiệp', value: 'tien-hiep'},
{label: 'Kiếm Hiệp', value: 'kiem-hiep'},
{label: 'Ngôn Tình', value: 'ngon-tinh'},
{label: 'Isekai', value: 'isekai'},
{label: 'Lịch Sử', value: 'lich-su'},
{label: 'Web Novel', value: 'web-novel'},
{label: 'Xuyên không', value: 'xuyen-khong'},
{label: 'Trọng sinh', value: 'trong-sinh'},
{label: 'Trinh thám', value: 'trinh-tham'},
{label: 'Dị giới', value: 'di-gioi'},
{label: 'Huyền ảo', value: 'huyen-ao'},
{label: 'Sắc Hiệp', value: 'sac-hiep'},
{label: 'Dị năng', value: 'di-nang'},
{label: 'Linh dị', value: 'linh-di'},
{label: 'Đô thị', value: 'do-thi'},
{label: 'Comedy', value: 'comedy'},
{label: 'School Life', value: 'school-life'},
{label: 'Romance', value: 'romance'},
{label: 'Martial-arts', value: 'martial-arts'},
{label: 'Light Novel', value: 'light-novel'},
{label: 'Huyền huyễn', value: 'huyen-huyen'},
{label: 'Kỳ Huyễn', value: 'ky-huyen'},
{label: 'Khoa Huyễn', value: 'khoa-huyen'},
{label: 'Võng Du', value: 'vong-du'},
{label: 'Đồng Nhân', value: 'dong-nhan'},
]
}
} satisfies Filters;
}
export default new TruyenConect();
-164
View File
@@ -1,164 +0,0 @@
import { load as parseHTML } from "cheerio";
import { fetchApi, fetchFile } from "@libs/fetch";
import { Plugin } from "@typings/plugin";
import { Filters } from "@libs/filterInputs";
import { NovelStatus } from "@libs/novelStatus";
class LightNovelVN implements Plugin.PluginBase {
id = "lightnovel.vn";
name = "Light Novel VN";
version = "1.0.0";
icon = "src/vi/lightnovelvn/icon.png";
filters?: Filters | undefined;
site = "https://lightnovel.vn/";
baseUrl = this.site;
headers = {
Accept: "application/json",
"Content-Type": "application/json",
};
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions<Filters>): Promise<Plugin.NovelItem[]> {
const url = `${this.baseUrl}truyen-hot-ds?page=${pageNo}`;
const body = await fetch(url).then((r) => r.text());
const loadedCheerio = parseHTML(body);
const novels: Plugin.NovelItem[] = [];
loadedCheerio(".flex.flex-col[itemtype='https://schema.org/Book']").each((idx, ele) => {
const novelName = loadedCheerio(ele).find('h3[itemprop="name"] > a').text().trim();
const img = loadedCheerio(ele).find('noscript').html();
const novelCover = img?.match(/srcSet="([^\s]+)/)?.[1];
const novelUrl = this.site + loadedCheerio(ele).find('h3[itemprop="name"] > a').attr('href')?.substring(1);
const novel = {
name: novelName,
cover: novelCover,
url: novelUrl,
};
novels.push(novel);
});
return novels;
}
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
const url = novelUrl;
const body = await fetch(url).then((r) => r.text());
let loadedCheerio = parseHTML(body);
const novel: Plugin.SourceNovel = {
url,
chapters: [],
};
novel.name = loadedCheerio('h1[itemprop="name"]').text().trim();
novel.cover = loadedCheerio('header div:nth-child(2) img').attr('srcset')?.split(/\s+/)[0]
const genres: string[] = [];
loadedCheerio('a[itemprop="genre"]').each(function() {
genres.push(loadedCheerio(this).text());
})
novel.genres = genres.join(',');
novel.status = loadedCheerio('span.font-bold.text-size22:last').text();
if(novel.status === 'Đang ra'){
novel.status = NovelStatus.Ongoing;
}else if(novel.status === 'Hoàn thành'){
novel.status = NovelStatus.Completed;
}else {
novel.status = NovelStatus.Unknown;
}
novel.author = loadedCheerio('a[itemprop="author"] > span').text();
novel.summary = loadedCheerio('#bookIntro').text().replace(/\s+/g, ' ');
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
await delay(1000);
const chapterListUrl = novelUrl + '/chapters?chorder=desc';
const chapterListBody = await fetchApi(chapterListUrl).then(r => r.text());
const loadedChapterList = parseHTML(chapterListBody);
const lastNumber = parseInt(
loadedChapterList('ul.chapter-list > li:nth-child(1)').attr('data-chapterno') ?? '0'
);
const lastChapterUrl = loadedChapterList('ul.chapter-list > li:nth-child(1) > a').attr('href');
if(lastChapterUrl){
const chapterUrlPrefix = this.baseUrl + lastChapterUrl.split('/').slice(1, -1).join('/');
const chapters: Plugin.ChapterItem[] = [];
for(let i = 1; i <= lastNumber; i++){
chapters.push({
chapterNumber: i,
name: 'Chapter ' + i,
url: chapterUrlPrefix + '/chapter-' + i,
})
}
novel.chapters = chapters;
}
return novel;
}
async parseChapter(chapterUrl: string): Promise<string> {
const body = await fetchApi(chapterUrl).then((r) => r.text());
const loadedCheerio = parseHTML(body);
let chapterText = loadedCheerio("#chapter-container").html() || '';
return chapterText;
}
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
const url = `${this.baseUrl}lnsearchlive`;
const link = `${this.baseUrl}search`;
const response = await fetchApi(link).then((r) => r.text());
const token = parseHTML(response);
let verifytoken = token("#novelSearchForm > input").attr("value");
let formData = new FormData();
formData.append("inputContent", searchTerm);
const body = await fetchApi(
url,
{
method: "POST",
headers: { LNRequestVerifyToken: verifytoken! },
body: formData,
},
).then((r) => r.text());
let loadedCheerio = parseHTML(body);
let novels: Plugin.NovelItem[] = [];
let results = JSON.parse(loadedCheerio("body").text());
loadedCheerio = parseHTML(results.resultview);
loadedCheerio(".novel-item").each((idx, ele) => {
const novelName = loadedCheerio(ele)
.find("h4.novel-title")
.text()
.trim();
const novelCover = loadedCheerio(ele).find("img").attr("src");
const novelUrl =
this.baseUrl + loadedCheerio(ele).find("a").attr("href")?.substring(1);
novels.push({
name: novelName,
url: novelUrl,
cover: novelCover,
});
});
return novels;
}
async fetchImage(url: string): Promise<string | undefined> {
return fetchFile(url, {headers: this.headers});
}
}
export default new LightNovelVN();
+161
View File
@@ -0,0 +1,161 @@
import { CheerioAPI, load as parseHTML } from "cheerio";
import { fetchApi, fetchFile } from "@libs/fetch";
import { Plugin } from "@typings/plugin";
import { Filters } from "@libs/filterInputs";
import { NovelStatus } from "@libs/novelStatus";
import { NovelItem } from "../../test_web/static/js";
interface SearchedNovel {
name: string;
slug: string;
coverUrl: string;
}
interface SearchedResult {
data?: SearchedNovel[]
}
class LightNovelVN implements Plugin.PagePlugin {
id = "lightnovel.vn";
name = "Light Novel VN";
version = "1.0.0";
icon = "src/vi/lightnovelvn/icon.png";
filters?: Filters | undefined;
site = "https://lightnovel.vn";
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions<Filters>): Promise<Plugin.NovelItem[]> {
const url = `${this.site}/truyen-hot-ds?page=${pageNo}`;
const body = await fetch(url).then((r) => r.text());
const loadedCheerio = parseHTML(body);
const novels: Plugin.NovelItem[] = [];
loadedCheerio(".flex.flex-col[itemtype='https://schema.org/Book']").each((idx, ele) => {
const novelName = loadedCheerio(ele).find('h3[itemprop="name"] > a').text().trim();
const img = loadedCheerio(ele).find('noscript').html();
const novelCover = img?.match(/srcSet="([^\s]+)/)?.[1];
const novelUrl = loadedCheerio(ele).find('h3[itemprop="name"] > a').attr('href');
if(novelUrl)
novels.push({
name: novelName,
cover: novelCover,
path: novelUrl.replace(this.site, ''),
});
});
return novels;
}
parseChapters(loadedCheerio: CheerioAPI){
const chapters: Plugin.ChapterItem[] = [];
loadedCheerio('ul.chapter-list > li').each((idx, ele) => {
const chNum = Number(loadedCheerio(ele).find('div').first().text());
const chapterUrl = loadedCheerio(ele).find('a').attr('href');
const name = loadedCheerio(ele).find('a').text().trim();
if(chapterUrl){
chapters.push({
path: chapterUrl.replace(this.site, ''),
name,
chapterNumber: chNum
})
}
})
return chapters;
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel & { totalPages: number; }> {
const url = this.site + novelPath;
const body = await fetch(url).then((r) => r.text());
let loadedCheerio = parseHTML(body);
const novel: Plugin.SourceNovel & { totalPages: number; } = {
path: novelPath,
chapters: [],
name: 'Không có tiêu đề',
totalPages: 1
};
novel.name = loadedCheerio('h1[itemprop="name"]').text().trim();
novel.cover = loadedCheerio('header div:nth-child(2) img').attr('srcset')?.split(/\s+/)[0]
const genres: string[] = [];
loadedCheerio('a[itemprop="genre"]').each(function() {
genres.push(loadedCheerio(this).text());
})
novel.genres = genres.join(',');
novel.status = loadedCheerio('span.font-bold.text-size22:last').text();
if(novel.status === 'Đang ra'){
novel.status = NovelStatus.Ongoing;
}else if(novel.status === 'Hoàn thành'){
novel.status = NovelStatus.Completed;
}else {
novel.status = NovelStatus.Unknown;
}
novel.author = loadedCheerio('a[itemprop="author"] > span').text();
novel.summary = loadedCheerio('#bookIntro').text().replace(/\s+/g, ' ');
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
await delay(1000);
const chapterListUrl = url + '/danh-sach-chuong';
const chapterListBody = await fetchApi(chapterListUrl).then(r => r.text());
const loadedChapterList = parseHTML(chapterListBody);
novel.chapters = this.parseChapters(loadedChapterList);
loadedChapterList('nav[aria-label="Pagination"] a').each((index, ele) => {
const href = ele.attribs['href'];
if(href){
const page = Number(href.match(/\?page=(\d+)/)?.[1]);
if(page && page > novel.totalPages){
novel.totalPages = page;
}
}
})
return novel;
}
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
const url = `${this.site}${novelPath}/danh-sach-chuong?page=${page}`;
const chapterListBody = await fetchApi(url).then(r => r.text());
const chapters = this.parseChapters(parseHTML(chapterListBody));
return {
chapters
}
}
async parseChapter(chapterPath: string): Promise<string> {
const body = await fetchApi(this.site + chapterPath).then((r) => r.text());
const loadedCheerio = parseHTML(body);
let chapterText = loadedCheerio("div.chapter-content").html() || '';
return chapterText;
}
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
if(pageNo > 1) return [];
const url = `${this.site}/api/book-search`;
let formData = new FormData();
formData.append("keyword", searchTerm);
const result: SearchedResult = await fetchApi(
url,
{
method: "POST",
body: formData,
},
).then((r) => r.json());
const novels: NovelItem[] = result.data?.map(item => {
return {
name: item.name,
path: '/truyen/' + item.slug,
cover: (this.site + item.coverUrl).replace('default.jpg', '150.jpg?w=256&q=')
}
}) || [];
return novels;
}
async fetchImage(url: string): Promise<string | undefined> {
return fetchFile(url);
}
}
export default new LightNovelVN();
+108
View File
@@ -0,0 +1,108 @@
import { fetchFile } from "@libs/fetch";
import { Filters } from "@libs/filterInputs";
import { NovelStatus } from "@libs/novelStatus";
import { Plugin } from "@typings/plugin";
import { CheerioAPI, load as parseHTML } from "cheerio";
class Nettruyen implements Plugin.PagePlugin {
id = 'nettruyen';
name = 'Nettruyen';
icon = 'src/vi/nettruyen/icon.png';
site = 'https://nettruyen.com.vn';
version = '1.0.0';
parseNovels(loadedCheerio: CheerioAPI){
const novels: Plugin.NovelItem[] = [];
loadedCheerio('#listchuong > ul > li > a.thumb').each((idx, ele) => {
const path = ele.attribs['href'];
if(!path) return;
const name = ele.attribs['title'];
const cover = this.site + '/' + loadedCheerio(ele).find('img').first().attr('src');
novels.push({
path: '/' + path,
name,
cover
})
})
return novels;
}
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions<Filters>): Promise<Plugin.NovelItem[]> {
const url = `${this.site}/xem-nhieu/trang-${pageNo}.html`;
const body = await fetch(url).then(r => r.text());
return this.parseNovels(parseHTML(body));
}
parseChapters(loadedCheerio: CheerioAPI){
const chapters: Plugin.ChapterItem[] = [];
loadedCheerio('ul.list-unstyled > li > a').each((idx, ele) => {
const path = ele.attribs['href'];
if(!path) return;
const name = ele.attribs['title'];
chapters.push({
path: '/' + path,
name,
chapterNumber: Number(name.match(/Chương (\d+)/)?.[1])
})
})
return chapters;
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel & { totalPages: number; }> {
const url = this.site + novelPath;
const body = await fetch(url).then(r => r.text());
const loadedCheerio = parseHTML(body);
const novel: Plugin.SourceNovel & { totalPages: number; } = {
path: novelPath,
name: loadedCheerio('.gioithieutruyen.profile-info > h1').text().trim(),
chapters: [],
totalPages: Number(loadedCheerio('.phantrang > span:nth-child(2)').text()) || 1,
}
novel.cover = this.site + '/' + loadedCheerio('.img-thumb > img').attr('src');
loadedCheerio('.thongtintruyen.note.note-info').each((idx, ele) => {
const strong = loadedCheerio(ele).find('strong').text().trim();
switch(strong){
case 'Tác giả':
novel.author = loadedCheerio(ele).text().replace(/Tác giả\s+\n?:/, '')
break;
case 'Trạng thái':
const text = loadedCheerio(ele).text();
if(text.includes('Đang ra')){
novel.status = NovelStatus.Ongoing;
}else if(text.includes('Hoàn thành')){
novel.status = NovelStatus.Completed;
}else {
novel.status = NovelStatus.Unknown;
}
break;
case 'Thể loại':
novel.genres = loadedCheerio('a > span').toArray().map((gEle) => loadedCheerio(gEle).text()).join(',');
break;
default:
break;
}
});
novel.summary = loadedCheerio('.gioithieutruyen > .gioithieutruyen').text().trim()
novel.chapters = this.parseChapters(loadedCheerio);
return novel;
}
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
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 chapters = this.parseChapters(parseHTML(body));
return {
chapters
}
}
async parseChapter(chapterPath: string): Promise<string> {
const url = this.site + chapterPath;
const body = await fetch(url).then(r => r.text());
const loadedCheerio = parseHTML(body);
return loadedCheerio('#noidungchap').html() || '';
}
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
throw new Error("Method not implemented.");
}
async fetchImage(url: string): Promise<string | undefined> {
return fetchFile(url);
}
}
export default new Nettruyen();
+147
View File
@@ -0,0 +1,147 @@
import { CheerioAPI, load as parseHTML } from "cheerio";
import { fetchFile } from "@libs/fetch";
import { Plugin } from "@typings/plugin";
import { Filters } from "@libs/filterInputs";
import { NovelStatus } from "@libs/novelStatus";
class TruyenFull implements Plugin.PagePlugin {
id = "truyenchu";
name = "Truyện Chữ";
icon = "src/vi/truyenchu/icon.png";
site = "https://truyenchu.vn";
version = "1.0.0";
parseNovels(loadedCheerio: CheerioAPI){
const novels: Plugin.NovelItem[] = [];
loadedCheerio(".list-truyen .row").each((idx, ele) => {
const novelName = loadedCheerio(ele)
.find("h3.truyen-title > a")
.text();
const novelCover = this.site + loadedCheerio(ele).find("div[data-classname='cover']").attr("data-image");
const novelUrl = loadedCheerio(ele)
.find("h3.truyen-title > a")
.attr("href");
if(novelUrl){
novels.push({
name: novelName,
cover: novelCover,
path: novelUrl.replace(this.site, '')
});
}
});
return novels;
}
parseChapters(html: string){
const listChapterHTML =
html.match(/("list_chapter":\s?\\{0}"(.+)\\{0}"),/)?.[1];
if(!listChapterHTML) throw new Error("Không tải được chương");
const listChapter = JSON.parse(`{${listChapterHTML}}`);
const loadedChapterList = parseHTML(listChapter.list_chapter);
const chapters: Plugin.ChapterItem[] = [];
loadedChapterList('ul > li > a').each((idx, ele) => {
const path = ele.attribs['href'].replace(this.site, '');
if(path){
chapters.push({
name: ele.attribs['title'],
path,
chapterNumber: Number(path.match(/\/chuong-(\d+)/)?.[1])
})
}
});
return chapters;
}
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions<Filters>): Promise<Plugin.NovelItem[]> {
const url = `${this.site}/danh-sach/truyen-hot?page=${pageNo}`;
const result = await fetch(url);
const body = await result.text();
const loadedCheerio = parseHTML(body);
return this.parseNovels(loadedCheerio);
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel & {totalPages: number}> {
const url = this.site + novelPath;
const result = await fetch(url);
const body = await result.text();
let loadedCheerio = parseHTML(body);
let lastPage = 1;
const regex = new RegExp(`${novelPath}\\?page=\\d+`, 'g');
body.match(regex)?.forEach(v => {
const page = Number(v.match(/\?page=(\d+)/)?.[1]);
if(page && page > lastPage){
lastPage = page;
}
});
const novel: Plugin.SourceNovel & {totalPages: number} = {
path: novelPath,
name: loadedCheerio("div.book > img").attr("alt") || 'Không có tiêu đề',
chapters: [],
totalPages: lastPage,
};
novel.cover = this.site + loadedCheerio("div.book > img").attr("src");
novel.summary = loadedCheerio("div.desc-text").text().trim();
novel.author = loadedCheerio('h3:contains("Tác giả:")')
.parent()
.contents()
.text()
.replace("Tác giả:", "");
novel.genres = loadedCheerio('h3:contains("Thể loại")')
.siblings()
.map((i, el) => loadedCheerio(el).text())
.toArray()
.join(",");
novel.status = loadedCheerio('h3:contains("Trạng thái")').next().text();
if(novel.status === "Full"){
novel.status = NovelStatus.Completed;
}else if(novel.status === 'Đang ra'){
novel.status = NovelStatus.Ongoing;
}else{
novel.status = NovelStatus.Unknown;
}
novel.chapters = this.parseChapters(body);
return novel;
}
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
const url = `${this.site}${novelPath}?page=${page}`;
const result = await fetch(url);
const body = await result.text();
const chapters = this.parseChapters(body);
return {
chapters
}
}
async parseChapter(chapterPath: string): Promise<string> {
const result = await fetch(this.site + chapterPath);
const body = await result.text();
const loadedCheerio = parseHTML(body);
let chapterText = (loadedCheerio(".chapter-title").html() || '') + (loadedCheerio('#chapter-c').html() || '');
return chapterText;
}
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
const searchUrl = `${this.site}/tim-kiem?tukhoa=${searchTerm}&page=${pageNo}`;
const result = await fetch(searchUrl);
const body = await result.text();
const loadedCheerio = parseHTML(body);
return this.parseNovels(loadedCheerio)
}
async fetchImage(url: string): Promise<string | undefined> {
return fetchFile(url);
}
}
export default new TruyenFull();
+37 -31
View File
@@ -4,7 +4,7 @@ import { Plugin } from "@typings/plugin";
import { Filters } from "@libs/filterInputs";
import { NovelStatus } from "@libs/novelStatus";
class TruyenFull implements Plugin.PluginBase {
class TruyenFull implements Plugin.PagePlugin {
id = "truyenfull";
name = "Truyện Full";
icon = "src/vi/truyenfull/icon.png";
@@ -27,13 +27,22 @@ class TruyenFull implements Plugin.PluginBase {
novels.push({
name: novelName,
cover: novelCover,
url: novelUrl
path: novelUrl.replace(this.site, '')
});
}
});
return novels;
}
parseChapters(loadedCheerio: CheerioAPI): Plugin.ChapterItem[]{
return loadedCheerio('ul.list-chapter > li > a').toArray().map((ele) => {
const path = ele.attribs['href'].replace(this.site, '');
return {
name: loadedCheerio(ele).text().trim(),
path,
chapterNumber: Number(path.match(/\/chuong-(\d+)\//)?.[1])
}
})
}
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions<Filters>): Promise<Plugin.NovelItem[]> {
const url = `${this.site}/danh-sach/truyen-hot/trang-${pageNo}/`;
@@ -44,21 +53,26 @@ class TruyenFull implements Plugin.PluginBase {
return this.parseNovels(loadedCheerio);
}
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
const url = novelUrl;
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel & {totalPages: number}> {
const url = this.site + novelPath;
const result = await fetch(url);
const body = await result.text();
let 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]);
if(page && page > lastPage) lastPage = page;
});
const novel: Plugin.SourceNovel = {
url,
const novel: Plugin.SourceNovel & {totalPages: number} = {
path: novelPath,
name: loadedCheerio("div.book > img").attr("alt") || 'Không có tiêu đề',
chapters: [],
totalPages: lastPage,
};
novel.name = loadedCheerio("div.book > img").attr("alt");
novel.cover = loadedCheerio("div.book > img").attr("src");
novel.summary = loadedCheerio("div.desc-text").text().trim();
@@ -83,30 +97,22 @@ class TruyenFull implements Plugin.PluginBase {
}else{
novel.status = NovelStatus.Unknown;
}
let lastPage = 1;
loadedCheerio('ul.pagination.pagination-sm > li').each(function() {
const page = Number(loadedCheerio(this).text());
if(page && page > lastPage) lastPage = page;
});
const lastPageUrl = novelUrl + 'trang-' + lastPage + '/';
const res = await fetch(lastPageUrl).then(res => res.text());
loadedCheerio = parseHTML(res);
const lastChapterUrl = loadedCheerio('ul.list-chapter > li:last-child > a').attr('href');
const lastChapter = Number(lastChapterUrl?.match(/\/chuong-(\d+)\//)?.[1]) || 1;
const chapters: Plugin.ChapterItem[] = [];
for(let i = 1; i <= lastChapter; i++){
chapters.push({
name: 'Chương ' + i,
url: novelUrl + 'chuong-'+ i + '/',
})
}
novel.chapters = chapters;
novel.chapters = this.parseChapters(loadedCheerio);
return novel;
}
async parseChapter(chapterUrl: string): Promise<string> {
const result = await fetch(chapterUrl);
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
const url = `${this.site}${novelPath}trang-${page}/#list-chapter`;
const result = await fetch(url);
const body = await result.text();
const loadedCheerio = parseHTML(body);
const chapters = this.parseChapters(loadedCheerio);
return {
chapters
}
}
async parseChapter(chapterPath: string): Promise<string> {
const result = await fetch(this.site + chapterPath);
const body = await result.text();
const loadedCheerio = parseHTML(body);