Fix: non-english broken plugins (#701)
* fix epiknovel * fix: hasutl * fix: Novelas Ligera * fix: ReinoWuxia * fix: Oasis * fix: json script * fix: Skynovels * fix: Yuuki Tls * fix: Agitoon * fix: Syosetu * fix: IndoWebNovel * fix: Novel Ringan * fix: Sakura Novel * fix: Hako * minor: type checking when PRing
This commit is contained in:
@@ -1,143 +0,0 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
export const id = "IDWN.id";
|
||||
export const name = "IndoWebNovel";
|
||||
export const site = "https://indowebnovel.id/id/";
|
||||
export const icon = "src/id/indowebnovel/icon.png";
|
||||
export const version = "1.0.0";
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}daftar-novel/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".novellist-blc li").each(function () {
|
||||
const novelName = loadedCheerio(this).find("a").text();
|
||||
const novelCover = defaultCover;
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!novelUrl || !novelName) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
url,
|
||||
name: "",
|
||||
cover: "",
|
||||
author: "",
|
||||
status: "",
|
||||
genres: "",
|
||||
summary: "",
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".series-title").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio(".series-thumb > img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio(".series-synops").text().trim();
|
||||
|
||||
novel.status = loadedCheerio(".status").text().trim();
|
||||
|
||||
const genres: string[] = [];
|
||||
|
||||
loadedCheerio(".series-genres").each(function () {
|
||||
genres.push(loadedCheerio(this).find("a").text().trim());
|
||||
});
|
||||
|
||||
novel.genres = genres.join(",");
|
||||
|
||||
let chapters: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".series-chapterlist li").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio(".reader").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}daftar-novel/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".novellist-blc li").each(function () {
|
||||
const novelName = loadedCheerio(this).find("a").text();
|
||||
const novelCover = defaultCover;
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
if (novelName.toLowerCase().includes(searchTerm.toLowerCase())) {
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -0,0 +1,146 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { Filters } from "@libs/filterInputs";
|
||||
|
||||
class IndoWebNovel implements Plugin.PluginBase {
|
||||
id = "IDWN.id";
|
||||
name = "IndoWebNovel";
|
||||
icon = "src/id/indowebnovel/icon.png";
|
||||
site = "https://indowebnovel.id/id/";
|
||||
filters?: Filters | undefined;
|
||||
version = "1.0.0";
|
||||
baseUrl = this.site
|
||||
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions<Filters>): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.baseUrl}daftar-novel/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio(".novellist-blc li").each(function () {
|
||||
const novelName = loadedCheerio(this).find("a").text();
|
||||
const novelCover = defaultCover;
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!novelUrl || !novelName) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
url,
|
||||
name: "",
|
||||
cover: "",
|
||||
author: "",
|
||||
status: "",
|
||||
genres: "",
|
||||
summary: "",
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".series-title").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio(".series-thumb > img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio(".series-synops").text().trim();
|
||||
|
||||
novel.status = loadedCheerio(".status").text().trim();
|
||||
|
||||
const genres: string[] = [];
|
||||
|
||||
loadedCheerio(".series-genres").each(function () {
|
||||
genres.push(loadedCheerio(this).find("a").text().trim());
|
||||
});
|
||||
|
||||
novel.genres = genres.join(",");
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio(".series-chapterlist li").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio(".readerss").html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.baseUrl}daftar-novel/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio(".novellist-blc li").each(function () {
|
||||
const novelName = loadedCheerio(this).find("a").text();
|
||||
const novelCover = defaultCover;
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
if (novelName.toLowerCase().includes(searchTerm.toLowerCase())) {
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new IndoWebNovel();
|
||||
@@ -1,159 +0,0 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "novelringan.com";
|
||||
export const name = "NovelRingan";
|
||||
export const site = "https://novelringan.com/";
|
||||
export const icon = "src/id/novelringan/icon.png";
|
||||
export const version = "1.0.0";
|
||||
|
||||
const baseUrl = site;
|
||||
const coverUriPrefix = "https://i0.wp.com/novelringan.com/wp-content/uploads/";
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}/top-novel/page/${page}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.post").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".entry-title")
|
||||
.text()
|
||||
?.trim();
|
||||
const novelCover =
|
||||
coverUriPrefix + loadedCheerio(this).find("img").attr("data-sxrx");
|
||||
const novelUrl = loadedCheerio(this).find("h2 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
url,
|
||||
name: "",
|
||||
cover: "",
|
||||
genres: "",
|
||||
author: "",
|
||||
status: NovelStatus.Unknown,
|
||||
summary: "",
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".entry-title").text()?.trim();
|
||||
novel.cover =
|
||||
coverUriPrefix +
|
||||
loadedCheerio("img.ts-post-image").attr("data-sxrx");
|
||||
novel.summary = loadedCheerio(
|
||||
"body > div.site-container > div > main > article > div > div.maininfo > span > p"
|
||||
).text();
|
||||
|
||||
let genreSelector = loadedCheerio(
|
||||
"body > div.site-container > div > main > article > div > div.maininfo > span > ul > li:nth-child(4)"
|
||||
).text();
|
||||
|
||||
novel.genres = genreSelector.includes("Genre")
|
||||
? genreSelector.replace("Genre:", "").trim()
|
||||
: "";
|
||||
|
||||
let statusSelector = loadedCheerio(
|
||||
"body > div.site-container > div > main > article > div > div.maininfo > span > ul > li:nth-child(3)"
|
||||
).text();
|
||||
|
||||
novel.status = statusSelector.includes("Status")
|
||||
? statusSelector.replace("Status:", "").trim()
|
||||
: NovelStatus.Unknown;
|
||||
|
||||
let chapters: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".bxcl > ul > li").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
};
|
||||
|
||||
chapters.push(chapter);
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.entry-content div[style="display:none"]').remove();
|
||||
|
||||
const chapterText = loadedCheerio(".entry-content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = baseUrl + "?s=" + searchTerm;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.post").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".entry-title").text();
|
||||
const novelCover =
|
||||
coverUriPrefix + loadedCheerio(this).find("img").attr("data-sxrx");
|
||||
|
||||
const novelUrl = loadedCheerio(this).find("h2 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -0,0 +1,163 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { Filters } from "@libs/filterInputs";
|
||||
|
||||
class NovelRingan implements Plugin.PluginBase {
|
||||
id = "novelringan.com";
|
||||
name = "NovelRingan";
|
||||
icon = "src/id/novelringan/icon.png";
|
||||
site = "https://novelringan.com/";
|
||||
filters?: Filters | undefined;
|
||||
version = "1.0.0";
|
||||
baseUrl = this.site;
|
||||
coverUriPrefix = "https://i0.wp.com/novelringan.com/wp-content/uploads/";
|
||||
|
||||
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions<Filters>): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.baseUrl}/top-novel/page/${pageNo}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio("article.post").each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele)
|
||||
.find(".entry-title")
|
||||
.text()
|
||||
?.trim();
|
||||
const novelCover =
|
||||
this.coverUriPrefix + loadedCheerio(ele).find("img").attr("data-sxrx");
|
||||
const novelUrl = loadedCheerio(ele).find("h2 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
url,
|
||||
name: "",
|
||||
cover: "",
|
||||
genres: "",
|
||||
author: "",
|
||||
status: NovelStatus.Unknown,
|
||||
summary: "",
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".entry-title").text()?.trim();
|
||||
novel.cover =
|
||||
this.coverUriPrefix +
|
||||
loadedCheerio("img.ts-post-image").attr("data-sxrx");
|
||||
novel.summary = loadedCheerio(
|
||||
"body > div.site-container > div > main > article > div > div.maininfo > span > p"
|
||||
).text();
|
||||
|
||||
let genreSelector = loadedCheerio(
|
||||
"body > div.site-container > div > main > article > div > div.maininfo > span > ul > li:nth-child(4)"
|
||||
).text();
|
||||
|
||||
novel.genres = genreSelector.includes("Genre")
|
||||
? genreSelector.replace("Genre:", "").trim()
|
||||
: "";
|
||||
|
||||
let statusSelector = loadedCheerio(
|
||||
"body > div.site-container > div > main > article > div > div.maininfo > span > ul > li:nth-child(3)"
|
||||
).text();
|
||||
|
||||
novel.status = statusSelector.includes("Status")
|
||||
? statusSelector.replace("Status:", "").trim()
|
||||
: NovelStatus.Unknown;
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio(".bxcl > ul > li").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
};
|
||||
|
||||
chapters.push(chapter);
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.entry-content div[style="display:none"]').remove();
|
||||
|
||||
const chapterText = loadedCheerio(".entry-content").html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.baseUrl + "?s=" + searchTerm;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio("article.post").each((idx, ele) => {
|
||||
const novelName = loadedCheerio(ele).find(".entry-title").text();
|
||||
const novelCover =
|
||||
this.coverUriPrefix + loadedCheerio(ele).find("img").attr("data-sxrx");
|
||||
|
||||
const novelUrl = loadedCheerio(ele).find("h2 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new NovelRingan();
|
||||
@@ -1,156 +0,0 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "sakura.id";
|
||||
export const name = "SakuraNovel";
|
||||
export const site = "https://sakuranovel.id/";
|
||||
export const icon = "src/id/sakuranovel/icon.png";
|
||||
export const version = "1.0.0";
|
||||
|
||||
const pluginId = id;
|
||||
const sourceName = name;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}advanced-search/page/${page}/?title&author&yearx&status&type&order=rating&country%5B0%5D=china&country%5B1%5D=jepang&country%5B2%5D=unknown`;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".flexbox2-item").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".flexbox2-title span")
|
||||
.first()
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".flexbox2-content > a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const result = await fetchApi(novelUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
name: sourceName,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".series-title h2").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio(".series-thumb img").attr("src");
|
||||
|
||||
loadedCheerio(".series-infolist > li").each(function () {
|
||||
const detailName = loadedCheerio(this).find("b").text().trim();
|
||||
const detail = loadedCheerio(this).find("b").next().text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Author":
|
||||
novel.author = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.status = loadedCheerio(".status").text().trim();
|
||||
|
||||
novel.genres = loadedCheerio(".series-genres")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
loadedCheerio(".series-synops div").remove();
|
||||
novel.summary = loadedCheerio(".series-synops").text().trim();
|
||||
|
||||
let chapters: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".series-chapterlist li").each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find("a span")
|
||||
.first()
|
||||
.text()
|
||||
.replace(/.*?(Chapter.|[0-9])/g, "$1")
|
||||
.replace(/Bahasa Indonesia/g, "")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find("a span")
|
||||
.first()
|
||||
.next()
|
||||
.text();
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio(".readers").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}?s=${searchTerm}`;
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".flexbox2-item").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".flexbox2-title span")
|
||||
.first()
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".flexbox2-content > a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -0,0 +1,156 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { Filters } from "@libs/filterInputs";
|
||||
|
||||
class SakuraNovel implements Plugin.PluginBase {
|
||||
id = "sakura.id";
|
||||
name = "SakuraNovel";
|
||||
icon = "src/id/sakuranovel/icon.png";
|
||||
site = "https://sakuranovel.id/";
|
||||
filters?: Filters | undefined;
|
||||
version = "1.0.0";
|
||||
baseUrl = this.site;
|
||||
|
||||
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions<Filters>): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.baseUrl}advanced-search/page/${pageNo}/?title&author&yearx&status&type&order=rating&country%5B0%5D=china&country%5B1%5D=jepang&country%5B2%5D=unknown`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio(".flexbox2-item").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".flexbox2-title span")
|
||||
.first()
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".flexbox2-content > a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".series-title h2").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio(".series-thumb img").attr("src");
|
||||
|
||||
loadedCheerio(".series-infolist > li").each(function () {
|
||||
const detailName = loadedCheerio(this).find("b").text().trim();
|
||||
const detail = loadedCheerio(this).find("b").next().text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Author":
|
||||
novel.author = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.status = loadedCheerio(".status").text().trim();
|
||||
|
||||
novel.genres = loadedCheerio(".series-genres")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
loadedCheerio(".series-synops div").remove();
|
||||
novel.summary = loadedCheerio(".series-synops").text().trim();
|
||||
|
||||
let chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
loadedCheerio(".series-chapterlist li").each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find("a span")
|
||||
.first()
|
||||
.text()
|
||||
.replace(/.*?(Chapter.|[0-9])/g, "$1")
|
||||
.replace(/Bahasa Indonesia/g, "")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find("a span")
|
||||
.first()
|
||||
.next()
|
||||
.text();
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio(".readerss").html() || '';
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.baseUrl}?s=${searchTerm}`;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio(".flexbox2-item").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".flexbox2-title span")
|
||||
.first()
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".flexbox2-content > a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new SakuraNovel();
|
||||
Reference in New Issue
Block a user