Migrate Indonesian plugins (#836)
* unbreak ID * just in case * Update plugins/indonesian/novelringan.ts Co-authored-by: nyagami <hoangquan05112002@gmail.com> --------- Co-authored-by: nyagami <hoangquan05112002@gmail.com>
This commit is contained in:
@@ -1,47 +1,55 @@
|
||||
import { CheerioAPI, load, load as parseHTML } from "cheerio";
|
||||
import { CheerioAPI, 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";
|
||||
import { Filters, FilterTypes } 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";
|
||||
parseNovels(loadedCheerio:CheerioAPI, searchTerm?: string) {
|
||||
let novels: Plugin.NovelItem[] = [];
|
||||
version = "1.1.0";
|
||||
|
||||
loadedCheerio(".novellist-blc li").each((i,el) => {
|
||||
const novelName = loadedCheerio(el).find("a").text();
|
||||
const novelCover = defaultCover;
|
||||
const novelUrl = loadedCheerio(el).find("a").attr("href");
|
||||
parseNovels(loadedCheerio:CheerioAPI){
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
if (!novelUrl || !novelName) return;
|
||||
loadedCheerio(".flexbox2-item").each((i,el) => {
|
||||
const novelName = loadedCheerio(el)
|
||||
.find(".flexbox2-title span")
|
||||
.first()
|
||||
.text();
|
||||
const novelCover = loadedCheerio(el).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(el)
|
||||
.find(".flexbox2-content > a")
|
||||
.attr("href");
|
||||
|
||||
const novel = {
|
||||
if (!novelUrl) return;
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
});
|
||||
|
||||
if (searchTerm) {
|
||||
novels = novels.filter((novel) =>
|
||||
novel.name.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
);
|
||||
}
|
||||
return novels;
|
||||
};
|
||||
}
|
||||
|
||||
async popularNovels(pageNo: number, options: Plugin.PopularNovelsOptions<Filters>): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}daftar-novel/`;
|
||||
async popularNovels(
|
||||
page: number,
|
||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}advanced-search/page/${page}/?title=&author=&yearx=`;
|
||||
link += `&status=${filters.status.value}`
|
||||
link += `&type=${filters.type.value}`;
|
||||
link += `&order=${filters.sort.value}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
if (filters.lang.value.length)
|
||||
link += filters.lang.value.map((i) => `&country[]=${i}`).join("");
|
||||
if (filters.genre.value.length)
|
||||
link += filters.genre.value.map((i) => `&genre[]=${i}`).join("");
|
||||
|
||||
const result = await fetchApi(link);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -107,13 +115,96 @@ class IndoWebNovel implements Plugin.PluginBase {
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio, searchTerm)
|
||||
return this.parseNovels(loadedCheerio)
|
||||
}
|
||||
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
|
||||
filters = {
|
||||
status: {
|
||||
value: "",
|
||||
label: "Status",
|
||||
options: [
|
||||
{ label: "All", value: "" },
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
type: {
|
||||
value: "",
|
||||
label: "Type",
|
||||
options: [
|
||||
{ label: "All", value: "" },
|
||||
{ label: "Web Novel", value: "Web+Novel" },
|
||||
{ label: "Light Novel", value: "Light+Novel" },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
sort: {
|
||||
value: "rating",
|
||||
label: "Order By",
|
||||
options: [
|
||||
{ label: "A-Z", value: "title" },
|
||||
{ label: "Z-A", value: "titlereverse" },
|
||||
{ label: "Latest Update", value: "update" },
|
||||
{ label: "Latest Added", value: "latest" },
|
||||
{ label: "Popular", value: "popular" },
|
||||
{ label: "Rating", value: "rating" },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
lang: {
|
||||
value: ['china','jepang','korea','unknown'],
|
||||
label: "Country",
|
||||
options: [
|
||||
{ label: "China", value: "china" },
|
||||
{ label: "Jepang", value: "jepang" },
|
||||
{ label: "Korea", value: "korea" },
|
||||
{ label: "Unknown", value: "unknown" },
|
||||
],
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
genre: {
|
||||
value: [],
|
||||
label: "Genres",
|
||||
options: [
|
||||
{ label: "Action", value: "action" },
|
||||
{ label: "Adult", value: "adult" },
|
||||
{ label: "Adventure", value: "adventure" },
|
||||
{ label: "Comedy", value: "comedy" },
|
||||
{ label: "Drama", value: "drama" },
|
||||
{ label: "Ecchi", value: "ecchi" },
|
||||
{ label: "Fantasy", value: "fantasy" },
|
||||
{ label: "Gender Bender", value: "gender-bender" },
|
||||
{ label: "Harem", value: "harem" },
|
||||
{ label: "Horror", value: "horror" },
|
||||
{ label: "Josei", value: "josei" },
|
||||
{ label: "Josei", value: "josei" },
|
||||
{ label: "Martial Arts", value: "martial-arts" },
|
||||
{ label: "Mature", value: "mature" },
|
||||
{ label: "Mecha", value: "mecha" },
|
||||
{ label: "Mystery", value: "mystery" },
|
||||
{ label: "Psychological", value: "psychological" },
|
||||
{ label: "Romance", value: "romance" },
|
||||
{ label: "School Life", value: "school-life" },
|
||||
{ label: "Sci-fi", value: "sci-fi" },
|
||||
{ label: "Seinen", value: "seinen" },
|
||||
{ label: "Shoujo", value: "shoujo" },
|
||||
{ label: "Shounen", value: "shounen" },
|
||||
{ label: "Slice of Life", value: "slice-of-life" },
|
||||
{ label: "Smut", value: "smut" },
|
||||
{ label: "Supernatural", value: "supernatural" },
|
||||
{ label: "Tragedy", value: "tragedy" },
|
||||
{ label: "Wuxia", value: "wuxia" },
|
||||
{ label: "Xianxia", value: "xianxia" },
|
||||
{ label: "Xuanhuan", value: "xuanhuan" }
|
||||
],
|
||||
type: FilterTypes.CheckboxGroup,
|
||||
},
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
export default new IndoWebNovel();
|
||||
|
||||
Reference in New Issue
Block a user