diff --git a/plugins/russian/jaomix.ts b/plugins/russian/jaomix.ts index ad1db0ffa..78eedbec4 100644 --- a/plugins/russian/jaomix.ts +++ b/plugins/russian/jaomix.ts @@ -2,14 +2,14 @@ import { Plugin } from '@/types/plugin'; import { FilterTypes, Filters } from '@libs/filterInputs'; import { fetchApi } from '@libs/fetch'; import { NovelStatus } from '@libs/novelStatus'; -import { load as parseHTML } from 'cheerio'; +import { load as parseHTML, CheerioAPI } from 'cheerio'; import dayjs from 'dayjs'; -class Jaomix implements Plugin.PluginBase { +class Jaomix implements Plugin.PagePlugin { id = 'jaomix.ru'; name = 'Jaomix'; site = 'https://jaomix.ru'; - version = '1.0.2'; + version = '1.0.3'; icon = 'src/ru/jaomix/icon.png'; async popularNovels( @@ -72,15 +72,18 @@ class Jaomix implements Plugin.PluginBase { return novels; } - async parseNovel(novelPath: string): Promise { + async parseNovel( + novelPath: string, + ): Promise { const body = await fetchApi(this.site + novelPath).then(res => res.text()); const loadedCheerio = parseHTML(body); - const novel: Plugin.SourceNovel = { + const novel: Plugin.SourceNovel & { totalPages: number } = { path: novelPath, name: loadedCheerio('div[class="desc-book"] > h1').text().trim(), cover: loadedCheerio('div[class="img-book"] > img').attr('src'), summary: loadedCheerio('div[id="desc-tab"]').text().trim(), + totalPages: loadedCheerio('.sel-toc > option').length, }; loadedCheerio('#info-book > p').each(function () { @@ -95,9 +98,34 @@ class Jaomix implements Plugin.PluginBase { : NovelStatus.Completed; } }); + novel.chapters = this.parseChapters(loadedCheerio); + return novel; + } + + async parsePage(novelPath: string, page: string): Promise { + const body = await fetchApi(`${this.site}/wp-admin/admin-ajax.php`, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + Referer: this.site + novelPath, + Origin: this.site, + }, + body: new URLSearchParams({ + action: 'loadpagenavchapstt', + page, + }).toString(), + }).then(data => data.text()); + + const loadedCheerio = parseHTML(body); + const chapters = this.parseChapters(loadedCheerio); + return { + chapters, + }; + } + + parseChapters(loadedCheerio: CheerioAPI) { const chapters: Plugin.ChapterItem[] = []; - const totalChapters = loadedCheerio('div.title').length; loadedCheerio('div.title').each((chapterIndex, element) => { const name = loadedCheerio(element).find('a').attr('title'); @@ -109,12 +137,10 @@ class Jaomix implements Plugin.PluginBase { name, path: url.replace(this.site, ''), releaseTime: this.parseDate(releaseDate), - chapterNumber: totalChapters - chapterIndex, }); }); - novel.chapters = chapters.reverse(); - return novel; + return chapters; } async parseChapter(chapterPath: string): Promise { diff --git a/public/static/multisrc/fictioneer/novelib/icon.png b/public/static/multisrc/fictioneer/novelib/icon.png index e08bee797..fc2193bcf 100644 Binary files a/public/static/multisrc/fictioneer/novelib/icon.png and b/public/static/multisrc/fictioneer/novelib/icon.png differ diff --git a/public/static/multisrc/madara/markazriwayat/icon.png b/public/static/multisrc/madara/markazriwayat/icon.png index 170540453..a2f829263 100644 Binary files a/public/static/multisrc/madara/markazriwayat/icon.png and b/public/static/multisrc/madara/markazriwayat/icon.png differ diff --git a/icons/src/en/novelrest/icon.png b/public/static/src/en/novelrest/icon.png similarity index 100% rename from icons/src/en/novelrest/icon.png rename to public/static/src/en/novelrest/icon.png