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.
Files changed (211) hide show
  1. package/android/src/main/java/com/consumet/HttpRequestModule.kt +88 -33
  2. package/android/src/main/java/com/consumet/WebViewTask.kt +18 -3
  3. package/ios/Consumet.mm +172 -72
  4. package/lib/commonjs/NativeConsumet.ts +11 -5
  5. package/lib/commonjs/extension-registry.json +6 -6
  6. package/lib/commonjs/extension-registry.json.sig +1 -1
  7. package/lib/commonjs/extractors/kwik.js +28 -29
  8. package/lib/commonjs/extractors/kwik.js.map +1 -1
  9. package/lib/commonjs/index.js +18 -0
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/models/types.js +6 -0
  12. package/lib/commonjs/models/types.js.map +1 -1
  13. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js +12 -13
  14. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js.map +1 -1
  15. package/lib/commonjs/providers/manga/asurascans.js +160 -96
  16. package/lib/commonjs/providers/manga/asurascans.js.map +1 -1
  17. package/lib/commonjs/providers/manga/flamescans.js +173 -91
  18. package/lib/commonjs/providers/manga/flamescans.js.map +1 -1
  19. package/lib/commonjs/providers/manga/index.js +1 -15
  20. package/lib/commonjs/providers/manga/index.js.map +1 -1
  21. package/lib/commonjs/providers/manga/mangadex.js +234 -227
  22. package/lib/commonjs/providers/manga/mangadex.js.map +1 -1
  23. package/lib/commonjs/providers/manga/mangahere.js +279 -135
  24. package/lib/commonjs/providers/manga/mangahere.js.map +1 -1
  25. package/lib/commonjs/providers/manga/mangakakalot.js +206 -107
  26. package/lib/commonjs/providers/manga/mangakakalot.js.map +1 -1
  27. package/lib/commonjs/providers/manga/mangapill.js +126 -38
  28. package/lib/commonjs/providers/manga/mangapill.js.map +1 -1
  29. package/lib/commonjs/providers/meta/anilist.js +41 -12
  30. package/lib/commonjs/providers/meta/anilist.js.map +1 -1
  31. package/lib/commonjs/utils/index.js +19 -0
  32. package/lib/commonjs/utils/index.js.map +1 -1
  33. package/lib/commonjs/utils/manga.js +60 -0
  34. package/lib/commonjs/utils/manga.js.map +1 -0
  35. package/lib/module/NativeConsumet.ts +11 -5
  36. package/lib/module/extension-registry.json +6 -6
  37. package/lib/module/extension-registry.json.sig +1 -1
  38. package/lib/module/extractors/kwik.js +28 -29
  39. package/lib/module/extractors/kwik.js.map +1 -1
  40. package/lib/module/index.js +2 -2
  41. package/lib/module/index.js.map +1 -1
  42. package/lib/module/models/types.js +9 -0
  43. package/lib/module/models/types.js.map +1 -1
  44. package/lib/module/providers/anime/animepahe/create-animepahe.js +12 -13
  45. package/lib/module/providers/anime/animepahe/create-animepahe.js.map +1 -1
  46. package/lib/module/providers/manga/asurascans.js +161 -96
  47. package/lib/module/providers/manga/asurascans.js.map +1 -1
  48. package/lib/module/providers/manga/flamescans.js +174 -91
  49. package/lib/module/providers/manga/flamescans.js.map +1 -1
  50. package/lib/module/providers/manga/index.js +1 -15
  51. package/lib/module/providers/manga/index.js.map +1 -1
  52. package/lib/module/providers/manga/mangadex.js +236 -228
  53. package/lib/module/providers/manga/mangadex.js.map +1 -1
  54. package/lib/module/providers/manga/mangahere.js +276 -132
  55. package/lib/module/providers/manga/mangahere.js.map +1 -1
  56. package/lib/module/providers/manga/mangakakalot.js +207 -107
  57. package/lib/module/providers/manga/mangakakalot.js.map +1 -1
  58. package/lib/module/providers/manga/mangapill.js +128 -39
  59. package/lib/module/providers/manga/mangapill.js.map +1 -1
  60. package/lib/module/providers/meta/anilist.js +41 -12
  61. package/lib/module/providers/meta/anilist.js.map +1 -1
  62. package/lib/module/utils/index.js +1 -0
  63. package/lib/module/utils/index.js.map +1 -1
  64. package/lib/module/utils/manga.js +54 -0
  65. package/lib/module/utils/manga.js.map +1 -0
  66. package/lib/typescript/commonjs/src/NativeConsumet.d.ts +11 -5
  67. package/lib/typescript/commonjs/src/NativeConsumet.d.ts.map +1 -1
  68. package/lib/typescript/commonjs/src/extractors/kwik.d.ts +1 -1
  69. package/lib/typescript/commonjs/src/extractors/kwik.d.ts.map +1 -1
  70. package/lib/typescript/commonjs/src/index.d.ts +2 -2
  71. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  72. package/lib/typescript/commonjs/src/models/types.d.ts +38 -5
  73. package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
  74. package/lib/typescript/commonjs/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/src/providers/manga/asurascans.d.ts +14 -4
  76. package/lib/typescript/commonjs/src/providers/manga/asurascans.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/src/providers/manga/flamescans.d.ts +18 -3
  78. package/lib/typescript/commonjs/src/providers/manga/flamescans.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/src/providers/manga/index.d.ts +0 -14
  80. package/lib/typescript/commonjs/src/providers/manga/index.d.ts.map +1 -1
  81. package/lib/typescript/commonjs/src/providers/manga/mangadex.d.ts +22 -5
  82. package/lib/typescript/commonjs/src/providers/manga/mangadex.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/src/providers/manga/mangahere.d.ts +15 -3
  84. package/lib/typescript/commonjs/src/providers/manga/mangahere.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/src/providers/manga/mangakakalot.d.ts +26 -4
  86. package/lib/typescript/commonjs/src/providers/manga/mangakakalot.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/src/providers/manga/mangapill.d.ts +16 -2
  88. package/lib/typescript/commonjs/src/providers/manga/mangapill.d.ts.map +1 -1
  89. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/src/utils/index.d.ts +1 -0
  91. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/src/utils/manga.d.ts +19 -0
  93. package/lib/typescript/commonjs/src/utils/manga.d.ts.map +1 -0
  94. package/lib/typescript/module/src/NativeConsumet.d.ts +11 -5
  95. package/lib/typescript/module/src/NativeConsumet.d.ts.map +1 -1
  96. package/lib/typescript/module/src/extractors/kwik.d.ts +1 -1
  97. package/lib/typescript/module/src/extractors/kwik.d.ts.map +1 -1
  98. package/lib/typescript/module/src/index.d.ts +2 -2
  99. package/lib/typescript/module/src/index.d.ts.map +1 -1
  100. package/lib/typescript/module/src/models/types.d.ts +38 -5
  101. package/lib/typescript/module/src/models/types.d.ts.map +1 -1
  102. package/lib/typescript/module/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  103. package/lib/typescript/module/src/providers/manga/asurascans.d.ts +14 -4
  104. package/lib/typescript/module/src/providers/manga/asurascans.d.ts.map +1 -1
  105. package/lib/typescript/module/src/providers/manga/flamescans.d.ts +18 -3
  106. package/lib/typescript/module/src/providers/manga/flamescans.d.ts.map +1 -1
  107. package/lib/typescript/module/src/providers/manga/index.d.ts +0 -14
  108. package/lib/typescript/module/src/providers/manga/index.d.ts.map +1 -1
  109. package/lib/typescript/module/src/providers/manga/mangadex.d.ts +22 -5
  110. package/lib/typescript/module/src/providers/manga/mangadex.d.ts.map +1 -1
  111. package/lib/typescript/module/src/providers/manga/mangahere.d.ts +15 -3
  112. package/lib/typescript/module/src/providers/manga/mangahere.d.ts.map +1 -1
  113. package/lib/typescript/module/src/providers/manga/mangakakalot.d.ts +26 -4
  114. package/lib/typescript/module/src/providers/manga/mangakakalot.d.ts.map +1 -1
  115. package/lib/typescript/module/src/providers/manga/mangapill.d.ts +16 -2
  116. package/lib/typescript/module/src/providers/manga/mangapill.d.ts.map +1 -1
  117. package/lib/typescript/module/src/providers/meta/anilist.d.ts.map +1 -1
  118. package/lib/typescript/module/src/utils/index.d.ts +1 -0
  119. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  120. package/lib/typescript/module/src/utils/manga.d.ts +19 -0
  121. package/lib/typescript/module/src/utils/manga.d.ts.map +1 -0
  122. package/package.json +1 -1
  123. package/src/NativeConsumet.ts +11 -5
  124. package/src/extension-registry.json +6 -6
  125. package/src/extension-registry.json.sig +1 -1
  126. package/src/extractors/kwik.ts +30 -43
  127. package/src/index.tsx +6 -0
  128. package/src/models/types.ts +38 -3
  129. package/src/providers/anime/animepahe/create-animepahe.ts +15 -14
  130. package/src/providers/manga/asurascans.ts +200 -135
  131. package/src/providers/manga/flamescans.ts +221 -118
  132. package/src/providers/manga/index.ts +0 -14
  133. package/src/providers/manga/mangadex.ts +335 -282
  134. package/src/providers/manga/mangahere.ts +309 -156
  135. package/src/providers/manga/mangakakalot.ts +249 -152
  136. package/src/providers/manga/mangapill.ts +163 -64
  137. package/src/providers/meta/anilist.ts +50 -14
  138. package/src/utils/index.ts +1 -0
  139. package/src/utils/manga.ts +58 -0
  140. package/lib/commonjs/providers/manga/brmangas.js +0 -110
  141. package/lib/commonjs/providers/manga/brmangas.js.map +0 -1
  142. package/lib/commonjs/providers/manga/comick.js +0 -154
  143. package/lib/commonjs/providers/manga/comick.js.map +0 -1
  144. package/lib/commonjs/providers/manga/mangahost.js +0 -113
  145. package/lib/commonjs/providers/manga/mangahost.js.map +0 -1
  146. package/lib/commonjs/providers/manga/mangapark.js +0 -97
  147. package/lib/commonjs/providers/manga/mangapark.js.map +0 -1
  148. package/lib/commonjs/providers/manga/mangareader.js +0 -106
  149. package/lib/commonjs/providers/manga/mangareader.js.map +0 -1
  150. package/lib/commonjs/providers/manga/mangasee123.js +0 -161
  151. package/lib/commonjs/providers/manga/mangasee123.js.map +0 -1
  152. package/lib/commonjs/providers/manga/readmanga.js +0 -269
  153. package/lib/commonjs/providers/manga/readmanga.js.map +0 -1
  154. package/lib/commonjs/providers/manga/vyvymanga.js +0 -166
  155. package/lib/commonjs/providers/manga/vyvymanga.js.map +0 -1
  156. package/lib/module/providers/manga/brmangas.js +0 -105
  157. package/lib/module/providers/manga/brmangas.js.map +0 -1
  158. package/lib/module/providers/manga/comick.js +0 -149
  159. package/lib/module/providers/manga/comick.js.map +0 -1
  160. package/lib/module/providers/manga/mangahost.js +0 -108
  161. package/lib/module/providers/manga/mangahost.js.map +0 -1
  162. package/lib/module/providers/manga/mangapark.js +0 -92
  163. package/lib/module/providers/manga/mangapark.js.map +0 -1
  164. package/lib/module/providers/manga/mangareader.js +0 -101
  165. package/lib/module/providers/manga/mangareader.js.map +0 -1
  166. package/lib/module/providers/manga/mangasee123.js +0 -156
  167. package/lib/module/providers/manga/mangasee123.js.map +0 -1
  168. package/lib/module/providers/manga/readmanga.js +0 -264
  169. package/lib/module/providers/manga/readmanga.js.map +0 -1
  170. package/lib/module/providers/manga/vyvymanga.js +0 -161
  171. package/lib/module/providers/manga/vyvymanga.js.map +0 -1
  172. package/lib/typescript/commonjs/src/providers/manga/brmangas.d.ts +0 -18
  173. package/lib/typescript/commonjs/src/providers/manga/brmangas.d.ts.map +0 -1
  174. package/lib/typescript/commonjs/src/providers/manga/comick.d.ts +0 -39
  175. package/lib/typescript/commonjs/src/providers/manga/comick.d.ts.map +0 -1
  176. package/lib/typescript/commonjs/src/providers/manga/mangahost.d.ts +0 -18
  177. package/lib/typescript/commonjs/src/providers/manga/mangahost.d.ts.map +0 -1
  178. package/lib/typescript/commonjs/src/providers/manga/mangapark.d.ts +0 -14
  179. package/lib/typescript/commonjs/src/providers/manga/mangapark.d.ts.map +0 -1
  180. package/lib/typescript/commonjs/src/providers/manga/mangareader.d.ts +0 -18
  181. package/lib/typescript/commonjs/src/providers/manga/mangareader.d.ts.map +0 -1
  182. package/lib/typescript/commonjs/src/providers/manga/mangasee123.d.ts +0 -17
  183. package/lib/typescript/commonjs/src/providers/manga/mangasee123.d.ts.map +0 -1
  184. package/lib/typescript/commonjs/src/providers/manga/readmanga.d.ts +0 -31
  185. package/lib/typescript/commonjs/src/providers/manga/readmanga.d.ts.map +0 -1
  186. package/lib/typescript/commonjs/src/providers/manga/vyvymanga.d.ts +0 -17
  187. package/lib/typescript/commonjs/src/providers/manga/vyvymanga.d.ts.map +0 -1
  188. package/lib/typescript/module/src/providers/manga/brmangas.d.ts +0 -18
  189. package/lib/typescript/module/src/providers/manga/brmangas.d.ts.map +0 -1
  190. package/lib/typescript/module/src/providers/manga/comick.d.ts +0 -39
  191. package/lib/typescript/module/src/providers/manga/comick.d.ts.map +0 -1
  192. package/lib/typescript/module/src/providers/manga/mangahost.d.ts +0 -18
  193. package/lib/typescript/module/src/providers/manga/mangahost.d.ts.map +0 -1
  194. package/lib/typescript/module/src/providers/manga/mangapark.d.ts +0 -14
  195. package/lib/typescript/module/src/providers/manga/mangapark.d.ts.map +0 -1
  196. package/lib/typescript/module/src/providers/manga/mangareader.d.ts +0 -18
  197. package/lib/typescript/module/src/providers/manga/mangareader.d.ts.map +0 -1
  198. package/lib/typescript/module/src/providers/manga/mangasee123.d.ts +0 -17
  199. package/lib/typescript/module/src/providers/manga/mangasee123.d.ts.map +0 -1
  200. package/lib/typescript/module/src/providers/manga/readmanga.d.ts +0 -31
  201. package/lib/typescript/module/src/providers/manga/readmanga.d.ts.map +0 -1
  202. package/lib/typescript/module/src/providers/manga/vyvymanga.d.ts +0 -17
  203. package/lib/typescript/module/src/providers/manga/vyvymanga.d.ts.map +0 -1
  204. package/src/providers/manga/brmangas.ts +0 -148
  205. package/src/providers/manga/comick.ts +0 -285
  206. package/src/providers/manga/mangahost.ts +0 -134
  207. package/src/providers/manga/mangapark.ts +0 -115
  208. package/src/providers/manga/mangareader.ts +0 -132
  209. package/src/providers/manga/mangasee123.ts +0 -187
  210. package/src/providers/manga/readmanga.ts +0 -380
  211. package/src/providers/manga/vyvymanga.ts +0 -237
