react-native-consumet 2.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/consumet/HttpRequestModule.kt +88 -33
- package/android/src/main/java/com/consumet/WebViewTask.kt +18 -3
- package/ios/Consumet.mm +172 -72
- package/lib/commonjs/NativeConsumet.ts +11 -5
- package/lib/commonjs/extension-registry.json +6 -6
- package/lib/commonjs/extension-registry.json.sig +1 -1
- package/lib/commonjs/extractors/kwik.js +28 -29
- package/lib/commonjs/extractors/kwik.js.map +1 -1
- package/lib/commonjs/index.js +18 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/types.js +6 -0
- package/lib/commonjs/models/types.js.map +1 -1
- package/lib/commonjs/providers/anime/animepahe/create-animepahe.js +12 -13
- package/lib/commonjs/providers/anime/animepahe/create-animepahe.js.map +1 -1
- package/lib/commonjs/providers/manga/asurascans.js +160 -96
- package/lib/commonjs/providers/manga/asurascans.js.map +1 -1
- package/lib/commonjs/providers/manga/flamescans.js +173 -91
- package/lib/commonjs/providers/manga/flamescans.js.map +1 -1
- package/lib/commonjs/providers/manga/index.js +1 -15
- package/lib/commonjs/providers/manga/index.js.map +1 -1
- package/lib/commonjs/providers/manga/mangadex.js +234 -227
- package/lib/commonjs/providers/manga/mangadex.js.map +1 -1
- package/lib/commonjs/providers/manga/mangahere.js +279 -135
- package/lib/commonjs/providers/manga/mangahere.js.map +1 -1
- package/lib/commonjs/providers/manga/mangakakalot.js +206 -107
- package/lib/commonjs/providers/manga/mangakakalot.js.map +1 -1
- package/lib/commonjs/providers/manga/mangapill.js +126 -38
- package/lib/commonjs/providers/manga/mangapill.js.map +1 -1
- package/lib/commonjs/providers/meta/anilist.js +41 -12
- package/lib/commonjs/providers/meta/anilist.js.map +1 -1
- package/lib/commonjs/utils/index.js +19 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/manga.js +60 -0
- package/lib/commonjs/utils/manga.js.map +1 -0
- package/lib/module/NativeConsumet.ts +11 -5
- package/lib/module/extension-registry.json +6 -6
- package/lib/module/extension-registry.json.sig +1 -1
- package/lib/module/extractors/kwik.js +28 -29
- package/lib/module/extractors/kwik.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/types.js +9 -0
- package/lib/module/models/types.js.map +1 -1
- package/lib/module/providers/anime/animepahe/create-animepahe.js +12 -13
- package/lib/module/providers/anime/animepahe/create-animepahe.js.map +1 -1
- package/lib/module/providers/manga/asurascans.js +161 -96
- package/lib/module/providers/manga/asurascans.js.map +1 -1
- package/lib/module/providers/manga/flamescans.js +174 -91
- package/lib/module/providers/manga/flamescans.js.map +1 -1
- package/lib/module/providers/manga/index.js +1 -15
- package/lib/module/providers/manga/index.js.map +1 -1
- package/lib/module/providers/manga/mangadex.js +236 -228
- package/lib/module/providers/manga/mangadex.js.map +1 -1
- package/lib/module/providers/manga/mangahere.js +276 -132
- package/lib/module/providers/manga/mangahere.js.map +1 -1
- package/lib/module/providers/manga/mangakakalot.js +207 -107
- package/lib/module/providers/manga/mangakakalot.js.map +1 -1
- package/lib/module/providers/manga/mangapill.js +128 -39
- package/lib/module/providers/manga/mangapill.js.map +1 -1
- package/lib/module/providers/meta/anilist.js +41 -12
- package/lib/module/providers/meta/anilist.js.map +1 -1
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/manga.js +54 -0
- package/lib/module/utils/manga.js.map +1 -0
- package/lib/typescript/commonjs/src/NativeConsumet.d.ts +11 -5
- package/lib/typescript/commonjs/src/NativeConsumet.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/kwik.d.ts +1 -1
- package/lib/typescript/commonjs/src/extractors/kwik.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/types.d.ts +38 -5
- package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/manga/asurascans.d.ts +14 -4
- package/lib/typescript/commonjs/src/providers/manga/asurascans.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/manga/flamescans.d.ts +18 -3
- package/lib/typescript/commonjs/src/providers/manga/flamescans.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/manga/index.d.ts +0 -14
- package/lib/typescript/commonjs/src/providers/manga/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/manga/mangadex.d.ts +22 -5
- package/lib/typescript/commonjs/src/providers/manga/mangadex.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/manga/mangahere.d.ts +15 -3
- package/lib/typescript/commonjs/src/providers/manga/mangahere.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/manga/mangakakalot.d.ts +26 -4
- package/lib/typescript/commonjs/src/providers/manga/mangakakalot.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/manga/mangapill.d.ts +16 -2
- package/lib/typescript/commonjs/src/providers/manga/mangapill.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/manga.d.ts +19 -0
- package/lib/typescript/commonjs/src/utils/manga.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeConsumet.d.ts +11 -5
- package/lib/typescript/module/src/NativeConsumet.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/kwik.d.ts +1 -1
- package/lib/typescript/module/src/extractors/kwik.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +2 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/models/types.d.ts +38 -5
- package/lib/typescript/module/src/models/types.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/manga/asurascans.d.ts +14 -4
- package/lib/typescript/module/src/providers/manga/asurascans.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/manga/flamescans.d.ts +18 -3
- package/lib/typescript/module/src/providers/manga/flamescans.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/manga/index.d.ts +0 -14
- package/lib/typescript/module/src/providers/manga/index.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/manga/mangadex.d.ts +22 -5
- package/lib/typescript/module/src/providers/manga/mangadex.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/manga/mangahere.d.ts +15 -3
- package/lib/typescript/module/src/providers/manga/mangahere.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/manga/mangakakalot.d.ts +26 -4
- package/lib/typescript/module/src/providers/manga/mangakakalot.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/manga/mangapill.d.ts +16 -2
- package/lib/typescript/module/src/providers/manga/mangapill.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/meta/anilist.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/index.d.ts +1 -0
- package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/manga.d.ts +19 -0
- package/lib/typescript/module/src/utils/manga.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/NativeConsumet.ts +11 -5
- package/src/extension-registry.json +6 -6
- package/src/extension-registry.json.sig +1 -1
- package/src/extractors/kwik.ts +30 -43
- package/src/index.tsx +6 -0
- package/src/models/types.ts +38 -3
- package/src/providers/anime/animepahe/create-animepahe.ts +15 -14
- package/src/providers/manga/asurascans.ts +200 -135
- package/src/providers/manga/flamescans.ts +221 -118
- package/src/providers/manga/index.ts +0 -14
- package/src/providers/manga/mangadex.ts +335 -282
- package/src/providers/manga/mangahere.ts +309 -156
- package/src/providers/manga/mangakakalot.ts +249 -152
- package/src/providers/manga/mangapill.ts +163 -64
- package/src/providers/meta/anilist.ts +50 -14
- package/src/utils/index.ts +1 -0
- package/src/utils/manga.ts +58 -0
- package/lib/commonjs/providers/manga/brmangas.js +0 -110
- package/lib/commonjs/providers/manga/brmangas.js.map +0 -1
- package/lib/commonjs/providers/manga/comick.js +0 -154
- package/lib/commonjs/providers/manga/comick.js.map +0 -1
- package/lib/commonjs/providers/manga/mangahost.js +0 -113
- package/lib/commonjs/providers/manga/mangahost.js.map +0 -1
- package/lib/commonjs/providers/manga/mangapark.js +0 -97
- package/lib/commonjs/providers/manga/mangapark.js.map +0 -1
- package/lib/commonjs/providers/manga/mangareader.js +0 -106
- package/lib/commonjs/providers/manga/mangareader.js.map +0 -1
- package/lib/commonjs/providers/manga/mangasee123.js +0 -161
- package/lib/commonjs/providers/manga/mangasee123.js.map +0 -1
- package/lib/commonjs/providers/manga/readmanga.js +0 -269
- package/lib/commonjs/providers/manga/readmanga.js.map +0 -1
- package/lib/commonjs/providers/manga/vyvymanga.js +0 -166
- package/lib/commonjs/providers/manga/vyvymanga.js.map +0 -1
- package/lib/module/providers/manga/brmangas.js +0 -105
- package/lib/module/providers/manga/brmangas.js.map +0 -1
- package/lib/module/providers/manga/comick.js +0 -149
- package/lib/module/providers/manga/comick.js.map +0 -1
- package/lib/module/providers/manga/mangahost.js +0 -108
- package/lib/module/providers/manga/mangahost.js.map +0 -1
- package/lib/module/providers/manga/mangapark.js +0 -92
- package/lib/module/providers/manga/mangapark.js.map +0 -1
- package/lib/module/providers/manga/mangareader.js +0 -101
- package/lib/module/providers/manga/mangareader.js.map +0 -1
- package/lib/module/providers/manga/mangasee123.js +0 -156
- package/lib/module/providers/manga/mangasee123.js.map +0 -1
- package/lib/module/providers/manga/readmanga.js +0 -264
- package/lib/module/providers/manga/readmanga.js.map +0 -1
- package/lib/module/providers/manga/vyvymanga.js +0 -161
- package/lib/module/providers/manga/vyvymanga.js.map +0 -1
- package/lib/typescript/commonjs/src/providers/manga/brmangas.d.ts +0 -18
- package/lib/typescript/commonjs/src/providers/manga/brmangas.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/providers/manga/comick.d.ts +0 -39
- package/lib/typescript/commonjs/src/providers/manga/comick.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/providers/manga/mangahost.d.ts +0 -18
- package/lib/typescript/commonjs/src/providers/manga/mangahost.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/providers/manga/mangapark.d.ts +0 -14
- package/lib/typescript/commonjs/src/providers/manga/mangapark.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/providers/manga/mangareader.d.ts +0 -18
- package/lib/typescript/commonjs/src/providers/manga/mangareader.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/providers/manga/mangasee123.d.ts +0 -17
- package/lib/typescript/commonjs/src/providers/manga/mangasee123.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/providers/manga/readmanga.d.ts +0 -31
- package/lib/typescript/commonjs/src/providers/manga/readmanga.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/providers/manga/vyvymanga.d.ts +0 -17
- package/lib/typescript/commonjs/src/providers/manga/vyvymanga.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/manga/brmangas.d.ts +0 -18
- package/lib/typescript/module/src/providers/manga/brmangas.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/manga/comick.d.ts +0 -39
- package/lib/typescript/module/src/providers/manga/comick.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/manga/mangahost.d.ts +0 -18
- package/lib/typescript/module/src/providers/manga/mangahost.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/manga/mangapark.d.ts +0 -14
- package/lib/typescript/module/src/providers/manga/mangapark.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/manga/mangareader.d.ts +0 -18
- package/lib/typescript/module/src/providers/manga/mangareader.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/manga/mangasee123.d.ts +0 -17
- package/lib/typescript/module/src/providers/manga/mangasee123.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/manga/readmanga.d.ts +0 -31
- package/lib/typescript/module/src/providers/manga/readmanga.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/manga/vyvymanga.d.ts +0 -17
- package/lib/typescript/module/src/providers/manga/vyvymanga.d.ts.map +0 -1
- package/src/providers/manga/brmangas.ts +0 -148
- package/src/providers/manga/comick.ts +0 -285
- package/src/providers/manga/mangahost.ts +0 -134
- package/src/providers/manga/mangapark.ts +0 -115
- package/src/providers/manga/mangareader.ts +0 -132
- package/src/providers/manga/mangasee123.ts +0 -187
- package/src/providers/manga/readmanga.ts +0 -380
- package/src/providers/manga/vyvymanga.ts +0 -237
|
@@ -7,10 +7,36 @@ exports.MangaKakalot = void 0;
|
|
|
7
7
|
var _cheerio = require("cheerio");
|
|
8
8
|
var _index = require("../../models/index.js");
|
|
9
9
|
var _createProviderContext = require("../../utils/create-provider-context.js");
|
|
10
|
+
var _manga = require("../../utils/manga.js");
|
|
11
|
+
/** One chapter as the site's chapter-list API (`/api/manga/<slug>/chapters`) returns it. */
|
|
12
|
+
|
|
13
|
+
// The chapter-list API pages through a title's chapters, newest first. The site's own page asks
|
|
14
|
+
// for 50 at a time; 500 keeps long series to a few requests (Cloudflare blocks `limit=1000`).
|
|
15
|
+
const CHAPTERS_PER_REQUEST = 500;
|
|
16
|
+
const MAX_CHAPTER_REQUESTS = 40;
|
|
17
|
+
/** Titles per search page, in both the HTML and the JSON form. */
|
|
18
|
+
const SEARCH_PAGE_SIZE = 20;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The search word the site's own search box sends: punctuation and spaces become `_`, which the
|
|
22
|
+
* site reads as a space (`Re:Zero` → `re_zero`).
|
|
23
|
+
*/
|
|
24
|
+
const searchWord = query => query.toLowerCase().replace(/[\s!-/:-@[-`{-~]+/g, '_').replace(/^_+|_+$/g, '');
|
|
25
|
+
|
|
26
|
+
/** `2024-11-03T11:37:28.000000Z` (the API's microseconds) → `2024-11-03T11:37:28.000Z`. */
|
|
27
|
+
const toIsoDate = value => {
|
|
28
|
+
if (!value) return undefined;
|
|
29
|
+
const match = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d+))?Z$/.exec(value.trim());
|
|
30
|
+
if (match) return `${match[1]}.${(match[2] ?? '').padEnd(3, '0').slice(0, 3)}Z`;
|
|
31
|
+
const time = Date.parse(value);
|
|
32
|
+
return Number.isNaN(time) ? value : new Date(time).toISOString();
|
|
33
|
+
};
|
|
10
34
|
class MangaKakalot extends _index.MangaParser {
|
|
11
35
|
name = 'MangaKakalot';
|
|
12
|
-
|
|
13
|
-
|
|
36
|
+
// mangakakalot.com is gone; mangakakalot.gg redirects here, and manganato.gg is the same site
|
|
37
|
+
// (same titles, ids and image hosts) under another name.
|
|
38
|
+
baseUrl = 'https://www.kakamanga.com';
|
|
39
|
+
logo = 'https://www.kakamanga.com/images/svg/logo-kkl.svg';
|
|
14
40
|
classPath = 'MANGA.MangaKakalot';
|
|
15
41
|
|
|
16
42
|
/** @param ctx provider context; requests go through its axios (default: `createProviderContext()`) */
|
|
@@ -18,122 +44,195 @@ class MangaKakalot extends _index.MangaParser {
|
|
|
18
44
|
super();
|
|
19
45
|
this.ctx = ctx;
|
|
20
46
|
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Covers and pages are on 2xstorage.com, which answers 403 unless the Referer is the site's
|
|
50
|
+
* origin (exactly `https://www.kakamanga.com/`; a page URL is refused too).
|
|
51
|
+
*/
|
|
52
|
+
imageHeaders = () => ({
|
|
53
|
+
Referer: `${this.baseUrl}/`
|
|
54
|
+
});
|
|
55
|
+
absoluteUrl = url => {
|
|
56
|
+
const value = url?.trim();
|
|
57
|
+
if (!value) return undefined;
|
|
58
|
+
if (value.startsWith('//')) return `https:${value}`;
|
|
59
|
+
if (value.startsWith('/')) return `${this.baseUrl}${value}`;
|
|
60
|
+
return /^https?:\/\//.test(value) ? value : undefined;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** The title's slug (its id) in `https://www.kakamanga.com/manga/<slug>`. */
|
|
64
|
+
slugFromUrl = url => /\/manga\/([^/?#]+)/.exec(url ?? '')?.[1];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param query Search query
|
|
68
|
+
* @param page Page number (default: 1)
|
|
69
|
+
*/
|
|
70
|
+
search = async (query, page = 1) => {
|
|
71
|
+
// /search/story/<word> is behind a Cloudflare challenge. The search box's endpoint serves the
|
|
72
|
+
// same results page, and JSON to requests sent with X-Requested-With (the search box's own).
|
|
73
|
+
// Cloudflare caches whichever it answered first for a URL, so either can come back.
|
|
74
|
+
const {
|
|
75
|
+
data
|
|
76
|
+
} = await this.ctx.axios.get(`${this.baseUrl}/home/search/json?searchword=${encodeURIComponent(searchWord(query))}&page=${page}`);
|
|
77
|
+
const json = typeof data === 'string' && /^\s*\[/.test(data) ? JSON.parse(data) : data;
|
|
78
|
+
if (Array.isArray(json)) return this.searchFromJson(json, page);
|
|
79
|
+
const $ = (0, _cheerio.load)(data);
|
|
80
|
+
const results = [];
|
|
81
|
+
$('.panel_story_list .story_item').each((_, el) => {
|
|
82
|
+
const link = $(el).find('.story_name a').first();
|
|
83
|
+
const result = this.searchResult(link.attr('href'), link.text(), $(el).find('img').first().attr('src'));
|
|
84
|
+
if (result) results.push(result);
|
|
85
|
+
});
|
|
86
|
+
const next = $('.panel_page_number .group_page a').filter((_, el) => $(el).text().trim().toLowerCase() === 'next').first();
|
|
87
|
+
return {
|
|
88
|
+
currentPage: Number($('.panel_page_number .page_select').first().text().trim()) || page,
|
|
89
|
+
hasNextPage: next.attr('href') !== undefined && !next.hasClass('page_disabled'),
|
|
90
|
+
results
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/** The JSON form of a search page: `[{ name, url, thumb, slug, ... }]`, with no pagination. */
|
|
95
|
+
searchFromJson = (items, page) => {
|
|
96
|
+
const results = items.map(item => this.searchResult(typeof item?.url === 'string' ? item.url : `/manga/${item?.slug}`, (0, _cheerio.load)(String(item?.name ?? ''), null, false).root().text(), item?.thumb)).filter(result => result !== undefined);
|
|
97
|
+
// Pages hold SEARCH_PAGE_SIZE titles, so a full page is taken to have a next one.
|
|
98
|
+
return {
|
|
99
|
+
currentPage: page,
|
|
100
|
+
hasNextPage: items.length >= SEARCH_PAGE_SIZE,
|
|
101
|
+
results
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
searchResult = (href, name, cover) => {
|
|
105
|
+
const url = this.absoluteUrl(typeof href === 'string' ? href : undefined);
|
|
106
|
+
const id = this.slugFromUrl(url);
|
|
107
|
+
const title = name.replace(/\s+/g, ' ').trim();
|
|
108
|
+
if (!url || !id || !title) return undefined;
|
|
109
|
+
const result = {
|
|
110
|
+
id,
|
|
111
|
+
title,
|
|
112
|
+
url
|
|
113
|
+
};
|
|
114
|
+
const image = this.absoluteUrl(typeof cover === 'string' ? cover : undefined);
|
|
115
|
+
if (image) Object.assign(result, {
|
|
116
|
+
image,
|
|
117
|
+
headerForImage: this.imageHeaders()
|
|
118
|
+
});
|
|
119
|
+
return result;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** @param mangaId the title's slug, e.g. `tomodachi-game` (from search results) */
|
|
21
123
|
fetchMangaInfo = async mangaId => {
|
|
22
|
-
const
|
|
124
|
+
const [{
|
|
125
|
+
data
|
|
126
|
+
}, chapters] = await Promise.all([this.ctx.axios.get(`${this.baseUrl}/manga/${mangaId}`), this.fetchChapters(mangaId)]);
|
|
127
|
+
const $ = (0, _cheerio.load)(data);
|
|
128
|
+
const title = $('.manga-info-text h1').first().text().trim();
|
|
129
|
+
const info = {
|
|
23
130
|
id: mangaId,
|
|
24
|
-
title
|
|
131
|
+
title,
|
|
132
|
+
url: `${this.baseUrl}/manga/${mangaId}`
|
|
25
133
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
id: $(el).find('span > a').attr('href')?.split('chapter/')[1],
|
|
55
|
-
title: $(el).find('span > a').text(),
|
|
56
|
-
views: parseInt($(el).find('span:nth-child(2)').text().replace(/,/g, '').trim()),
|
|
57
|
-
releasedDate: $(el).find('span:nth-child(3)').attr('title')
|
|
58
|
-
})).get();
|
|
59
|
-
} else {
|
|
60
|
-
mangaInfo.title = $(' div.panel-story-info > div.story-info-right > h1').text();
|
|
61
|
-
mangaInfo.altTitles = $('div.story-info-right > table > tbody > tr:nth-child(1) > td.table-value > h2').text().split(';');
|
|
62
|
-
mangaInfo.description = $('#panel-story-info-description').text().replace(`Description :`, '').replace(/\n/g, '').trim();
|
|
63
|
-
mangaInfo.headerForImage = {
|
|
64
|
-
Referer: 'https://readmanganato.com'
|
|
65
|
-
};
|
|
66
|
-
mangaInfo.image = $('div.story-info-left > span.info-image > img').attr('src');
|
|
67
|
-
mangaInfo.genres = $('div.story-info-right > table > tbody > tr:nth-child(4) > td.table-value > a').map((i, el) => $(el).text()).get();
|
|
68
|
-
switch ($('div.story-info-right > table > tbody > tr:nth-child(3) > td.table-value').text().trim()) {
|
|
69
|
-
case 'Completed':
|
|
70
|
-
mangaInfo.status = _index.MediaStatus.COMPLETED;
|
|
71
|
-
break;
|
|
72
|
-
case 'Ongoing':
|
|
73
|
-
mangaInfo.status = _index.MediaStatus.ONGOING;
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
mangaInfo.status = _index.MediaStatus.UNKNOWN;
|
|
77
|
-
}
|
|
78
|
-
mangaInfo.views = parseInt($('div.story-info-right > div > p:nth-child(2) > span.stre-value').text().replace(/,/g, '').trim());
|
|
79
|
-
mangaInfo.authors = $('div.story-info-right > table > tbody > tr:nth-child(2) > td.table-value > a').map((i, el) => $(el).text()).get();
|
|
80
|
-
mangaInfo.chapters = $('div.container-main-left > div.panel-story-chapter-list > ul > li').map((i, el) => ({
|
|
81
|
-
id: $(el).find('a').attr('href')?.split(`${mangaId}/`)[1],
|
|
82
|
-
title: $(el).find('a').text(),
|
|
83
|
-
views: parseInt($(el).find('span.chapter-view.text-nowrap').text().replace(/,/g, '').trim()),
|
|
84
|
-
releasedDate: $(el).find('span.chapter-time.text-nowrap').attr('title')
|
|
85
|
-
})).get();
|
|
86
|
-
}
|
|
87
|
-
return mangaInfo;
|
|
88
|
-
} catch (err) {
|
|
89
|
-
throw new Error(err.message);
|
|
90
|
-
}
|
|
134
|
+
|
|
135
|
+
// `Alternative : A; B`, which can repeat the title itself.
|
|
136
|
+
const altTitles = $('.manga-info-text h2.story-alternative').first().text().replace(/^\s*Alternative\s*:/i, '').split(';').map(alt => alt.replace(/\s+/g, ' ').trim()).filter((alt, i, all) => alt && alt !== title && all.indexOf(alt) === i);
|
|
137
|
+
if (altTitles.length) info.altTitles = altTitles;
|
|
138
|
+
const image = this.absoluteUrl($('.manga-info-pic img').first().attr('src'));
|
|
139
|
+
if (image) Object.assign(info, {
|
|
140
|
+
image,
|
|
141
|
+
headerForImage: this.imageHeaders()
|
|
142
|
+
});
|
|
143
|
+
const description = this.description($);
|
|
144
|
+
if (description) info.description = description;
|
|
145
|
+
|
|
146
|
+
// `Author(s) : A, B`, `Status : Ongoing`, `View : 41,148,877`, ...
|
|
147
|
+
const fields = {};
|
|
148
|
+
$('.manga-info-text > li:not(:has(h1))').each((_, el) => {
|
|
149
|
+
const match = /^([^:]+?)\s*:\s*(.*)$/.exec($(el).text().replace(/\s+/g, ' ').trim());
|
|
150
|
+
if (match) fields[match[1].toLowerCase()] = match[2].trim();
|
|
151
|
+
});
|
|
152
|
+
const authors = (fields['author(s)'] ?? '').split(',').map(author => author.trim()).filter(author => author && author.toLowerCase() !== 'unknown');
|
|
153
|
+
if (authors.length) info.authors = authors;
|
|
154
|
+
const status = (fields.status ?? '').toLowerCase();
|
|
155
|
+
if (status === 'ongoing') info.status = _index.MediaStatus.ONGOING;else if (status === 'completed') info.status = _index.MediaStatus.COMPLETED;
|
|
156
|
+
const genres = $('.manga-info-text li.genres a').map((_, el) => $(el).text().trim()).get().filter(Boolean);
|
|
157
|
+
if (genres.length) info.genres = genres;
|
|
158
|
+
const views = parseInt((fields.view ?? '').replace(/,/g, ''), 10);
|
|
159
|
+
if (Number.isFinite(views)) info.views = views;
|
|
160
|
+
info.chapters = chapters;
|
|
161
|
+
return info;
|
|
91
162
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
Referer: this.baseUrl
|
|
105
|
-
}
|
|
106
|
-
})).get();
|
|
107
|
-
return pages;
|
|
108
|
-
} catch (err) {
|
|
109
|
-
throw new Error(err.message);
|
|
110
|
-
}
|
|
163
|
+
|
|
164
|
+
/** @param chapterId `<title slug>/<chapter slug>`, e.g. `tomodachi-game/chapter-127-5` */
|
|
165
|
+
fetchChapterPages = async chapterId => {
|
|
166
|
+
const {
|
|
167
|
+
data
|
|
168
|
+
} = await this.ctx.axios.get(`${this.baseUrl}/manga/${chapterId}`);
|
|
169
|
+
const $ = (0, _cheerio.load)(data);
|
|
170
|
+
return $('.container-chapter-reader img').map((_, el) => this.absoluteUrl($(el).attr('src') ?? $(el).attr('data-src'))).get().filter(img => Boolean(img)).map((img, i) => ({
|
|
171
|
+
img,
|
|
172
|
+
page: i + 1,
|
|
173
|
+
headerForImage: this.imageHeaders()
|
|
174
|
+
}));
|
|
111
175
|
};
|
|
112
176
|
|
|
113
177
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
178
|
+
* The synopsis under the `<title> summary:` heading, as plain text. Some titles store it as
|
|
179
|
+
* escaped HTML (`&quot;`, `<br>`), so its text is read as HTML once more: whitespace
|
|
180
|
+
* collapses as a browser would and `<br>` breaks lines.
|
|
116
181
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
182
|
+
description = $ => {
|
|
183
|
+
const box = $('#contentBox').first().clone();
|
|
184
|
+
box.find('h2').remove();
|
|
185
|
+
box.find('br').replaceWith('<br>');
|
|
186
|
+
const html = box.text().replace(/\s+/g, ' ').replace(/<br\s*\/?>/gi, '\n');
|
|
187
|
+
const text = (0, _cheerio.load)(html, null, false).root().text().split('\n').map(line => line.trim()).join('\n').replace(/\n{3,}/g, '\n\n').trim();
|
|
188
|
+
return text || undefined;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/** Every chapter of a title from the chapter-list API, in reading order. */
|
|
192
|
+
fetchChapters = async mangaId => {
|
|
193
|
+
const rows = [];
|
|
194
|
+
for (let request = 0; request < MAX_CHAPTER_REQUESTS; request++) {
|
|
119
195
|
const {
|
|
120
196
|
data
|
|
121
|
-
} = await this.ctx.axios.get(`${this.baseUrl}/
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
})).get();
|
|
131
|
-
return {
|
|
132
|
-
results: results
|
|
133
|
-
};
|
|
134
|
-
} catch (err) {
|
|
135
|
-
throw new Error(err.message);
|
|
197
|
+
} = await this.ctx.axios.get(`${this.baseUrl}/api/manga/${mangaId}/chapters?limit=${CHAPTERS_PER_REQUEST}&offset=${rows.length}`);
|
|
198
|
+
const body = typeof data === 'string' ? JSON.parse(data) : data;
|
|
199
|
+
const page = body?.data?.chapters;
|
|
200
|
+
if (!body?.success || !Array.isArray(page)) {
|
|
201
|
+
throw new Error(`MangaKakalot: no chapter list for '${mangaId}' (${body?.message ?? 'unexpected response'})`);
|
|
202
|
+
}
|
|
203
|
+
rows.push(...page);
|
|
204
|
+
if (!body.data.pagination?.has_more || page.length === 0) break;
|
|
136
205
|
}
|
|
206
|
+
|
|
207
|
+
// A chapter published while paging shifts the offsets, so a row can come twice.
|
|
208
|
+
const seen = new Set();
|
|
209
|
+
const chapters = [];
|
|
210
|
+
for (const row of rows) {
|
|
211
|
+
const chapter = this.toChapter(mangaId, row);
|
|
212
|
+
if (!chapter || seen.has(chapter.id)) continue;
|
|
213
|
+
seen.add(chapter.id);
|
|
214
|
+
chapters.push(chapter);
|
|
215
|
+
}
|
|
216
|
+
return (0, _manga.sortChaptersForReading)(chapters.reverse());
|
|
217
|
+
};
|
|
218
|
+
toChapter = (mangaId, row) => {
|
|
219
|
+
const slug = row.chapter_slug?.trim();
|
|
220
|
+
if (!slug) return undefined;
|
|
221
|
+
const label = row.chapter_name?.replace(/\s+/g, ' ').trim() ?? '';
|
|
222
|
+
const apiNumber = row.chapter_num === null || row.chapter_num === '' ? NaN : Number(row.chapter_num);
|
|
223
|
+
const chapterNumber = (0, _manga.parseChapterNumber)(label) ?? (Number.isFinite(apiNumber) ? apiNumber : undefined);
|
|
224
|
+
const chapter = {
|
|
225
|
+
id: `${mangaId}/${slug}`,
|
|
226
|
+
title: label || (chapterNumber !== undefined ? `Chapter ${chapterNumber}` : slug)
|
|
227
|
+
};
|
|
228
|
+
if (chapterNumber !== undefined) chapter.chapterNumber = chapterNumber;
|
|
229
|
+
const volumeNumber = (0, _manga.parseVolumeNumber)(label);
|
|
230
|
+
if (volumeNumber !== undefined) chapter.volumeNumber = volumeNumber;
|
|
231
|
+
const releaseDate = toIsoDate(row.updated_at);
|
|
232
|
+
if (releaseDate) chapter.releaseDate = releaseDate;
|
|
233
|
+
if (typeof row.view === 'number') chapter.views = row.view;
|
|
234
|
+
chapter.url = `${this.baseUrl}/manga/${mangaId}/${slug}`;
|
|
235
|
+
return chapter;
|
|
137
236
|
};
|
|
138
237
|
}
|
|
139
238
|
exports.MangaKakalot = MangaKakalot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cheerio","require","_index","_createProviderContext","MangaKakalot","MangaParser","name","baseUrl","logo","classPath","constructor","ctx","createProviderContext","fetchMangaInfo","mangaId","mangaInfo","id","title","url","includes","data","axios","get","$","load","text","altTitles","replace","split","description","trim","headerForImage","Referer","image","attr","genres","map","i","el","status","MediaStatus","COMPLETED","ONGOING","UNKNOWN","views","parseInt","authors","chapters","find","releasedDate","err","Error","message","fetchChapterPages","chapterId","pages","img","page","search","query","results","exports"],"sourceRoot":"../../../../src","sources":["providers/manga/mangakakalot.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAUA,IAAAE,sBAAA,GAAAF,OAAA;AAEO,MAAMG,YAAY,SAASC,kBAAW,CAAC;EAC1BC,IAAI,GAAG,cAAc;EACpBC,OAAO,GAAG,0BAA0B;EACpCC,IAAI,GAAG,mEAAmE;EAC1EC,SAAS,GAAG,oBAAoB;;EAEnD;EACAC,WAAWA,CAAkBC,GAAoB,GAAG,IAAAC,4CAAqB,EAAC,CAAC,EAAE;IAC3E,KAAK,CAAC,CAAC;IAAC,KADmBD,GAAoB,GAApBA,GAAoB;EAEjD;EAESE,cAAc,GAAG,MAAOC,OAAe,IAA0B;IACxE,MAAMC,SAAqB,GAAG;MAC5BC,EAAE,EAAEF,OAAO;MACXG,KAAK,EAAE;IACT,CAAC;IACD,MAAMC,GAAG,GAAGJ,OAAO,CAACK,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAACZ,OAAO,GAAG,0BAA0B;IAChF,IAAI;MACF,MAAM;QAAEa;MAAK,CAAC,GAAG,MAAM,IAAI,CAACT,GAAG,CAACU,KAAK,CAACC,GAAG,CAAC,GAAGJ,GAAG,IAAIJ,OAAO,EAAE,CAAC;MAC9D,MAAMS,CAAC,GAAG,IAAAC,aAAI,EAACJ,IAAI,CAAC;MAEpB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,MAAM,CAAC,EAAEN,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE;QAC3DX,KAAK,EAAEM,CAAC,CAACe,EAAE,CAAC,CAACU,IAAI,CAAC,cAAc,CAAC,CAACvB,IAAI,CAAC,CAAC;QACxCQ,KAAK,EAAEV,CAAC,CAACe,EAAE,CAAC,CAACU,IAAI,CAAC,SAAS,CAAC,CAACd,IAAI,CAAC,KAAK,CAAC;QACxCH,cAAc,EAAE;UAAEC,OAAO,EAAE,IAAI,CAACzB;QAAQ;MAC1C,CAAC,CACH,CAAC,CACAe,GAAG,CAAC,CAAC;MACR,OAAO;QACLsC,OAAO,EAAEA;MACX,CAAC;IACH,CAAC,CAAC,OAAOV,GAAG,EAAE;MACZ,MAAM,IAAIC,KAAK,CAAED,GAAG,CAAWE,OAAO,CAAC;IACzC;EACF,CAAC;AACH;AAACS,OAAA,CAAAzD,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_cheerio","require","_index","_createProviderContext","_manga","CHAPTERS_PER_REQUEST","MAX_CHAPTER_REQUESTS","SEARCH_PAGE_SIZE","searchWord","query","toLowerCase","replace","toIsoDate","value","undefined","match","exec","trim","padEnd","slice","time","Date","parse","Number","isNaN","toISOString","MangaKakalot","MangaParser","name","baseUrl","logo","classPath","constructor","ctx","createProviderContext","imageHeaders","Referer","absoluteUrl","url","startsWith","test","slugFromUrl","search","page","data","axios","get","encodeURIComponent","json","JSON","Array","isArray","searchFromJson","$","load","results","each","_","el","link","find","first","result","searchResult","attr","text","push","next","filter","currentPage","hasNextPage","hasClass","items","map","item","slug","String","root","thumb","length","href","cover","id","title","image","Object","assign","headerForImage","fetchMangaInfo","mangaId","chapters","Promise","all","fetchChapters","info","altTitles","split","alt","i","indexOf","description","fields","authors","author","status","MediaStatus","ONGOING","COMPLETED","genres","Boolean","views","parseInt","view","isFinite","fetchChapterPages","chapterId","img","box","clone","remove","replaceWith","html","line","join","rows","request","body","success","Error","message","pagination","has_more","seen","Set","row","chapter","toChapter","has","add","sortChaptersForReading","reverse","chapter_slug","label","chapter_name","apiNumber","chapter_num","NaN","chapterNumber","parseChapterNumber","volumeNumber","parseVolumeNumber","releaseDate","updated_at","exports"],"sourceRoot":"../../../../src","sources":["providers/manga/mangakakalot.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAUA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA;;AASA;AACA;AACA,MAAMI,oBAAoB,GAAG,GAAG;AAChC,MAAMC,oBAAoB,GAAG,EAAE;AAC/B;AACA,MAAMC,gBAAgB,GAAG,EAAE;;AAE3B;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAIC,KAAa,IAC/BA,KAAK,CACFC,WAAW,CAAC,CAAC,CACbC,OAAO,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAClCA,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;;AAE5B;AACA,MAAMC,SAAS,GAAIC,KAAyB,IAAyB;EACnE,IAAI,CAACA,KAAK,EAAE,OAAOC,SAAS;EAC5B,MAAMC,KAAK,GAAG,sDAAsD,CAACC,IAAI,CAACH,KAAK,CAACI,IAAI,CAAC,CAAC,CAAC;EACvF,IAAIF,KAAK,EAAE,OAAO,GAAGA,KAAK,CAAC,CAAC,CAAC,IAAI,CAACA,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAEG,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;EAC/E,MAAMC,IAAI,GAAGC,IAAI,CAACC,KAAK,CAACT,KAAK,CAAC;EAC9B,OAAOU,MAAM,CAACC,KAAK,CAACJ,IAAI,CAAC,GAAGP,KAAK,GAAG,IAAIQ,IAAI,CAACD,IAAI,CAAC,CAACK,WAAW,CAAC,CAAC;AAClE,CAAC;AAEM,MAAMC,YAA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AAS,GAAGlI,SAAS,CAAC;IAEvG,MAAMyH,OAAsB,GAAG;MAC7BrD,EAAE,EAAE,GAAGO,OAAO,IAAId,IAAI,EAAE;MACxBQ,KAAK,EAAE2D,KAAK,KAAKK,aAAa,KAAKrI,SAAS,GAAG,WAAWqI,aAAa,EAAE,GAAGxE,IAAI;IAClF,CAAC;IACD,IAAIwE,aAAa,KAAKrI,SAAS,EAAEyH,OAAO,CAACY,aAAa,GAAGA,aAAa;IACtE,MAAME,YAAY,GAAG,IAAAC,wBAAiB,EAACR,KAAK,CAAC;IAC7C,IAAIO,YAAY,KAAKvI,SAAS,EAAEyH,OAAO,CAACc,YAAY,GAAGA,YAAY;IACnE,MAAME,WAAW,GAAG3I,SAAS,CAAC0H,GAAG,CAACkB,UAAU,CAAC;IAC7C,IAAID,WAAW,EAAEhB,OAAO,CAACgB,WAAW,GAAGA,WAAW;IAClD,IAAI,OAAOjB,GAAG,CAACtB,IAAI,KAAK,QAAQ,EAAEuB,OAAO,CAACzB,KAAK,GAAGwB,GAAG,CAACtB,IAAI;IAC1DuB,OAAO,CAACjG,GAAG,GAAG,GAAG,IAAI,CAACT,OAAO,UAAU4D,OAAO,IAAId,IAAI,EAAE;IACxD,OAAO4D,OAAO;EAChB,CAAC;AACH;AAACkB,OAAA,CAAA/H,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -7,6 +7,23 @@ exports.MangaPill = void 0;
|
|
|
7
7
|
var _cheerio = require("cheerio");
|
|
8
8
|
var _index = require("../../models/index.js");
|
|
9
9
|
var _createProviderContext = require("../../utils/create-provider-context.js");
|
|
10
|
+
var _manga = require("../../utils/manga.js");
|
|
11
|
+
// The status labels MangaPill uses (its search filter lists the same five).
|
|
12
|
+
const STATUSES = {
|
|
13
|
+
'publishing': _index.MediaStatus.ONGOING,
|
|
14
|
+
'finished': _index.MediaStatus.COMPLETED,
|
|
15
|
+
'on hiatus': _index.MediaStatus.HIATUS,
|
|
16
|
+
'discontinued': _index.MediaStatus.CANCELLED,
|
|
17
|
+
'not yet published': _index.MediaStatus.NOT_YET_AIRED
|
|
18
|
+
};
|
|
19
|
+
const toStatus = text => text ? STATUSES[text.toLowerCase()] ?? _index.MediaStatus.UNKNOWN : undefined;
|
|
20
|
+
const toYear = text => /^\d{4}$/.test(text) ? Number(text) : undefined;
|
|
21
|
+
|
|
22
|
+
/** Plain text: whitespace within a line collapses to one space, paragraph breaks stay. */
|
|
23
|
+
const cleanText = text => text.split('\n').map(line => line.replace(/\s+/g, ' ').trim()).join('\n').replace(/\n{3,}/g, '\n\n').trim();
|
|
24
|
+
|
|
25
|
+
/** Copies only the fields that have a value, so missing ones are left out rather than `undefined`. */
|
|
26
|
+
const defined = fields => Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
|
|
10
27
|
class MangaPill extends _index.MangaParser {
|
|
11
28
|
name = 'MangaPill';
|
|
12
29
|
baseUrl = 'https://mangapill.com';
|
|
@@ -20,76 +37,147 @@ class MangaPill extends _index.MangaParser {
|
|
|
20
37
|
}
|
|
21
38
|
|
|
22
39
|
/**
|
|
23
|
-
*
|
|
24
40
|
* @param query Search query
|
|
41
|
+
* @param page Page number (default: `1`); the site lists 50 titles a page
|
|
25
42
|
*/
|
|
26
|
-
search = async query => {
|
|
43
|
+
search = async (query, page = 1) => {
|
|
27
44
|
try {
|
|
45
|
+
const pageQuery = page > 1 ? `&page=${page}` : '';
|
|
28
46
|
const {
|
|
29
47
|
data
|
|
30
|
-
} = await this.ctx.axios.get(`${this.baseUrl}/search?q=${encodeURIComponent(query)}`);
|
|
48
|
+
} = await this.ctx.axios.get(`${this.baseUrl}/search?q=${encodeURIComponent(query)}${pageQuery}`);
|
|
31
49
|
const $ = (0, _cheerio.load)(data);
|
|
32
|
-
const results = $('div.container div.my-3.justify-end > div').map((
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
const results = $('div.container div.my-3.justify-end > div').map((_, el) => {
|
|
51
|
+
const card = $(el);
|
|
52
|
+
const link = card.find('div.flex-col > a[href^="/manga/"]').first();
|
|
53
|
+
const id = this.mangaId(link.attr('href') ?? card.find('a[href^="/manga/"]').attr('href'));
|
|
54
|
+
const title = link.children('div').first().text().trim();
|
|
55
|
+
if (!id || !title) return undefined;
|
|
56
|
+
const altTitle = link.children('div').eq(1).text().trim();
|
|
57
|
+
// Type, year and status badges ("manga", "1997", "publishing").
|
|
58
|
+
const badges = card.find('div.flex-col > div.flex-wrap').first().children('div').map((__, badge) => $(badge).text().trim()).get();
|
|
59
|
+
const status = badges.find(badge => STATUSES[badge.toLowerCase()]);
|
|
60
|
+
const image = this.absoluteUrl(card.find('a img').attr('data-src') ?? card.find('a img').attr('src'));
|
|
61
|
+
return defined({
|
|
62
|
+
id,
|
|
63
|
+
title,
|
|
64
|
+
altTitles: altTitle && altTitle !== title ? [altTitle] : undefined,
|
|
65
|
+
image,
|
|
66
|
+
headerForImage: image ? this.imageHeaders() : undefined,
|
|
67
|
+
url: `${this.baseUrl}/manga/${id}`,
|
|
68
|
+
status: status ? toStatus(status) : undefined,
|
|
69
|
+
releaseDate: badges.map(toYear).find(year => year !== undefined)
|
|
70
|
+
});
|
|
71
|
+
}).get().filter(result => result !== undefined);
|
|
72
|
+
const hasNextPage = $('a[href^="/search"]').filter((_, a) => $(a).text().trim().toLowerCase() === 'next').length > 0;
|
|
37
73
|
return {
|
|
38
|
-
|
|
74
|
+
currentPage: page,
|
|
75
|
+
hasNextPage,
|
|
76
|
+
results
|
|
39
77
|
};
|
|
40
78
|
} catch (err) {
|
|
41
|
-
// console.log(err);
|
|
42
79
|
throw new Error(err.message);
|
|
43
80
|
}
|
|
44
81
|
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param mangaId Manga id from the search results (e.g. `2/one-piece`)
|
|
85
|
+
*/
|
|
45
86
|
fetchMangaInfo = async mangaId => {
|
|
46
|
-
const mangaInfo = {
|
|
47
|
-
id: mangaId,
|
|
48
|
-
title: ''
|
|
49
|
-
};
|
|
50
87
|
try {
|
|
51
88
|
const {
|
|
52
89
|
data
|
|
53
90
|
} = await this.ctx.axios.get(`${this.baseUrl}/manga/${mangaId}`);
|
|
54
91
|
const $ = (0, _cheerio.load)(data);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
92
|
+
// The cover and the details beside it: title, alt title, synopsis, type/status/year, genres.
|
|
93
|
+
const header = $('div.container div.my-3').filter((_, el) => $(el).find('h1').length > 0).first();
|
|
94
|
+
// The value under a label of the details grid ("Type", "Status", "Year").
|
|
95
|
+
const detail = label => header.find('label').filter((_, el) => $(el).text().trim() === label).first().next('div').text().trim();
|
|
96
|
+
const heading = header.find('h1').first();
|
|
97
|
+
const title = heading.text().trim();
|
|
98
|
+
const altTitle = heading.nextAll('div').first().text().trim();
|
|
99
|
+
const cover = header.find('img').first();
|
|
100
|
+
const image = this.absoluteUrl(cover.attr('data-src') ?? cover.attr('src'));
|
|
101
|
+
const description = cleanText(header.find('p.text--secondary').first().text());
|
|
102
|
+
const genres = header.find('a[href*="genre="]').map((_, a) => $(a).text().trim()).get().filter(Boolean);
|
|
103
|
+
return defined({
|
|
104
|
+
id: mangaId,
|
|
105
|
+
title,
|
|
106
|
+
altTitles: altTitle && altTitle !== title ? [altTitle] : undefined,
|
|
107
|
+
image,
|
|
108
|
+
headerForImage: image ? this.imageHeaders() : undefined,
|
|
109
|
+
description: description || undefined,
|
|
110
|
+
status: toStatus(detail('Status')),
|
|
111
|
+
releaseDate: toYear(detail('Year')),
|
|
112
|
+
url: `${this.baseUrl}/manga/${mangaId}`,
|
|
113
|
+
genres: genres.length ? genres : undefined,
|
|
114
|
+
chapters: this.parseChapters($)
|
|
115
|
+
});
|
|
65
116
|
} catch (err) {
|
|
66
117
|
throw new Error(err.message);
|
|
67
118
|
}
|
|
68
119
|
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param chapterId Chapter id from the manga info (e.g. `2-11069000/one-piece-chapter-1069`)
|
|
123
|
+
*/
|
|
69
124
|
fetchChapterPages = async chapterId => {
|
|
70
125
|
try {
|
|
71
126
|
const {
|
|
72
127
|
data
|
|
73
128
|
} = await this.ctx.axios.get(`${this.baseUrl}/chapters/${chapterId}`);
|
|
74
129
|
const $ = (0, _cheerio.load)(data);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
130
|
+
return $('chapter-page').map((_, el) => {
|
|
131
|
+
const img = $(el).find('img').first();
|
|
132
|
+
return this.absoluteUrl(img.attr('data-src') ?? img.attr('src'));
|
|
133
|
+
}).get().filter(img => Boolean(img)).map((img, i) => ({
|
|
134
|
+
img,
|
|
135
|
+
page: i + 1,
|
|
136
|
+
headerForImage: this.imageHeaders()
|
|
137
|
+
}));
|
|
81
138
|
} catch (err) {
|
|
82
139
|
throw new Error(err.message);
|
|
83
140
|
}
|
|
84
141
|
};
|
|
85
|
-
}
|
|
86
142
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//
|
|
143
|
+
/** The site lists chapters newest first; they are returned first chapter first. */
|
|
144
|
+
parseChapters($) {
|
|
145
|
+
const chapters = $('div#chapters a[href^="/chapters/"]').map((_, el) => {
|
|
146
|
+
const id = $(el).attr('href').split('/chapters/')[1];
|
|
147
|
+
if (!id) return undefined;
|
|
148
|
+
const label = $(el).text().replace(/\s+/g, ' ').trim();
|
|
149
|
+
// The label is "Chapter 1053.4"; the slug ("one-piece-chapter-1053.4") names it too.
|
|
150
|
+
const chapterNumber = (0, _manga.parseChapterNumber)(label) ?? (0, _manga.parseChapterNumber)(id.split('/')[1]);
|
|
151
|
+
return defined({
|
|
152
|
+
id,
|
|
153
|
+
title: label || (chapterNumber !== undefined ? `Chapter ${chapterNumber}` : id),
|
|
154
|
+
chapterNumber,
|
|
155
|
+
url: `${this.baseUrl}/chapters/${id}`
|
|
156
|
+
});
|
|
157
|
+
}).get().filter(chapter => chapter !== undefined);
|
|
158
|
+
return (0, _manga.sortChaptersForReading)(chapters.reverse());
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** The image CDN answers 403 to requests without a MangaPill Referer, covers and pages alike. */
|
|
162
|
+
imageHeaders() {
|
|
163
|
+
return {
|
|
164
|
+
Referer: `${this.baseUrl}/`
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** `/manga/2/one-piece` → `2/one-piece`. */
|
|
169
|
+
mangaId(href) {
|
|
170
|
+
return href?.split('/manga/')[1] || undefined;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Image URLs are absolute today; resolve site-relative ones anyway (Hermes' global URL is incomplete). */
|
|
174
|
+
absoluteUrl(url) {
|
|
175
|
+
const value = url?.trim();
|
|
176
|
+
if (!value) return undefined;
|
|
177
|
+
if (/^https?:\/\//i.test(value)) return value;
|
|
178
|
+
if (value.startsWith('//')) return `https:${value}`;
|
|
179
|
+
return `${this.baseUrl}/${value.replace(/^\/+/, '')}`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
94
182
|
exports.MangaPill = MangaPill;
|
|
95
183
|
//# sourceMappingURL=mangapill.js.map
|