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
|
@@ -2,151 +2,254 @@ import { load } from 'cheerio';
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
MangaParser,
|
|
5
|
+
MediaStatus,
|
|
5
6
|
type ISearch,
|
|
6
7
|
type IMangaInfo,
|
|
7
8
|
type IMangaResult,
|
|
8
9
|
type IMangaChapterPage,
|
|
9
10
|
type IMangaChapter,
|
|
10
|
-
MediaStatus,
|
|
11
11
|
type ProviderContext,
|
|
12
12
|
} from '../../models';
|
|
13
13
|
import { createProviderContext } from '../../utils/create-provider-context';
|
|
14
|
+
import { parseChapterNumber, sortChaptersForReading } from '../../utils/manga';
|
|
15
|
+
|
|
16
|
+
/** Covers and chapter pages; the CDN serves them without a Referer. */
|
|
17
|
+
const IMAGE_CDN = 'https://cdn.flamecomics.xyz/uploads/images/series';
|
|
18
|
+
|
|
19
|
+
/** A series as the site's browse and series pages describe it. */
|
|
20
|
+
interface FlameSeries {
|
|
21
|
+
series_id?: number;
|
|
22
|
+
/** Set (instead of `series_id`) on the web novels the browse page also lists. */
|
|
23
|
+
novel_id?: number | null;
|
|
24
|
+
title?: string;
|
|
25
|
+
altTitles?: string[];
|
|
26
|
+
/** HTML on the series page, plain text on the browse page. */
|
|
27
|
+
description?: string | null;
|
|
28
|
+
tags?: string[];
|
|
29
|
+
author?: string[];
|
|
30
|
+
artist?: string[];
|
|
31
|
+
year?: number | null;
|
|
32
|
+
status?: string;
|
|
33
|
+
cover?: string;
|
|
34
|
+
last_edit?: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface FlameChapter {
|
|
38
|
+
series_id?: number;
|
|
39
|
+
/** `"12.00"`, `"10.50"` */
|
|
40
|
+
chapter?: string;
|
|
41
|
+
/** The chapter's name; null or empty when it has none. */
|
|
42
|
+
title?: string | null;
|
|
43
|
+
token: string;
|
|
44
|
+
release_date?: number | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface FlameReaderChapter {
|
|
48
|
+
edit_time?: number;
|
|
49
|
+
images?: Record<string, { name?: string }> | { name?: string }[];
|
|
50
|
+
}
|
|
14
51
|
|
|
52
|
+
const STATUS: Record<string, MediaStatus> = {
|
|
53
|
+
'ongoing': MediaStatus.ONGOING,
|
|
54
|
+
'completed': MediaStatus.COMPLETED,
|
|
55
|
+
'hiatus': MediaStatus.HIATUS,
|
|
56
|
+
'dropped': MediaStatus.CANCELLED,
|
|
57
|
+
'cancelled': MediaStatus.CANCELLED,
|
|
58
|
+
'coming soon': MediaStatus.NOT_YET_AIRED,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Lower-case words without punctuation, so `returners magic` finds "A Returner's Magic". */
|
|
62
|
+
const searchable = (text: string) =>
|
|
63
|
+
text
|
|
64
|
+
.toLowerCase()
|
|
65
|
+
.replace(/['`\u2018\u2019]/g, '')
|
|
66
|
+
.replace(/[^a-z0-9\u00c0-\u1fff\u2070-\uffff]+/g, ' ')
|
|
67
|
+
.trim();
|
|
68
|
+
|
|
69
|
+
/** Plain text of the site's HTML descriptions (paragraphs become blank-line separated). */
|
|
70
|
+
const plainText = (html: string | null | undefined): string | undefined => {
|
|
71
|
+
if (!html) return undefined;
|
|
72
|
+
const $ = load(html);
|
|
73
|
+
$('br').replaceWith('\n');
|
|
74
|
+
$('p').after('\n\n');
|
|
75
|
+
const text = $.root()
|
|
76
|
+
.text()
|
|
77
|
+
.replace(/[ \t]+\n/g, '\n')
|
|
78
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
79
|
+
.trim();
|
|
80
|
+
return text || undefined;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** The non-empty strings of a list, trimmed and without repeats. */
|
|
84
|
+
const strings = (values: unknown): string[] =>
|
|
85
|
+
Array.isArray(values)
|
|
86
|
+
? [...new Set(values.filter((v): v is string => typeof v === 'string').map((v) => v.trim()))].filter(Boolean)
|
|
87
|
+
: [];
|
|
88
|
+
|
|
89
|
+
const parseJson = (data: unknown): any => {
|
|
90
|
+
if (typeof data !== 'string') return data;
|
|
91
|
+
try {
|
|
92
|
+
return JSON.parse(data);
|
|
93
|
+
} catch {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const isoDate = (unixSeconds: number | null | undefined): string | undefined =>
|
|
99
|
+
typeof unixSeconds === 'number' && unixSeconds > 0 ? new Date(unixSeconds * 1000).toISOString() : undefined;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Flame Comics (https://flamecomics.xyz), the scanlation group formerly at flamescans.org. The site
|
|
103
|
+
* is a Next.js app: every page's data comes as JSON from `/_next/data/<buildId>/<page>.json`.
|
|
104
|
+
*/
|
|
15
105
|
export class FlameScans extends MangaParser {
|
|
16
|
-
override readonly name = '
|
|
17
|
-
protected override baseUrl = 'https://
|
|
18
|
-
protected override logo = 'https://
|
|
106
|
+
override readonly name = 'FlameComics';
|
|
107
|
+
protected override baseUrl = 'https://flamecomics.xyz';
|
|
108
|
+
protected override logo = 'https://flamecomics.xyz/og-default.png';
|
|
19
109
|
protected override classPath = 'MANGA.FlameScans';
|
|
20
110
|
|
|
111
|
+
private buildIdRequest?: Promise<string>;
|
|
112
|
+
|
|
21
113
|
/** @param ctx provider context; requests go through its axios (default: `createProviderContext()`) */
|
|
22
114
|
constructor(private readonly ctx: ProviderContext = createProviderContext()) {
|
|
23
115
|
super();
|
|
24
116
|
}
|
|
25
117
|
|
|
26
118
|
/**
|
|
119
|
+
* The site has no search endpoint: its browse page lists every series, and this keeps the ones
|
|
120
|
+
* whose title has every word of the query. All matches come on page 1.
|
|
27
121
|
*
|
|
28
122
|
* @param query Search query
|
|
29
|
-
*
|
|
123
|
+
* @param page Page number (default 1)
|
|
30
124
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
title: $(el).find('a').attr('title') ?? '',
|
|
43
|
-
image: $(el).find('img').attr('src'),
|
|
44
|
-
})
|
|
45
|
-
)
|
|
46
|
-
.get();
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
results: results,
|
|
50
|
-
};
|
|
51
|
-
} catch (err) {
|
|
52
|
-
throw new Error((err as Error).message);
|
|
53
|
-
}
|
|
125
|
+
override search = async (query: string, page: number = 1): Promise<ISearch<IMangaResult>> => {
|
|
126
|
+
const { series = [] } = await this.nextData<{ series?: FlameSeries[] }>('browse');
|
|
127
|
+
const words = searchable(query).split(' ').filter(Boolean);
|
|
128
|
+
const results =
|
|
129
|
+
page > 1
|
|
130
|
+
? []
|
|
131
|
+
: series
|
|
132
|
+
.filter((entry) => typeof entry.series_id === 'number' && entry.title?.trim())
|
|
133
|
+
.filter((entry) => words.every((word) => searchable(entry.title!).includes(word)))
|
|
134
|
+
.map((entry) => this.toResult(entry));
|
|
135
|
+
return { currentPage: page, hasNextPage: false, results };
|
|
54
136
|
};
|
|
55
137
|
|
|
138
|
+
/** @param mangaId series id from `search` (`"101"`) */
|
|
56
139
|
override fetchMangaInfo = async (mangaId: string): Promise<IMangaInfo> => {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const seriesChaptersSelector = 'div.bxcl li, div.cl li, #chapterlist li, ul li:has(div.chbox):has(div.eph-num)';
|
|
78
|
-
|
|
79
|
-
mangaInfo.title = $(seriesTitleSelector).text().trim();
|
|
80
|
-
mangaInfo.altTitles = $(seriesAltNameSelector).text()
|
|
81
|
-
? $(seriesAltNameSelector)
|
|
82
|
-
.first()
|
|
83
|
-
.text()
|
|
84
|
-
.split('|')
|
|
85
|
-
.map((item) => item.replace(/\n/g, ' ').trim())
|
|
86
|
-
: [];
|
|
87
|
-
mangaInfo.description = $(seriesDescriptionSelector).text().trim();
|
|
88
|
-
mangaInfo.headerForImage = { Referer: this.baseUrl };
|
|
89
|
-
mangaInfo.image = $(seriesThumbnailSelector).attr('src');
|
|
90
|
-
mangaInfo.genres = $(seriesGenreSelector)
|
|
91
|
-
.map((i, el) => $(el).text())
|
|
92
|
-
.get();
|
|
93
|
-
switch ($(seriesStatusSelector).text().trim()) {
|
|
94
|
-
case 'Completed':
|
|
95
|
-
mangaInfo.status = MediaStatus.COMPLETED;
|
|
96
|
-
break;
|
|
97
|
-
case 'Ongoing':
|
|
98
|
-
mangaInfo.status = MediaStatus.ONGOING;
|
|
99
|
-
break;
|
|
100
|
-
case 'Dropped':
|
|
101
|
-
mangaInfo.status = MediaStatus.CANCELLED;
|
|
102
|
-
break;
|
|
103
|
-
default:
|
|
104
|
-
mangaInfo.status = MediaStatus.UNKNOWN;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
mangaInfo.authors = $(seriesAuthorSelector).text().replace('-', '').trim()
|
|
108
|
-
? $(seriesAuthorSelector)
|
|
109
|
-
.text()
|
|
110
|
-
.split(',')
|
|
111
|
-
.map((item) => item.trim())
|
|
112
|
-
: [];
|
|
113
|
-
mangaInfo.artist = $(seriesArtistSelector).text().trim() ? $(seriesArtistSelector).text().trim() : 'N/A';
|
|
114
|
-
mangaInfo.chapters = $(seriesChaptersSelector)
|
|
115
|
-
.map(
|
|
116
|
-
(i, el): IMangaChapter => ({
|
|
117
|
-
id: $(el).find('a').attr('href')?.split('/')[3] ?? '',
|
|
118
|
-
title: $(el).find('.lch a, .chapternum').text().trim().replace(/\n/g, ' '),
|
|
119
|
-
releasedDate: $(el).find('.chapterdate').text(),
|
|
120
|
-
})
|
|
121
|
-
)
|
|
122
|
-
.get();
|
|
123
|
-
|
|
124
|
-
return mangaInfo;
|
|
125
|
-
} catch (err) {
|
|
126
|
-
throw new Error((err as Error).message);
|
|
140
|
+
const id = String(mangaId).trim();
|
|
141
|
+
if (!/^\d+$/.test(id))
|
|
142
|
+
throw new Error(`FlameComics: invalid series id '${mangaId}' (expected a number like '101')`);
|
|
143
|
+
|
|
144
|
+
const { series, chapters = [] } = await this.nextData<{ series?: FlameSeries; chapters?: FlameChapter[] }>(
|
|
145
|
+
`series/${id}`
|
|
146
|
+
);
|
|
147
|
+
if (!series?.title) throw new Error(`FlameComics: series ${id} not found`);
|
|
148
|
+
|
|
149
|
+
const info: IMangaInfo = this.toResult({ ...series, series_id: series.series_id ?? Number(id) });
|
|
150
|
+
const title = info.title as string;
|
|
151
|
+
const altTitles = strings(series.altTitles).filter((alt) => alt.toLowerCase() !== title.toLowerCase());
|
|
152
|
+
if (altTitles.length) info.altTitles = altTitles;
|
|
153
|
+
for (const [field, values] of [
|
|
154
|
+
['genres', series.tags],
|
|
155
|
+
['authors', series.author],
|
|
156
|
+
['artists', series.artist],
|
|
157
|
+
] as const) {
|
|
158
|
+
const list = strings(values);
|
|
159
|
+
if (list.length) info[field] = list;
|
|
127
160
|
}
|
|
161
|
+
// The site lists the newest chapter first.
|
|
162
|
+
info.chapters = sortChaptersForReading(chapters.map((chapter) => this.toChapter(chapter, id)).reverse());
|
|
163
|
+
return info;
|
|
128
164
|
};
|
|
129
165
|
|
|
166
|
+
/** @param chapterId chapter id from `fetchMangaInfo` (`"101/327c2f17ef9cacd3"`: series id / chapter token) */
|
|
130
167
|
override fetchChapterPages = async (chapterId: string): Promise<IMangaChapterPage[]> => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
throw new Error((err as Error).message);
|
|
150
|
-
}
|
|
168
|
+
const match = /^(\d+)\/([A-Za-z0-9]+)$/.exec(String(chapterId).trim());
|
|
169
|
+
if (!match) throw new Error(`FlameComics: invalid chapter id '${chapterId}' (expected '<seriesId>/<token>')`);
|
|
170
|
+
const seriesId = match[1]!;
|
|
171
|
+
const token = match[2]!;
|
|
172
|
+
|
|
173
|
+
const { chapter } = await this.nextData<{ chapter?: FlameReaderChapter }>(`series/${seriesId}/${token}`);
|
|
174
|
+
if (!chapter) throw new Error(`FlameComics: chapter ${chapterId} not found`);
|
|
175
|
+
|
|
176
|
+
// `images` is keyed by position ("0", "1", ...); the site adds the chapter's edit time to bust caches.
|
|
177
|
+
const version = chapter.edit_time ? `?${chapter.edit_time}` : '';
|
|
178
|
+
return Object.entries(chapter.images ?? {})
|
|
179
|
+
.sort(([a], [b]) => Number(a) - Number(b))
|
|
180
|
+
.map(([, image]) => image?.name)
|
|
181
|
+
.filter((name): name is string => typeof name === 'string' && name.length > 0)
|
|
182
|
+
.map((name, i) => ({
|
|
183
|
+
img: `${IMAGE_CDN}/${seriesId}/${token}/${encodeURIComponent(name)}${version}`,
|
|
184
|
+
page: i + 1,
|
|
185
|
+
}));
|
|
151
186
|
};
|
|
187
|
+
|
|
188
|
+
private toResult(series: FlameSeries): IMangaResult {
|
|
189
|
+
const id = String(series.series_id);
|
|
190
|
+
const result: IMangaResult = { id, title: series.title!.trim(), url: `${this.baseUrl}/series/${id}` };
|
|
191
|
+
// The site adds the series' edit time to cover URLs to bust caches.
|
|
192
|
+
if (series.cover) {
|
|
193
|
+
const version = series.last_edit ? `?${series.last_edit}` : '';
|
|
194
|
+
result.image = `${IMAGE_CDN}/${id}/${encodeURIComponent(series.cover)}${version}`;
|
|
195
|
+
}
|
|
196
|
+
const description = plainText(series.description);
|
|
197
|
+
if (description) result.description = description;
|
|
198
|
+
const status = series.status?.trim();
|
|
199
|
+
if (status) result.status = STATUS[status.toLowerCase()] ?? MediaStatus.UNKNOWN;
|
|
200
|
+
if (typeof series.year === 'number' && series.year > 0) result.releaseDate = series.year;
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private toChapter(chapter: FlameChapter, seriesId: string): IMangaChapter {
|
|
205
|
+
const id = `${chapter.series_id ?? seriesId}/${chapter.token}`;
|
|
206
|
+
const chapterNumber = parseChapterNumber(chapter.chapter);
|
|
207
|
+
// Labelled like the site: "Chapter 151 - Season 4 Start", or "Chapter 152" when it has no name.
|
|
208
|
+
const label = `Chapter ${chapterNumber ?? chapter.chapter ?? ''}`.trim();
|
|
209
|
+
const name = chapter.title?.trim();
|
|
210
|
+
const result: IMangaChapter = { id, title: name ? `${label} - ${name}` : label };
|
|
211
|
+
if (chapterNumber !== undefined) result.chapterNumber = chapterNumber;
|
|
212
|
+
const releaseDate = isoDate(chapter.release_date);
|
|
213
|
+
if (releaseDate) result.releaseDate = releaseDate;
|
|
214
|
+
result.url = `${this.baseUrl}/series/${id}`;
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** `pageProps` of a site page (`browse`, `series/101`), from its Next.js data route. */
|
|
219
|
+
private async nextData<T>(path: string, retried = false): Promise<T> {
|
|
220
|
+
const buildIdRequest = this.buildId();
|
|
221
|
+
const buildId = await buildIdRequest;
|
|
222
|
+
const { status, data } = await this.ctx.axios.get(`${this.baseUrl}/_next/data/${buildId}/${path}.json`, {
|
|
223
|
+
validateStatus: (code: number) => (code >= 200 && code < 300) || code === 404,
|
|
224
|
+
});
|
|
225
|
+
const json = parseJson(data);
|
|
226
|
+
if (status === 404) {
|
|
227
|
+
// A missing page answers `{ notFound: true }`. Otherwise a deploy replaced the build id, and every
|
|
228
|
+
// data route of the old one answers 404: look the id up again, once.
|
|
229
|
+
if (json?.notFound || retried) throw new Error(`FlameComics: /${path} not found`);
|
|
230
|
+
if (this.buildIdRequest === buildIdRequest) this.buildIdRequest = undefined;
|
|
231
|
+
return this.nextData<T>(path, true);
|
|
232
|
+
}
|
|
233
|
+
if (!json?.pageProps) throw new Error(`FlameComics: no page data for /${path}`);
|
|
234
|
+
return json.pageProps as T;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** The site's current Next.js build id, from the home page (looked up once, then reused). */
|
|
238
|
+
private buildId(): Promise<string> {
|
|
239
|
+
if (!this.buildIdRequest) {
|
|
240
|
+
this.buildIdRequest = this.ctx.axios
|
|
241
|
+
.get(`${this.baseUrl}/`)
|
|
242
|
+
.then(({ data }) => {
|
|
243
|
+
const buildId = /"buildId"\s*:\s*"([^"]+)"/.exec(String(data))?.[1];
|
|
244
|
+
if (!buildId) throw new Error('FlameComics: no Next.js build id on the home page');
|
|
245
|
+
return buildId;
|
|
246
|
+
})
|
|
247
|
+
.catch((err) => {
|
|
248
|
+
// Look it up again next time.
|
|
249
|
+
this.buildIdRequest = undefined;
|
|
250
|
+
throw err;
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return this.buildIdRequest;
|
|
254
|
+
}
|
|
152
255
|
}
|
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
import { MangaDex } from './mangadex';
|
|
2
|
-
import { ComicK } from './comick';
|
|
3
2
|
import { MangaHere } from './mangahere';
|
|
4
3
|
import { MangaKakalot } from './mangakakalot';
|
|
5
|
-
import { Mangasee123 } from './mangasee123';
|
|
6
|
-
import { Mangapark } from './mangapark';
|
|
7
4
|
import { MangaPill } from './mangapill';
|
|
8
|
-
import { MangaReader } from './mangareader';
|
|
9
5
|
import { AsuraScans } from './asurascans';
|
|
10
6
|
import { FlameScans } from './flamescans';
|
|
11
|
-
import { MangaHost } from './mangahost';
|
|
12
|
-
import { BRMangas } from './brmangas';
|
|
13
|
-
import { VyvyManga } from './vyvymanga';
|
|
14
7
|
|
|
15
8
|
export const MANGA = {
|
|
16
9
|
MangaDex,
|
|
17
|
-
ComicK,
|
|
18
10
|
MangaHere,
|
|
19
11
|
MangaKakalot,
|
|
20
|
-
Mangasee123,
|
|
21
|
-
Mangapark,
|
|
22
12
|
MangaPill,
|
|
23
|
-
MangaReader,
|
|
24
13
|
AsuraScans,
|
|
25
14
|
FlameScans,
|
|
26
|
-
MangaHost,
|
|
27
|
-
BRMangas,
|
|
28
|
-
VyvyManga,
|
|
29
15
|
};
|