@@ -15,10 +15,10 @@
15
15
  },
16
16
  {
17
17
  "name": "Kwik",
18
- "version": "1.2.4",
18
+ "version": "1.2.5",
19
19
  "minContextVersion": 1,
20
- "main": "https://raw.githubusercontent.com/uwumilabs/react-native-consumet/refs/heads/main/registry/extractors/kwik/1.2.4.js",
21
- "sha256": "625158a91f9272470f9c645621133074f11f99b292680920494e14bbe9005d4c",
20
+ "main": "https://raw.githubusercontent.com/uwumilabs/react-native-consumet/refs/heads/main/registry/extractors/kwik/1.2.5.js",
21
+ "sha256": "d4b4992d35d6e8f5e00143deaf61e0c54c5bd1f402a64f376e8550dd77dbb68a",
22
22
  "distFile": "dist/bundles/extractors/kwik.js"
23
23
  },
24
24
  {
@@ -75,14 +75,14 @@
75
75
  "id": "animepahe",
76
76
  "name": "AnimePahe",
77
77
  "description": "High-quality anime streaming from AnimePahe with multiple servers and subtitles",
78
- "version": "1.2.6",
78
+ "version": "1.2.7",
79
79
  "minContextVersion": 1,
80
80
  "author": {
81
81
  "name": "RNConsumet Team",
82
82
  "url": "https://github.com/uwumilabs"
83
83
  },
84
84
  "category": "anime",
85
- "main": "https://raw.githubusercontent.com/uwumilabs/react-native-consumet/refs/heads/main/registry/extensions/animepahe/1.2.6.js",
85
+ "main": "https://raw.githubusercontent.com/uwumilabs/react-native-consumet/refs/heads/main/registry/extensions/animepahe/1.2.7.js",
86
86
  "factoryName": "createAnimePahe",
87
87
  "baseUrl": "https://animepahe.pw",
88
88
  "logo": "https://animepahe.pw/web-app-manifest-512x512.png",
@@ -100,7 +100,7 @@
100
100
  "dubbed": true,
101
101
  "isSourceEmbed": true,
102
102
  "haveMultiServers": false,
103
- "sha256": "a2c83cc43c95f2224c599e805d9f5dfc9b89b3c36713c20c6ef063790f31013d",
103
+ "sha256": "63b4fbf8c7333984e518545171571d43cd983479c9b1f14b9c194beec5966811",
104
104
  "distFile": "dist/bundles/providers/anime/animepahe/create-animepahe.js"
105
105
  },
