Prettier (#852)
* add prettier * lint-staged * prettier * upgrade husky
This commit is contained in:
+244
-234
@@ -1,259 +1,269 @@
|
||||
import { CheerioAPI, load as parseHTML } from "cheerio";
|
||||
import { fetchFile } from "@libs/fetch";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { isUrlAbsolute } from "@libs/isAbsoluteUrl";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||
import { fetchFile } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
import { isUrlAbsolute } from '@libs/isAbsoluteUrl';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
|
||||
class HakoPlugin implements Plugin.PluginBase {
|
||||
id = "ln.hako";
|
||||
name = "Hako";
|
||||
icon = "src/vi/hakolightnovel/icon.png";
|
||||
site = "https://ln.hako.vn";
|
||||
version = "1.0.1";
|
||||
parseNovels(loadedCheerio: CheerioAPI) {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio("#mainpart .row .thumb-item-flow").each((index, ele) => {
|
||||
let url = loadedCheerio(ele)
|
||||
.find("div.thumb_attr.series-title > a")
|
||||
.attr("href");
|
||||
id = 'ln.hako';
|
||||
name = 'Hako';
|
||||
icon = 'src/vi/hakolightnovel/icon.png';
|
||||
site = 'https://ln.hako.vn';
|
||||
version = '1.0.1';
|
||||
parseNovels(loadedCheerio: CheerioAPI) {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio('#mainpart .row .thumb-item-flow').each((index, ele) => {
|
||||
let url = loadedCheerio(ele)
|
||||
.find('div.thumb_attr.series-title > a')
|
||||
.attr('href');
|
||||
|
||||
if (url) {
|
||||
const name = loadedCheerio(ele)
|
||||
.find(".series-title")
|
||||
.text()
|
||||
.trim();
|
||||
let cover = loadedCheerio(ele)
|
||||
.find(".img-in-ratio")
|
||||
.attr("data-bg");
|
||||
if (url) {
|
||||
const name = loadedCheerio(ele).find('.series-title').text().trim();
|
||||
let cover = loadedCheerio(ele).find('.img-in-ratio').attr('data-bg');
|
||||
|
||||
if (cover && !isUrlAbsolute(cover)) {
|
||||
cover = this.site + cover;
|
||||
}
|
||||
if (cover && !isUrlAbsolute(cover)) {
|
||||
cover = this.site + cover;
|
||||
}
|
||||
|
||||
const novel = { name, path: url.replace(this.site, ''), cover };
|
||||
const novel = { name, path: url.replace(this.site, ''), cover };
|
||||
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
return novels;
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = this.site + '/danh-sach';
|
||||
if (filters.alphabet.value) {
|
||||
link += '/' + filters.alphabet.value;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{showLatestNovels, filters}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = this.site + "/danh-sach"
|
||||
if(filters.alphabet.value){
|
||||
link += "/" + filters.alphabet.value;
|
||||
}
|
||||
const params = new URLSearchParams();
|
||||
for(const novelType of filters.type.value){
|
||||
params.append(novelType, "1");
|
||||
}
|
||||
for(const status of filters.status.value){
|
||||
params.append(status, "1");
|
||||
}
|
||||
params.append("sapxep", filters.sort.value);
|
||||
link += '?' + params.toString() + '&page=' + pageNo
|
||||
const result = await fetch(link);
|
||||
const body = await result.text();
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio);
|
||||
const params = new URLSearchParams();
|
||||
for (const novelType of filters.type.value) {
|
||||
params.append(novelType, '1');
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: 'Không có tiêu đề',
|
||||
};
|
||||
const result = await fetch(this.site + novelPath);
|
||||
const body = await result.text();
|
||||
for (const status of filters.status.value) {
|
||||
params.append(status, '1');
|
||||
}
|
||||
params.append('sapxep', filters.sort.value);
|
||||
link += '?' + params.toString() + '&page=' + pageNo;
|
||||
const result = await fetch(link);
|
||||
const body = await result.text();
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio);
|
||||
}
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: 'Không có tiêu đề',
|
||||
};
|
||||
const result = await fetch(this.site + novelPath);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
novel.name = loadedCheerio(".series-name").text().trim();
|
||||
novel.name = loadedCheerio('.series-name').text().trim();
|
||||
|
||||
const background =
|
||||
loadedCheerio(".series-cover > .a6-ratio > div").attr("style") ||
|
||||
"";
|
||||
const novelCover = background.substring(
|
||||
background.indexOf("http"),
|
||||
background.length - 2
|
||||
);
|
||||
const background =
|
||||
loadedCheerio('.series-cover > .a6-ratio > div').attr('style') || '';
|
||||
const novelCover = background.substring(
|
||||
background.indexOf('http'),
|
||||
background.length - 2,
|
||||
);
|
||||
|
||||
novel.cover = novelCover
|
||||
? isUrlAbsolute(novelCover)
|
||||
? novelCover
|
||||
: this.site + novelCover
|
||||
: "";
|
||||
novel.cover = novelCover
|
||||
? isUrlAbsolute(novelCover)
|
||||
? novelCover
|
||||
: this.site + novelCover
|
||||
: '';
|
||||
|
||||
novel.summary = loadedCheerio(".summary-content").text().trim();
|
||||
novel.summary = loadedCheerio('.summary-content').text().trim();
|
||||
|
||||
novel.genres = loadedCheerio(".series-information > div:nth-child(1)")
|
||||
.text()
|
||||
.trim()
|
||||
.split(/\n[\s\n]*/).join(',');
|
||||
|
||||
novel.author = loadedCheerio('.series-information > div:nth-child(2) > .info-value')
|
||||
novel.genres = loadedCheerio('.series-information > div:nth-child(1)')
|
||||
.text()
|
||||
.trim()
|
||||
.split(/\n[\s\n]*/)
|
||||
.join(',');
|
||||
|
||||
novel.author = loadedCheerio(
|
||||
'.series-information > div:nth-child(2) > .info-value',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
novel.artist = loadedCheerio(
|
||||
'.series-information > div:nth-child(3) > .info-value',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.status = loadedCheerio(
|
||||
'.series-information > div:nth-child(4) > .info-value',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (novel.status) {
|
||||
case 'Đang tiến hành':
|
||||
novel.status = NovelStatus.Ongoing;
|
||||
break;
|
||||
case 'Tạm ngưng':
|
||||
novel.status = NovelStatus.OnHiatus;
|
||||
break;
|
||||
case 'Completed':
|
||||
novel.status = NovelStatus.Completed;
|
||||
break;
|
||||
default:
|
||||
novel.status = NovelStatus.Unknown;
|
||||
}
|
||||
|
||||
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();
|
||||
novel.artist = loadedCheerio('.series-information > div:nth-child(3) > .info-value')
|
||||
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()
|
||||
.trim();
|
||||
|
||||
novel.status = loadedCheerio('.series-information > div:nth-child(4) > .info-value')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (novel.status) {
|
||||
case 'Đang tiến hành':
|
||||
novel.status = NovelStatus.Ongoing;
|
||||
break;
|
||||
case 'Tạm ngưng':
|
||||
novel.status = NovelStatus.OnHiatus;
|
||||
break;
|
||||
case 'Completed':
|
||||
novel.status = NovelStatus.Completed;
|
||||
break;
|
||||
default:
|
||||
novel.status = NovelStatus.Unknown;
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
);
|
||||
}
|
||||
.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(chapterPath: string): Promise<string> {
|
||||
const result = await fetch(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
});
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetch(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio("#chapter-content").html() || "";
|
||||
const chapterText = loadedCheerio('#chapter-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + "/tim-kiem?keywords=" + searchTerm + '&page=' + pageNo;
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio);
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
const headers = {
|
||||
Referer: "https://ln.hako.vn",
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
}
|
||||
filters = {
|
||||
alphabet: {
|
||||
type: FilterTypes.Picker,
|
||||
value: "",
|
||||
label: "Chữ cái",
|
||||
options: [
|
||||
{label: 'Tất cả', value: ''},
|
||||
{label: 'Khác', value: 'khac'},
|
||||
{label: 'A', value: 'a'},
|
||||
{label: 'B', value: 'b'},
|
||||
{label: 'C', value: 'c'},
|
||||
{label: 'D', value: 'd'},
|
||||
{label: 'E', value: 'e'},
|
||||
{label: 'F', value: 'f'},
|
||||
{label: 'G', value: 'g'},
|
||||
{label: 'H', value: 'h'},
|
||||
{label: 'I', value: 'i'},
|
||||
{label: 'J', value: 'j'},
|
||||
{label: 'K', value: 'k'},
|
||||
{label: 'L', value: 'l'},
|
||||
{label: 'M', value: 'm'},
|
||||
{label: 'N', value: 'n'},
|
||||
{label: 'O', value: 'o'},
|
||||
{label: 'P', value: 'p'},
|
||||
{label: 'Q', value: 'q'},
|
||||
{label: 'R', value: 'r'},
|
||||
{label: 'S', value: 's'},
|
||||
{label: 'T', value: 't'},
|
||||
{label: 'U', value: 'u'},
|
||||
{label: 'V', value: 'v'},
|
||||
{label: 'W', value: 'w'},
|
||||
{label: 'X', value: 'x'},
|
||||
{label: 'Y', value: 'y'},
|
||||
{label: 'Z', value: 'z'},
|
||||
]
|
||||
},
|
||||
type: {
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
label: "Phân loại",
|
||||
value: [],
|
||||
options: [
|
||||
{label: "Truyện dịch", value: "truyendich"},
|
||||
{label: "Truyện sáng tác", value: "sangtac"},
|
||||
{label: "Convert", value: "convert"}
|
||||
]
|
||||
},
|
||||
status: {
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
label: "Tình trạng",
|
||||
value: [],
|
||||
options: [
|
||||
{label: "Đang tiến hành", value: "dangtienhanh"},
|
||||
{label: "Tạm ngưng", value: "tamngung"},
|
||||
{label: "Đã hoàn thành", value: "hoanthanh"}
|
||||
]
|
||||
},
|
||||
sort: {
|
||||
type: FilterTypes.Picker,
|
||||
label: "Sắp xếp",
|
||||
value: "top",
|
||||
options: [
|
||||
{label: "A-Z", value: "tentruyen"},
|
||||
{label: "Z-A", value: "tentruyenza"},
|
||||
{label: "Mới cập nhật", value: "capnhat"},
|
||||
{label: "Truyện mới", value: "truyenmoi"},
|
||||
{label: "Theo dõi", value: "theodoi"},
|
||||
{label: "Top toàn thời gian", value: "top"},
|
||||
{label: "Top tháng", value: "topthang"},
|
||||
{label: "Số từ", value: "sotu"},
|
||||
]
|
||||
}
|
||||
} satisfies Filters;
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url =
|
||||
this.site + '/tim-kiem?keywords=' + searchTerm + '&page=' + pageNo;
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio);
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
const headers = {
|
||||
Referer: 'https://ln.hako.vn',
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
}
|
||||
filters = {
|
||||
alphabet: {
|
||||
type: FilterTypes.Picker,
|
||||
value: '',
|
||||
label: 'Chữ cái',
|
||||
options: [
|
||||
{ label: 'Tất cả', value: '' },
|
||||
{ label: 'Khác', value: 'khac' },
|
||||
{ label: 'A', value: 'a' },
|
||||
{ label: 'B', value: 'b' },
|
||||
{ label: 'C', value: 'c' },
|
||||
{ label: 'D', value: 'd' },
|
||||
{ label: 'E', value: 'e' },
|
||||
{ label: 'F', value: 'f' },
|
||||
{ label: 'G', value: 'g' },
|
||||
{ label: 'H', value: 'h' },
|
||||
{ label: 'I', value: 'i' },
|
||||
{ label: 'J', value: 'j' },
|
||||
{ label: 'K', value: 'k' },
|
||||
{ label: 'L', value: 'l' },
|
||||
{ label: 'M', value: 'm' },
|
||||
{ label: 'N', value: 'n' },
|
||||
{ label: 'O', value: 'o' },
|
||||
{ label: 'P', value: 'p' },
|
||||
{ label: 'Q', value: 'q' },
|
||||
{ label: 'R', value: 'r' },
|
||||
{ label: 'S', value: 's' },
|
||||
{ label: 'T', value: 't' },
|
||||
{ label: 'U', value: 'u' },
|
||||
{ label: 'V', value: 'v' },
|
||||
{ label: 'W', value: 'w' },
|
||||
{ label: 'X', value: 'x' },
|
||||
{ label: 'Y', value: 'y' },
|
||||
{ label: 'Z', value: 'z' },
|
||||
],
|
||||
},
|
||||
type: {
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
label: 'Phân loại',
|
||||
value: [],
|
||||
options: [
|
||||
{ label: 'Truyện dịch', value: 'truyendich' },
|
||||
{ label: 'Truyện sáng tác', value: 'sangtac' },
|
||||
{ label: 'Convert', value: 'convert' },
|
||||
],
|
||||
},
|
||||
status: {
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
label: 'Tình trạng',
|
||||
value: [],
|
||||
options: [
|
||||
{ label: 'Đang tiến hành', value: 'dangtienhanh' },
|
||||
{ label: 'Tạm ngưng', value: 'tamngung' },
|
||||
{ label: 'Đã hoàn thành', value: 'hoanthanh' },
|
||||
],
|
||||
},
|
||||
sort: {
|
||||
type: FilterTypes.Picker,
|
||||
label: 'Sắp xếp',
|
||||
value: 'top',
|
||||
options: [
|
||||
{ label: 'A-Z', value: 'tentruyen' },
|
||||
{ label: 'Z-A', value: 'tentruyenza' },
|
||||
{ label: 'Mới cập nhật', value: 'capnhat' },
|
||||
{ label: 'Truyện mới', value: 'truyenmoi' },
|
||||
{ label: 'Theo dõi', value: 'theodoi' },
|
||||
{ label: 'Top toàn thời gian', value: 'top' },
|
||||
{ label: 'Top tháng', value: 'topthang' },
|
||||
{ label: 'Số từ', value: 'sotu' },
|
||||
],
|
||||
},
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new HakoPlugin();
|
||||
|
||||
+284
-272
@@ -1,299 +1,311 @@
|
||||
|
||||
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";
|
||||
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
|
||||
story: string;
|
||||
navigation: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface ChapterSelect {
|
||||
chap_selector: string;
|
||||
eps_selector: boolean | string;
|
||||
chap_selector: string;
|
||||
eps_selector: boolean | string;
|
||||
}
|
||||
|
||||
interface VolumeList {
|
||||
chapters: Plugin.ChapterItem[],
|
||||
volumes?: VolumeData[]
|
||||
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'),
|
||||
})
|
||||
}
|
||||
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;
|
||||
}
|
||||
});
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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),
|
||||
);
|
||||
}
|
||||
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();
|
||||
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;
|
||||
}
|
||||
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();
|
||||
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();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
let chapterText = loadedCheerio('.reading-content').html() || '';
|
||||
|
||||
const novel: Plugin.SourceNovel & { totalPages: number; }= {
|
||||
name: loadedCheerio(".post-title > h1").text().trim(),
|
||||
path: novelPath,
|
||||
chapters: [],
|
||||
totalPages: 1
|
||||
};
|
||||
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();
|
||||
|
||||
novel.cover = loadedCheerio(".summary_image > a > img").attr(
|
||||
"data-src"
|
||||
);
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".post-content_item").each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find(".summary-heading > h5")
|
||||
.text()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this).find(".summary-content").html();
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
if (!detail) return;
|
||||
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'];
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
if (!novelUrl) return;
|
||||
|
||||
loadedCheerio(
|
||||
".description-summary > div.summary__content > div"
|
||||
).remove();
|
||||
novels.push({
|
||||
name: novelName,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
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;
|
||||
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();
|
||||
|
||||
+162
-145
@@ -1,161 +1,178 @@
|
||||
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";
|
||||
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;
|
||||
name: string;
|
||||
slug: string;
|
||||
coverUrl: string;
|
||||
}
|
||||
interface SearchedResult {
|
||||
data?: SearchedNovel[]
|
||||
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, ''),
|
||||
});
|
||||
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 novels;
|
||||
}
|
||||
});
|
||||
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;
|
||||
}
|
||||
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());
|
||||
novel.author = loadedCheerio('a[itemprop="author"] > span').text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
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 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;
|
||||
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;
|
||||
}
|
||||
novel.author = loadedCheerio('a[itemprop="author"] > span').text();
|
||||
}
|
||||
});
|
||||
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());
|
||||
|
||||
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 loadedCheerio = parseHTML(body);
|
||||
|
||||
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));
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
export default new LightNovelVN();
|
||||
|
||||
+123
-105
@@ -1,108 +1,126 @@
|
||||
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";
|
||||
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);
|
||||
}
|
||||
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();
|
||||
export default new Nettruyen();
|
||||
|
||||
+142
-130
@@ -1,147 +1,159 @@
|
||||
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";
|
||||
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";
|
||||
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();
|
||||
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 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, '')
|
||||
});
|
||||
}
|
||||
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 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;
|
||||
}
|
||||
});
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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();
|
||||
|
||||
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();
|
||||
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();
|
||||
|
||||
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,
|
||||
};
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
novel.cover = this.site + loadedCheerio("div.book > img").attr("src");
|
||||
let chapterText =
|
||||
(loadedCheerio('.chapter-title').html() || '') +
|
||||
(loadedCheerio('#chapter-c').html() || '');
|
||||
|
||||
novel.summary = loadedCheerio("div.desc-text").text().trim();
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const searchUrl = `${this.site}/tim-kiem?tukhoa=${searchTerm}&page=${pageNo}`;
|
||||
|
||||
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);
|
||||
}
|
||||
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();
|
||||
|
||||
+133
-122
@@ -1,139 +1,150 @@
|
||||
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";
|
||||
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 = "truyenfull";
|
||||
name = "Truyện Full";
|
||||
icon = "src/vi/truyenfull/icon.png";
|
||||
site = "https://truyenfull.vn";
|
||||
version = "1.0.0";
|
||||
id = 'truyenfull';
|
||||
name = 'Truyện Full';
|
||||
icon = 'src/vi/truyenfull/icon.png';
|
||||
site = 'https://truyenfull.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();
|
||||
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 = loadedCheerio(ele).find("div[data-classname='cover']").attr("data-image");
|
||||
const novelCover = 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, '')
|
||||
});
|
||||
}
|
||||
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(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}/`;
|
||||
|
||||
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;
|
||||
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 & {totalPages: number} = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio("div.book > img").attr("alt") || 'Không có tiêu đề',
|
||||
chapters: [],
|
||||
totalPages: lastPage,
|
||||
};
|
||||
|
||||
novel.cover = 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(loadedCheerio);
|
||||
return novel;
|
||||
}
|
||||
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 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 {
|
||||
chapters
|
||||
}
|
||||
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}/`;
|
||||
|
||||
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;
|
||||
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 & { totalPages: number } = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio('div.book > img').attr('alt') || 'Không có tiêu đề',
|
||||
chapters: [],
|
||||
totalPages: lastPage,
|
||||
};
|
||||
|
||||
novel.cover = 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;
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetch(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
novel.chapters = this.parseChapters(loadedCheerio);
|
||||
return novel;
|
||||
}
|
||||
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 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();
|
||||
|
||||
let chapterText = (loadedCheerio(".chapter-title").html() || '') + (loadedCheerio('#chapter-c').html() || '');
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const searchUrl = `${this.site}/tim-kiem?tukhoa=${searchTerm}&page=${pageNo}`;
|
||||
let chapterText =
|
||||
(loadedCheerio('.chapter-title').html() || '') +
|
||||
(loadedCheerio('#chapter-c').html() || '');
|
||||
|
||||
const result = await fetch(searchUrl);
|
||||
const body = await result.text();
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const searchUrl = `${this.site}/tim-kiem?tukhoa=${searchTerm}&page=${pageNo}`;
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio)
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user