Update faqwikius.ts (#850)
* Update faqwikius.ts * fix id and faqwiki * wrong branch
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
import { Plugin } from "@typings/plugin";
|
import { Plugin } from "@typings/plugin";
|
||||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||||
import { CheerioAPI, load as parseHTML } from "cheerio";
|
import { CheerioAPI, load as parseHTML } from "cheerio";
|
||||||
|
import { NovelStatus } from "@libs/novelStatus";
|
||||||
|
|
||||||
class FaqWikiUs implements Plugin.PluginBase {
|
class FaqWikiUs implements Plugin.PluginBase {
|
||||||
id = "FWK.US";
|
id = "FWK.US";
|
||||||
name = "Faq Wiki";
|
name = "Faq Wiki";
|
||||||
site = "https://faqwiki.us/";
|
site = "https://faqwiki.us/";
|
||||||
version = "1.1.0";
|
version = "1.1.1";
|
||||||
icon = "src/en/faqwikius/icon.png";
|
icon = "src/en/faqwikius/icon.png";
|
||||||
|
|
||||||
parseNovels(loadedCheerio:CheerioAPI, searchTerm?: string) {
|
parseNovels(loadedCheerio:CheerioAPI, searchTerm?: string) {
|
||||||
@@ -18,10 +19,12 @@ class FaqWikiUs implements Plugin.PluginBase {
|
|||||||
|
|
||||||
// Remove the appended query string
|
// Remove the appended query string
|
||||||
if (cover) {
|
if (cover) {
|
||||||
cover = cover.replace(/\?ezimgfmt=.*$/, ''); // Regular expression magic!
|
cover = cover.replace(/\?ezimgfmt=.*$/, ''); // Regular expression magic!
|
||||||
|
} else {
|
||||||
|
cover = loadedCheerio(element).find("img").attr("src");
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = loadedCheerio(element).find("a").attr("href")?.slice(this.site.length);
|
const path = loadedCheerio(element).find("a").attr("href")?.replace('tp:', 'tps:')?.slice(this.site.length);
|
||||||
if (!path) return;
|
if (!path) return;
|
||||||
|
|
||||||
novels.push({ name, cover, path });
|
novels.push({ name, cover, path });
|
||||||
@@ -58,9 +61,33 @@ class FaqWikiUs implements Plugin.PluginBase {
|
|||||||
|
|
||||||
novel.name = loadedCheerio(".entry-title").text().replace("Novel – All Chapters", "").trim();
|
novel.name = loadedCheerio(".entry-title").text().replace("Novel – All Chapters", "").trim();
|
||||||
|
|
||||||
novel.cover = loadedCheerio(".wp-block-image").find("img").attr("src");
|
novel.cover = loadedCheerio(".wp-block-image")
|
||||||
|
.find("img")
|
||||||
|
.attr("data-ezsrc")
|
||||||
|
?.replace(/\?ezimgfmt=.*$/, ''); // Regular expression magic!
|
||||||
|
|
||||||
|
const status = loadedCheerio("#lcp_instance_0 +:icontains('complete')").text();
|
||||||
|
novel.status = (status ? NovelStatus.Completed : NovelStatus.Ongoing)
|
||||||
|
|
||||||
novel.summary = loadedCheerio(".book-review-block__meta-item-value").text().trim();
|
const div = loadedCheerio(".book-review-block__meta-item-value");
|
||||||
|
|
||||||
|
div.html(div.html()?.replace(/(?<=>)([^<]+)(?=<br\s*\/?>)/g, '<p>$1</p>')!);
|
||||||
|
|
||||||
|
loadedCheerio(".book-review-block__meta-item-value strong").each((i,el) => {
|
||||||
|
const key = loadedCheerio(el).text().replace(':', '').trim().toLowerCase();
|
||||||
|
const value = loadedCheerio(el).next().text().replace(':', '').trim();
|
||||||
|
|
||||||
|
switch(key){
|
||||||
|
case "description":
|
||||||
|
novel.summary = value;
|
||||||
|
break;
|
||||||
|
case "author(s)":
|
||||||
|
novel.author = value;
|
||||||
|
break;
|
||||||
|
case "genre":
|
||||||
|
novel.genres = value.split(' ').join(',');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const chapters: Plugin.ChapterItem[] = loadedCheerio(".lcp_catlist > li > a")
|
const chapters: Plugin.ChapterItem[] = loadedCheerio(".lcp_catlist > li > a")
|
||||||
.map((chapterIndex, element) => ({
|
.map((chapterIndex, element) => ({
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ class IndoWebNovel implements Plugin.PluginBase {
|
|||||||
id = "IDWN.id";
|
id = "IDWN.id";
|
||||||
name = "IndoWebNovel";
|
name = "IndoWebNovel";
|
||||||
icon = "src/id/indowebnovel/icon.png";
|
icon = "src/id/indowebnovel/icon.png";
|
||||||
site = "https://indowebnovel.id/id/";
|
site = "https://indowebnovel.id/";
|
||||||
version = "1.1.0";
|
version = "1.2.0";
|
||||||
|
|
||||||
parseNovels(loadedCheerio:CheerioAPI){
|
parseNovels(loadedCheerio:CheerioAPI){
|
||||||
const novels: Plugin.NovelItem[] = [];
|
const novels: Plugin.NovelItem[] = [];
|
||||||
@@ -28,7 +28,7 @@ class IndoWebNovel implements Plugin.PluginBase {
|
|||||||
novels.push({
|
novels.push({
|
||||||
name: novelName,
|
name: novelName,
|
||||||
cover: novelCover,
|
cover: novelCover,
|
||||||
path: novelUrl.replace(this.site, ''),
|
path: novelUrl.slice(this.site.length),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ class IndoWebNovel implements Plugin.PluginBase {
|
|||||||
|
|
||||||
chapters.push({
|
chapters.push({
|
||||||
name: chapterName,
|
name: chapterName,
|
||||||
path: chapterUrl.replace(this.site, ''),
|
path: chapterUrl.slice(this.site.length),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -108,10 +108,14 @@ class IndoWebNovel implements Plugin.PluginBase {
|
|||||||
return chapterText;
|
return chapterText;
|
||||||
}
|
}
|
||||||
|
|
||||||
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]> {
|
async searchNovels(searchTerm: string, page: number): Promise<Plugin.NovelItem[]> {
|
||||||
const url = `${this.site}daftar-novel/`;
|
let link = `${this.site}advanced-search/page/${page}/?title=${searchTerm}&author=&yearx=`;
|
||||||
|
link += `&status=${this.filters.status.value}`
|
||||||
|
link += `&type=${this.filters.type.value}`;
|
||||||
|
link += `&order=${this.filters.sort.value}`;
|
||||||
|
link += this.filters.lang.value.map((i) => `&country[]=${i}`).join("");
|
||||||
|
|
||||||
const result = await fetchApi(url);
|
const result = await fetchApi(link);
|
||||||
const body = await result.text();
|
const body = await result.text();
|
||||||
|
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class SakuraNovel implements Plugin.PluginBase {
|
|||||||
name = "SakuraNovel";
|
name = "SakuraNovel";
|
||||||
icon = "src/id/sakuranovel/icon.png";
|
icon = "src/id/sakuranovel/icon.png";
|
||||||
site = "https://sakuranovel.id/";
|
site = "https://sakuranovel.id/";
|
||||||
version = "1.0.0";
|
version = "1.0.1";
|
||||||
|
|
||||||
parseNovels(loadedCheerio:CheerioAPI){
|
parseNovels(loadedCheerio:CheerioAPI){
|
||||||
const novels: Plugin.NovelItem[] = [];
|
const novels: Plugin.NovelItem[] = [];
|
||||||
@@ -79,30 +79,35 @@ class SakuraNovel implements Plugin.PluginBase {
|
|||||||
.toArray()
|
.toArray()
|
||||||
.join(",");
|
.join(",");
|
||||||
|
|
||||||
|
const imageTitle = novel.cover?.split('/').pop()?.split('-').join(' ').split('.')[0];
|
||||||
|
const chapterTitle = novel.name.replace(/\(LN\)|\(WN\)/, "").split(',')[0].trim();
|
||||||
const chapter: Plugin.ChapterItem[] = [];
|
const chapter: Plugin.ChapterItem[] = [];
|
||||||
|
|
||||||
loadedCheerio(".series-chapterlist li").each((i,el) => {
|
loadedCheerio(".series-flexright li").each((i,el) => {
|
||||||
const chapterName = loadedCheerio(el)
|
const chapterName = loadedCheerio(el)
|
||||||
.find("a span")
|
.find("a span")
|
||||||
.first()
|
.first()
|
||||||
.text()
|
.text()
|
||||||
.replace(/.*?(Chapter.|[0-9])/g, "$1")
|
.replace(chapterTitle, '')
|
||||||
.replace(/Bahasa Indonesia/g, "")
|
.replace(imageTitle!, '')
|
||||||
|
.replace(/Bahasa Indonesia/, '')
|
||||||
.replace(/\s+/g, " ")
|
.replace(/\s+/g, " ")
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
const releaseDate = loadedCheerio(el)
|
const releaseDate = loadedCheerio(el)
|
||||||
.find("a span")
|
.find(".date")
|
||||||
.first()
|
.text()
|
||||||
.next()
|
.trim()
|
||||||
.text();
|
.split('/')
|
||||||
|
.map(x => Number(x));
|
||||||
|
|
||||||
const chapterUrl = loadedCheerio(el).find("a").attr("href");
|
const chapterUrl = loadedCheerio(el).find("a").attr("href");
|
||||||
|
|
||||||
if (!chapterUrl) return;
|
if (!chapterUrl) return;
|
||||||
|
|
||||||
chapter.push({
|
chapter.push({
|
||||||
name: chapterName,
|
name: chapterName,
|
||||||
releaseTime: releaseDate,
|
releaseTime: new Date(releaseDate[2], releaseDate[1], releaseDate[0]).toISOString(),
|
||||||
path: chapterUrl.replace(this.site, ''),
|
path: chapterUrl.replace(this.site, ''),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user