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:
+202
-103
@@ -1,52 +1,34 @@
|
||||
import { load as cheerioload } from "cheerio";
|
||||
import { CheerioAPI, load as parseHTML} from "cheerio";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { fetchFile } from "@libs/fetch";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { FilterTypes, Filters } from "@libs/filterInputs";
|
||||
|
||||
class BLN implements Plugin.PluginBase {
|
||||
id = "BLN.com";
|
||||
id = "BLN";
|
||||
name = "BestLightNovel";
|
||||
icon = "src/en/bestlightnovel/icon.png";
|
||||
site = "https://bestlightnovel.com/";
|
||||
filter?: undefined;
|
||||
version = "1.0.0";
|
||||
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
options: Plugin.PopularNovelsOptions
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url =
|
||||
this.site +
|
||||
"novel_list?type=topview&category=all&state=all&page=1" +
|
||||
|
||||
|
||||
const result = await fetch(url);
|
||||
if (!result.ok) {
|
||||
console.error(await result.text());
|
||||
// TODO: Cloudflare protection or other error
|
||||
return [];
|
||||
}
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio(".update_item.list_category").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h3 > a").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
parseNovels(loadedCheerio: CheerioAPI) {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio(".update_item.list_category").each((i,el) => {
|
||||
const novelUrl = loadedCheerio(el).find("h3 > a").attr("href");
|
||||
if (!novelUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No novel url!");
|
||||
return;
|
||||
}
|
||||
|
||||
const novelName = loadedCheerio(el).find("h3 > a").text();
|
||||
const novelCover = loadedCheerio(el).find("img").attr("src");
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
name: novelName,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
cover: novelCover,
|
||||
};
|
||||
|
||||
@@ -55,126 +37,243 @@ class BLN implements Plugin.PluginBase {
|
||||
|
||||
return novels;
|
||||
}
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = this.site + "novel_list?"
|
||||
link += 'type=' + filters.type.value;
|
||||
link += '&category=' + filters.category.value;
|
||||
link += '&state=' + filters.status.value;
|
||||
link += '&page=' + page;
|
||||
|
||||
const result = await fetch(link);
|
||||
if (!result.ok) {
|
||||
console.error(await result.text());
|
||||
console.error(await result.text());
|
||||
// TODO: Cloudflare protection
|
||||
// TODO: Cloudflare protection or other error
|
||||
return [];
|
||||
}
|
||||
const body = await result.text();
|
||||
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio);
|
||||
}
|
||||
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
url,
|
||||
name: "",
|
||||
cover: "",
|
||||
author: "",
|
||||
status: NovelStatus.Unknown,
|
||||
genres: "",
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetch(this.site + novelPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
path: novelPath,
|
||||
name: loadedCheerio(".truyen_info_right h1").text().trim() || "",
|
||||
cover: loadedCheerio(".info_image img").attr("src") || defaultCover,
|
||||
summary: loadedCheerio("#noidungm").text()?.trim() || "",
|
||||
chapters: [],
|
||||
};
|
||||
loadedCheerio('ul.truyen_info_right > li').each(function() {
|
||||
const detailName = loadedCheerio(this).find('span').text();
|
||||
const detail = loadedCheerio(this)
|
||||
.find('a')
|
||||
.map((a,ex) => loadedCheerio(ex).text())
|
||||
.toArray()
|
||||
.join(', ');
|
||||
|
||||
switch(detailName) {
|
||||
case "Author(s): ":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "GENRES: ":
|
||||
novel.genres = detail;
|
||||
break;
|
||||
case "STATUS : ":
|
||||
novel.status =
|
||||
detail === "Ongoing"
|
||||
? NovelStatus.Ongoing
|
||||
: detail === "Completed"
|
||||
? NovelStatus.Completed
|
||||
: NovelStatus.Unknown;
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
novel.name = loadedCheerio(".truyen_info_right h1").text().trim();
|
||||
novel.cover =
|
||||
loadedCheerio(".info_image img").attr("src") || defaultCover;
|
||||
novel.summary = loadedCheerio("#noidungm").text()?.trim();
|
||||
novel.author = loadedCheerio(
|
||||
"#main_body > div.cotgiua > div.truyen_info_wrapper > div.truyen_info > div.entry-header > div.truyen_if_wrap > ul > li:nth-child(2) > a"
|
||||
)
|
||||
.text()
|
||||
const chapter: Plugin.ChapterItem[] = [];
|
||||
|
||||
|
||||
let status = loadedCheerio(
|
||||
"#main_body > div.cotgiua > div.truyen_info_wrapper > div.truyen_info > div.entry-header > div.truyen_if_wrap > ul > li:nth-child(4) > a"
|
||||
)
|
||||
.text()
|
||||
?.trim();
|
||||
|
||||
novel.status =
|
||||
status === "ONGOING"
|
||||
? NovelStatus.Ongoing
|
||||
: status === "COMPLETED"
|
||||
? NovelStatus.Completed
|
||||
: NovelStatus.Unknown;
|
||||
|
||||
let novelChapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio(".chapter-list div.row").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
const releaseDate = loadedCheerio(this)
|
||||
loadedCheerio(".chapter-list div.row").each((i, el) => {
|
||||
const chapterName = loadedCheerio(el).find("a").text().trim();
|
||||
const releaseDate = loadedCheerio(el)
|
||||
.find("span:last")
|
||||
.text()
|
||||
.trim();
|
||||
.trim();
|
||||
|
||||
const months = [
|
||||
"jan",
|
||||
"feb",
|
||||
"mar",
|
||||
"apr",
|
||||
"may",
|
||||
"jun",
|
||||
"jul",
|
||||
"aug",
|
||||
"sep",
|
||||
"oct",
|
||||
"nov",
|
||||
"dec",
|
||||
].join("|");
|
||||
const rx = new RegExp(`(${months})-(\\d{1,2})-(\\d{2})`,'i')
|
||||
.exec(releaseDate);
|
||||
if (!rx) return;
|
||||
const year = 2000 + +rx[3];
|
||||
const month = months.indexOf(rx[1].toLowerCase());
|
||||
const day = +rx[2];
|
||||
|
||||
const chapterUrl = loadedCheerio(el).find("a").attr("href");
|
||||
if (!chapterUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No chapter url!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
releaseTime: new Date(year, month, day).toISOString(),
|
||||
path: chapterUrl.replace(this.site, ''),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
}
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
|
||||
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetch(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio("#vung_doc").html() || "";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
searchTerm: string,
|
||||
page: number
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}search_novels/${searchTerm}?page=${page}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
|
||||
let loadedCheerio = cheerioload(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio(".update_item.list_category").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h3 > a").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h3 > a").attr("href");
|
||||
|
||||
if (!novelUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No novel url!");
|
||||
return;
|
||||
}
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio);
|
||||
}
|
||||
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url);
|
||||
}
|
||||
|
||||
filters = {
|
||||
status: {
|
||||
label: "Status",
|
||||
value: "all",
|
||||
options: [
|
||||
{ label: "ALL", value: "all" },
|
||||
{ label: "Completed", value: "completed" },
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
type: {
|
||||
value: "topview",
|
||||
label: "Type",
|
||||
options: [
|
||||
{ label: "Recently updated", value: "latest" },
|
||||
{ label: "Newest", value: "newest" },
|
||||
{ label: "Top view", value: "topview" },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
category: {
|
||||
label: "Category",
|
||||
value: "all",
|
||||
options: [
|
||||
{ label: "ALL", value: "all" },
|
||||
{ label: "Action", value: "1" },
|
||||
{ label: "Adventure", value: "2" },
|
||||
{ label: "Animals", value: "65" },
|
||||
{ label: "Arts", value: "40" },
|
||||
{ label: "Biographies", value: "41" },
|
||||
{ label: "Business", value: "42" },
|
||||
{ label: "Chinese", value: "3" },
|
||||
{ label: "Comedy", value: "4" },
|
||||
{ label: "Computers", value: "43" },
|
||||
{ label: "Crafts, Hobbies", value: "45" },
|
||||
{ label: "Drama", value: "5" },
|
||||
{ label: "Education", value: "46" },
|
||||
{ label: "English", value: "6" },
|
||||
{ label: "Entertainment", value: "47" },
|
||||
{ label: "Fantasy", value: "7" },
|
||||
{ label: "Fiction", value: "48" },
|
||||
{ label: "Gender Bender", value: "8" },
|
||||
{ label: "Harem", value: "9" },
|
||||
{ label: "Historical", value: "10" },
|
||||
{ label: "History", value: "49" },
|
||||
{ label: "Home", value: "50" },
|
||||
{ label: "Horror", value: "11" },
|
||||
{ label: "Humor", value: "51" },
|
||||
{ label: "Investing", value: "52" },
|
||||
{ label: "Josei", value: "12" },
|
||||
{ label: "Korean", value: "13" },
|
||||
{ label: "Literature", value: "53" },
|
||||
{ label: "Lolicon", value: "14" },
|
||||
{ label: "Martial Arts", value: "15" },
|
||||
{ label: "Mature", value: "16" },
|
||||
{ label: "Mecha", value: "17" },
|
||||
{ label: "Memoirs", value: "54" },
|
||||
{ label: "Mystery", value: "18" },
|
||||
{ label: "Original", value: "19" },
|
||||
{ label: "Other Books", value: "66" },
|
||||
{ label: "Philosophy", value: "55" },
|
||||
{ label: "Photography", value: "56" },
|
||||
{ label: "Politics", value: "57" },
|
||||
{ label: "Professional", value: "58" },
|
||||
{ label: "Psychological", value: "20" },
|
||||
{ label: "Reference", value: "59" },
|
||||
{ label: "Reincarnation", value: "21" },
|
||||
{ label: "Religion", value: "60" },
|
||||
{ label: "Romance", value: "22" },
|
||||
{ label: "School Life", value: "23" },
|
||||
{ label: "School Stories", value: "67" },
|
||||
{ label: "Sci-Fi", value: "24" },
|
||||
{ label: "Seinen", value: "25" },
|
||||
{ label: "Short Stories", value: "68" },
|
||||
{ label: "Shotacon", value: "26" },
|
||||
{ label: "Shoujo", value: "27" },
|
||||
{ label: "Shoujo Ai", value: "28" },
|
||||
{ label: "Shounen", value: "29" },
|
||||
{ label: "Shounen Ai", value: "30" },
|
||||
{ label: "Slice Of Life", value: "31" },
|
||||
{ label: "Smut", value: "32" },
|
||||
{ label: "Social Science", value: "61" },
|
||||
{ label: "Spirituality", value: "62" },
|
||||
{ label: "Sports", value: "33" },
|
||||
{ label: "Supernatural", value: "34" },
|
||||
{ label: "Teaser", value: "69" },
|
||||
{ label: "Technical", value: "63" },
|
||||
{ label: "Technology", value: "64" },
|
||||
{ label: "Tragedy", value: "35" },
|
||||
{ label: "Virtual Reality", value: "36" },
|
||||
{ label: "Wuxia", value: "37" },
|
||||
{ label: "Xianxia", value: "38" },
|
||||
{ label: "Xuanhuan", value: "39" },
|
||||
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new BLN();
|
||||
|
||||
Reference in New Issue
Block a user