106
106
  {
@@ -1 +1 @@
1
- 8be845fade449ff71e43fddcdf44eb39618a1811e13b598d188ae20abc689397a0e21cb02e1c3c748764e71db0e78d0ca126611ba4d05e8a090f81cf096b3f0f
1
+ fa54678c129da118d355e4e5c0d0077224807ca6deb394e653ddc067c65958d371b89425d58e09836631c4b1c2ca19ef1520b73ca9dc9170598c56b9b3c56b0e
@@ -3,26 +3,22 @@ import type { PolyURL } from '../utils/url-polyfill';
3
3
 
4
4
  /**
5
5
  * Kwik extractor function
6
- * @param ctx ExtractorContext containing axios, load, USER_AGENT
6
+ * @param ctx ExtractorContext; the embed page is loaded through its NativeConsumet WebView
7
7
  * @returns Object with extract method implementing IVideoExtractor interface
8
8
  */
9
9
  export function Kwik(ctx: ExtractorContext): IVideoExtractor {
10
10
  const serverName = 'kwik';
11
11
  const sources: IVideo[] = [];
12
- const { load, USER_AGENT, NativeConsumet } = ctx;
12
+ const { NativeConsumet } = ctx;
13
13
 
14
- const ua =
15
- USER_AGENT ||
16
- 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36';
14
+ // One eval(function(p,a,c,k,e,d){...}('payload',base,count,'words'.split('|'))) block.
15
+ const PACKED =
16
+ /\beval\s*\(\s*function\s*\(\s*p\s*,\s*a\s*,\s*c\s*,\s*k\s*,\s*e\s*,\s*[dr]\s*\)\s*\{[\s\S]+?\}\s*\(\s*'([\s\S]+?)'\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*'([\s\S]+?)'\s*\.split\s*\(\s*'(.+?)'\s*\)/;
17
17
 
18
- function unpackPacked(packed: string): string | null {
19
- const re =
20
- /\beval\s*\(\s*function\s*\(\s*p\s*,\s*a\s*,\s*c\s*,\s*k\s*,\s*e\s*,\s*[dr]\s*\)\s*\{[\s\S]+?\}\s*\(\s*'([\s\S]+?)'\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*'([\s\S]+?)'\s*\.split\s*\(\s*'(.+?)'\s*\)/;
21
-
22
- const m = packed.match(re);
23
- if (!m) return null;
24
-
25
- const encoded = m[1]!;
18
+ /** The code of one packed block. */
19
+ function unpackPacked(m: RegExpMatchArray): string {
20
+ // The payload is the source of a single-quoted string: undo its escapes (\' and \\).
21
+ const encoded = m[1]!.replace(/\\(['"\\])/g, '$1');
26
22
  const base = parseInt(m[2]!, 10);
27
23
  const count = parseInt(m[3]!, 10);
28
24
  const words = m[4]!.split(m[5]!);
@@ -42,46 +38,37 @@ export function Kwik(ctx: ExtractorContext): IVideoExtractor {
42
38
  return result;
43
39
  }
44
40
 
41
+ /** The stream URL in a Kwik embed page; the page packs several scripts, only one has it. */
42
+ function findSource(html: string): string | null {
43
+ const packed = new RegExp(PACKED.source, 'g');
44
+ let block: RegExpExecArray | null;
45
+ while ((block = packed.exec(html))) {
46
+ const code = unpackPacked(block);
47
+ const source =
48
+ code.match(/const\s+source\s*=\s*'([^']+)'/) ||
49
+ code.match(/const\s+source\s*=\s*"([^"]+)"/) ||
50
+ code.match(/['"](https?:\/\/[^'"]+\.m3u8[^'"]*)['"]/);
51
+ if (source?.[1]) return source[1];
52
+ }
53
+ return null;
54
+ }
55
+
45
56
  // @ts-ignore
46
57
  const extract = async (videoUrl: PolyURL, referer = 'https://animepahe.ru/'): Promise<ISource> => {
47
58
  const kwikUrl = typeof videoUrl === 'string' ? videoUrl : (videoUrl as any).href;
48
59
  const kwikHost = kwikUrl.match(/^https?:\/\/([^/]+)/)?.[1] ?? 'kwik.cx';
49
60
 
61
+ // No User-Agent: the WebView's own keeps a Cloudflare clearance valid (see AnimePahe).
50
62
  const { html } = await NativeConsumet.makeGetRequestWithWebView(kwikUrl, {
51
- 'Referer': referer,
52
- 'User-Agent': ua,
63
+ Referer: referer,
53
64
  });
54
65
 
55
- const $ = load(html);
56
- let packedScript: string | null = null;
57
-
58
- $('script').each((_, el) => {
59
- const text = $(el).html() ?? '';
60
- if (text.includes('eval(function(p,a,c,k,e,')) {
61
- packedScript = text;
62
- return false;
63
- }
64
- });
65
-
66
- if (!packedScript) {
67
- const m = html.match(/eval\(function\(p,a,c,k,e,[dr]\)[\s\S]+?\.split\(['"]\|['"]\)[\s\S]+?\)/);
68
- packedScript = m?.[0] ?? null;
66
+ const m3u8 = findSource(html);
67
+ if (!m3u8) {
68
+ const packed = html.includes('eval(function(p,a,c,k,e,');
69
+ throw new Error(packed ? '[Kwik] No source URL found' : '[Kwik] No packed script found');
69
70
  }
70
71
 
71
- if (!packedScript) throw new Error('[Kwik] No packed script found');
72
-
73
- const unpacked = unpackPacked(packedScript);
74
- if (!unpacked) throw new Error('[Kwik] Failed to unpack script');
75
-
76
- const sourceMatch =
77
- unpacked.match(/const\s+source\s*=\s*'([^']+)'/) ||
78
- unpacked.match(/const\s+source\s*=\s*"([^"]+)"/) ||
79
- unpacked.match(/['"]?(https?:\/\/[^'"]+\.m3u8[^'"]*)['"]/);
80
-
81
- if (!sourceMatch?.[1]) throw new Error('[Kwik] No source URL found');
82
-
83
- const m3u8 = sourceMatch[1];
84
-
85
72
  return {
86
73
  sources: [{ url: m3u8, isM3U8: m3u8.includes('.m3u8') }],
87
74
  headers: { Referer: `https://${kwikHost}/` },
package/src/index.tsx CHANGED
@@ -51,6 +51,9 @@ import {
51
51
  RegistrySignatureError,
52
52
  verifyRegistrySignature,
53
53
  parseSignedRegistry,
54
+ parseChapterNumber,
55
+ parseVolumeNumber,
56
+ sortChaptersForReading,
54
57
  } from './utils';
55
58
  import type {
56
59
  IntegrityErrorCode,
@@ -275,6 +278,9 @@ export {
275
278
  RegistrySignatureError,
276
279
  verifyRegistrySignature,
277
280
  parseSignedRegistry,
281
+ parseChapterNumber,
282
+ parseVolumeNumber,
283
+ sortChaptersForReading,
278
284
  MetaError,
279
285
  };
280
286
  export type { MetaErrorSource };
@@ -308,39 +308,74 @@ export enum SubOrDub {
308
308
  BOTH = 'both',
309
309
  }
310
310
 
311
+ /**
312
+ * A manga search result. Sites describe titles differently, so most fields are optional; every
313
+ * provider fills the ones its site has, in the same shape (see docs/guides/manga.md).
314
+ */
311
315
  export interface IMangaResult {
316
+ /** Provider id of the title, passed to `fetchMangaInfo`. Stable across calls. */
312
317
  id: string;
313
- title: string | [lang: string][] | ITitle;
314
- altTitles?: string | string[] | [lang: string][];
318
+ /** Display title. Manga providers return a string; meta providers (AniList) return an `ITitle`. */
319
+ title: string | ITitle;
320
+ /** The title in other languages or spellings. */
321
+ altTitles?: string[];
322
+ /** Absolute cover image URL. */
315
323
  image?: string;
316
- description?: string | [lang: string][] | { [lang: string]: string };
324
+ /** Headers the cover image request needs (e.g. Referer) when the image host refuses hotlinks. */
325
+ headerForImage?: Record<string, string>;
326
+ /** Plain-text synopsis. */
327
+ description?: string;
317
328
  status?: MediaStatus;
318
329
  releaseDate?: number | string;
330
+ /** Absolute URL of the title's page on the site. */
331
+ url?: string;
319
332
  [x: string]: unknown; // other fields
320
333
  }
321
334
 
335
+ /** One chapter of a title. */
322
336
  export interface IMangaChapter {
337
+ /** Provider id of the chapter, passed to `fetchChapterPages`. */
323
338
  id: string;
339
+ /** Always a string: the chapter's name, or `Chapter 12` when the site gives none. */
324
340
  title: string;
341
+ /** Chapter number (`12`, `10.5`) when the site gives one; chapter lists are ordered by it. */
342
+ chapterNumber?: number;
343
+ /** Volume number when the site gives one. */
344
+ volumeNumber?: number;
345
+ /** @deprecated Use `volumeNumber`. */
325
346
  volume?: number;
326
347
  pages?: number;
348
+ /** ISO 8601 date when it can be parsed, otherwise the site's own text. */
327
349
  releaseDate?: string;
350
+ /** Scanlation group, when the site credits one. */
351
+ scanlator?: string;
352
+ /** Language of the chapter (ISO 639-1, e.g. `en`, with a region when the site has one, e.g. `pt-br`). */
353
+ language?: string;
354
+ /** Absolute URL of the chapter on the site. */
355
+ url?: string;
328
356
  [x: string]: unknown; // other fields
329
357
  }
330
358
 
331
359
  export interface IMangaInfo extends IMangaResult {
332
360
  malId?: number | string;
333
361
  authors?: string[];
362
+ artists?: string[];
334
363
  genres?: string[];
335
364
  links?: string[];
336
365
  characters?: any[];
337
366
  recommendations?: IMangaResult[];
367
+ /** In reading order: the first chapter first (see `sortChaptersForReading`). */
338
368
  chapters?: IMangaChapter[];
339
369
  }
340
370
 
371
+ /** One page image of a chapter. */
341
372
  export interface IMangaChapterPage {
373
+ /** Absolute image URL. */
342
374
  img: string;
375
+ /** Position in the chapter, starting at 1. */
343
376
  page: number;
377
+ /** Headers the image request needs (e.g. Referer). Set on every page when the host needs them. */
378
+ headerForImage?: Record<string, string>;
344
379
  [x: string]: unknown; // other fields
345
380
  }
346
381
 
@@ -34,15 +34,20 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
34
34
  isDubAvailableSeparately: true,
35
35
  };
36
36
 
37
- const UA =
38
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36';
39
-
40
37
  // ── WebView helpers ────────────────────────────────────────────────────────
41
- let _challengePassed = false;
42
- const ensureChallengePassed = async () => {
43
- if (_challengePassed) return;
44
- await makeGetRequestWithWebView(config.baseUrl, { 'User-Agent': UA });
45
- _challengePassed = true;
38
+ let challenge: Promise<void> | undefined;
39
+ const ensureChallengePassed = (): Promise<void> => {
40
+ // Searches running at once share one challenge load.
41
+ if (!challenge) {
42
+ challenge = makeGetRequestWithWebView(config.baseUrl, {}).then(
43
+ () => undefined,
44
+ (err: unknown) => {
45
+ challenge = undefined;
46
+ throw err;
47
+ }
48
+ );
49
+ }
50
+ return challenge;
46
51
  };
47
52
 
48
53
  const withRetry = async <T>(fn: () => Promise<T>, retries = 2): Promise<T> => {
@@ -64,12 +69,11 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
64
69
  }
65
70
  };
66
71
 
67
- // Fetches an HTML page through the WebView (bypasses DDoS-Guard JS challenge).
72
+ // Fetches an HTML page through the WebView, which gets past the Cloudflare challenge.
68
73
  const webViewGet = async (url: string, referer?: string): Promise<string> => {
69
74
  return withRetry(async () => {
70
75
  const res = await makeGetRequestWithWebView(url, {
71
- 'User-Agent': UA,
72
- 'Referer': referer ?? config.baseUrl,
76
+ Referer: referer ?? config.baseUrl,
73
77
  });
74
78
  return res.html ?? '';
75
79
  });
@@ -78,14 +82,11 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
78
82
  const webViewGetJson = async <T = any>(url: string, referer?: string): Promise<T> => {
79
83
  return withRetry(async () => {
80
84
  const res = await makeGetRequestWithWebView(url, {
81
- 'User-Agent': UA,
82
85
  'Accept': 'application/json, text/javascript, */*; q=0.01',
83
86
  'X-Requested-With': 'XMLHttpRequest',
84
87
  'Referer': referer ?? config.baseUrl,
85
88
  });
86
89
  const raw = (res.html ?? '').replace(/<[^>]*>/g, '').trim();
87
- console.log(raw);
88
-
89
90
  if (!raw) throw new Error(`[AnimePahe] Empty response from ${url}`);
90
91
  return JSON.parse(raw) as T;
91
92
  });