react-native-consumet 1.4.0 → 1.5.0

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 (157) hide show
  1. package/lib/commonjs/extension-registry.json +30 -1
  2. package/lib/commonjs/extractors/flixcloud.js +179 -0
  3. package/lib/commonjs/extractors/flixcloud.js.map +1 -0
  4. package/lib/commonjs/extractors/index.js +7 -0
  5. package/lib/commonjs/extractors/index.js.map +1 -1
  6. package/lib/commonjs/extractors/kwik.js +59 -74
  7. package/lib/commonjs/extractors/kwik.js.map +1 -1
  8. package/lib/commonjs/extractors/megaplay.js +196 -124
  9. package/lib/commonjs/extractors/megaplay.js.map +1 -1
  10. package/lib/commonjs/extractors/vidhide.js +9 -2
  11. package/lib/commonjs/extractors/vidhide.js.map +1 -1
  12. package/lib/commonjs/models/types.js +1 -0
  13. package/lib/commonjs/models/types.js.map +1 -1
  14. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js +107 -137
  15. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js.map +1 -1
  16. package/lib/commonjs/providers/anime/anineko/anineko.js +31 -0
  17. package/lib/commonjs/providers/anime/anineko/anineko.js.map +1 -0
  18. package/lib/commonjs/providers/anime/anineko/create-anineko.js +447 -0
  19. package/lib/commonjs/providers/anime/anineko/create-anineko.js.map +1 -0
  20. package/lib/commonjs/providers/anime/index.js +9 -1
  21. package/lib/commonjs/providers/anime/index.js.map +1 -1
  22. package/lib/commonjs/providers/anime/reanime/create-reanime.js +255 -0
  23. package/lib/commonjs/providers/anime/reanime/create-reanime.js.map +1 -0
  24. package/lib/commonjs/providers/anime/reanime/reanime.js +31 -0
  25. package/lib/commonjs/providers/anime/reanime/reanime.js.map +1 -0
  26. package/lib/commonjs/utils/ExtractorManager.js +8 -1
  27. package/lib/commonjs/utils/ExtractorManager.js.map +1 -1
  28. package/lib/commonjs/utils/ProviderManager.js +8 -1
  29. package/lib/commonjs/utils/ProviderManager.js.map +1 -1
  30. package/lib/commonjs/utils/create-extractor-context.js +3 -0
  31. package/lib/commonjs/utils/create-extractor-context.js.map +1 -1
  32. package/lib/commonjs/utils/create-provider-context.js +2 -0
  33. package/lib/commonjs/utils/create-provider-context.js.map +1 -1
  34. package/lib/commonjs/utils/extension-utils.js +6 -2
  35. package/lib/commonjs/utils/extension-utils.js.map +1 -1
  36. package/lib/module/extension-registry.json +30 -1
  37. package/lib/module/extractors/flixcloud.js +174 -0
  38. package/lib/module/extractors/flixcloud.js.map +1 -0
  39. package/lib/module/extractors/index.js +2 -1
  40. package/lib/module/extractors/index.js.map +1 -1
  41. package/lib/module/extractors/kwik.js +58 -74
  42. package/lib/module/extractors/kwik.js.map +1 -1
  43. package/lib/module/extractors/megaplay.js +196 -123
  44. package/lib/module/extractors/megaplay.js.map +1 -1
  45. package/lib/module/extractors/vidhide.js +8 -2
  46. package/lib/module/extractors/vidhide.js.map +1 -1
  47. package/lib/module/models/types.js +1 -0
  48. package/lib/module/models/types.js.map +1 -1
  49. package/lib/module/providers/anime/animepahe/create-animepahe.js +107 -138
  50. package/lib/module/providers/anime/animepahe/create-animepahe.js.map +1 -1
  51. package/lib/module/providers/anime/anineko/anineko.js +25 -0
  52. package/lib/module/providers/anime/anineko/anineko.js.map +1 -0
  53. package/lib/module/providers/anime/anineko/create-anineko.js +443 -0
  54. package/lib/module/providers/anime/anineko/create-anineko.js.map +1 -0
  55. package/lib/module/providers/anime/index.js +9 -1
  56. package/lib/module/providers/anime/index.js.map +1 -1
  57. package/lib/module/providers/anime/reanime/create-reanime.js +251 -0
  58. package/lib/module/providers/anime/reanime/create-reanime.js.map +1 -0
  59. package/lib/module/providers/anime/reanime/reanime.js +25 -0
  60. package/lib/module/providers/anime/reanime/reanime.js.map +1 -0
  61. package/lib/module/utils/ExtractorManager.js +8 -1
  62. package/lib/module/utils/ExtractorManager.js.map +1 -1
  63. package/lib/module/utils/ProviderManager.js +8 -1
  64. package/lib/module/utils/ProviderManager.js.map +1 -1
  65. package/lib/module/utils/create-extractor-context.js +2 -0
  66. package/lib/module/utils/create-extractor-context.js.map +1 -1
  67. package/lib/module/utils/create-provider-context.js +2 -0
  68. package/lib/module/utils/create-provider-context.js.map +1 -1
  69. package/lib/module/utils/extension-utils.js +7 -3
  70. package/lib/module/utils/extension-utils.js.map +1 -1
  71. package/lib/typescript/commonjs/src/extractors/flixcloud.d.ts +18 -0
  72. package/lib/typescript/commonjs/src/extractors/flixcloud.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/src/extractors/index.d.ts +2 -1
  74. package/lib/typescript/commonjs/src/extractors/index.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/src/extractors/kwik.d.ts +1 -0
  76. package/lib/typescript/commonjs/src/extractors/kwik.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/src/extractors/megaplay.d.ts +1 -1
  78. package/lib/typescript/commonjs/src/extractors/megaplay.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/src/extractors/vidhide.d.ts +1 -0
  80. package/lib/typescript/commonjs/src/extractors/vidhide.d.ts.map +1 -1
  81. package/lib/typescript/commonjs/src/models/extractor-context.d.ts +3 -0
  82. package/lib/typescript/commonjs/src/models/extractor-context.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/src/models/provider-context.d.ts +6 -0
  84. package/lib/typescript/commonjs/src/models/provider-context.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/src/models/types.d.ts +2 -1
  86. package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/src/providers/anime/anineko/anineko.d.ts +23 -0
  89. package/lib/typescript/commonjs/src/providers/anime/anineko/anineko.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/providers/anime/anineko/create-anineko.d.ts +52 -0
  91. package/lib/typescript/commonjs/src/providers/anime/anineko/create-anineko.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/providers/anime/index.d.ts +8 -0
  93. package/lib/typescript/commonjs/src/providers/anime/index.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/src/providers/anime/reanime/create-reanime.d.ts +18 -0
  95. package/lib/typescript/commonjs/src/providers/anime/reanime/create-reanime.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/providers/anime/reanime/reanime.d.ts +19 -0
  97. package/lib/typescript/commonjs/src/providers/anime/reanime/reanime.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/utils/ExtractorManager.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/src/utils/create-extractor-context.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/src/utils/create-provider-context.d.ts.map +1 -1
  102. package/lib/typescript/commonjs/src/utils/extension-utils.d.ts +2 -0
  103. package/lib/typescript/commonjs/src/utils/extension-utils.d.ts.map +1 -1
  104. package/lib/typescript/module/src/extractors/flixcloud.d.ts +18 -0
  105. package/lib/typescript/module/src/extractors/flixcloud.d.ts.map +1 -0
  106. package/lib/typescript/module/src/extractors/index.d.ts +2 -1
  107. package/lib/typescript/module/src/extractors/index.d.ts.map +1 -1
  108. package/lib/typescript/module/src/extractors/kwik.d.ts +1 -0
  109. package/lib/typescript/module/src/extractors/kwik.d.ts.map +1 -1
  110. package/lib/typescript/module/src/extractors/megaplay.d.ts +1 -1
  111. package/lib/typescript/module/src/extractors/megaplay.d.ts.map +1 -1
  112. package/lib/typescript/module/src/extractors/vidhide.d.ts +1 -0
  113. package/lib/typescript/module/src/extractors/vidhide.d.ts.map +1 -1
  114. package/lib/typescript/module/src/models/extractor-context.d.ts +3 -0
  115. package/lib/typescript/module/src/models/extractor-context.d.ts.map +1 -1
  116. package/lib/typescript/module/src/models/provider-context.d.ts +6 -0
  117. package/lib/typescript/module/src/models/provider-context.d.ts.map +1 -1
  118. package/lib/typescript/module/src/models/types.d.ts +2 -1
  119. package/lib/typescript/module/src/models/types.d.ts.map +1 -1
  120. package/lib/typescript/module/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  121. package/lib/typescript/module/src/providers/anime/anineko/anineko.d.ts +23 -0
  122. package/lib/typescript/module/src/providers/anime/anineko/anineko.d.ts.map +1 -0
  123. package/lib/typescript/module/src/providers/anime/anineko/create-anineko.d.ts +52 -0
  124. package/lib/typescript/module/src/providers/anime/anineko/create-anineko.d.ts.map +1 -0
  125. package/lib/typescript/module/src/providers/anime/index.d.ts +8 -0
  126. package/lib/typescript/module/src/providers/anime/index.d.ts.map +1 -1
  127. package/lib/typescript/module/src/providers/anime/reanime/create-reanime.d.ts +18 -0
  128. package/lib/typescript/module/src/providers/anime/reanime/create-reanime.d.ts.map +1 -0
  129. package/lib/typescript/module/src/providers/anime/reanime/reanime.d.ts +19 -0
  130. package/lib/typescript/module/src/providers/anime/reanime/reanime.d.ts.map +1 -0
  131. package/lib/typescript/module/src/utils/ExtractorManager.d.ts.map +1 -1
  132. package/lib/typescript/module/src/utils/ProviderManager.d.ts.map +1 -1
  133. package/lib/typescript/module/src/utils/create-extractor-context.d.ts.map +1 -1
  134. package/lib/typescript/module/src/utils/create-provider-context.d.ts.map +1 -1
  135. package/lib/typescript/module/src/utils/extension-utils.d.ts +2 -0
  136. package/lib/typescript/module/src/utils/extension-utils.d.ts.map +1 -1
  137. package/package.json +1 -1
  138. package/src/extension-registry.json +30 -1
  139. package/src/extractors/flixcloud.ts +139 -0
  140. package/src/extractors/index.ts +2 -0
  141. package/src/extractors/kwik.ts +74 -93
  142. package/src/extractors/megaplay.ts +205 -133
  143. package/src/extractors/vidhide.ts +12 -4
  144. package/src/models/extractor-context.ts +3 -0
  145. package/src/models/provider-context.ts +6 -0
  146. package/src/models/types.ts +1 -0
  147. package/src/providers/anime/animepahe/create-animepahe.ts +118 -158
  148. package/src/providers/anime/anineko/anineko.ts +44 -0
  149. package/src/providers/anime/anineko/create-anineko.ts +489 -0
  150. package/src/providers/anime/index.ts +8 -0
  151. package/src/providers/anime/reanime/create-reanime.ts +283 -0
  152. package/src/providers/anime/reanime/reanime.ts +41 -0
  153. package/src/utils/ExtractorManager.ts +7 -0
  154. package/src/utils/ProviderManager.ts +7 -0
  155. package/src/utils/create-extractor-context.ts +2 -0
  156. package/src/utils/create-provider-context.ts +2 -0
  157. package/src/utils/extension-utils.ts +5 -0
@@ -1,4 +1,5 @@
1
1
  import { type ExtractorContext, type IVideo, type ISource, type IVideoExtractor } from '../models';
2
+ import type { PolyURL } from '../utils/url-polyfill';
2
3
 
3
4
  /**
4
5
  * Kwik extractor function
@@ -8,106 +9,86 @@ import { type ExtractorContext, type IVideo, type ISource, type IVideoExtractor
8
9
  export function Kwik(ctx: ExtractorContext): IVideoExtractor {
9
10
  const serverName = 'kwik';
10
11
  const sources: IVideo[] = [];
11
- const { axios, load, USER_AGENT, PolyURL } = ctx;
12
- function unPack(code: string) {
13
- function indent(code: string[]) {
14
- try {
15
- let tabs = 0,
16
- old = -1,
17
- add = '';
18
- for (let i = 0; i < code.length; i++) {
19
- if (code[i]!.includes('{')) tabs++;
20
- if (code[i]!.includes('}')) tabs--;
21
-
22
- if (old !== tabs) {
23
- old = tabs;
24
- add = '';
25
- while (old > 0) {
26
- add += '\t';
27
- old--;
28
- }
29
- old = tabs;
30
- }
31
-
32
- code[i] = add + code[i];
33
- }
34
- } finally {
35
- // let GC cleanup
36
- }
37
- return code;
38
- }
12
+ const { load, USER_AGENT, NativeConsumet } = ctx;
39
13
 
40
- let captured = '';
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';
41
17
 
42
- // fake environment
43
- const env = {
44
- eval: function (c: string) {
45
- captured = c;
46
- },
47
- window: {},
48
- document: {},
49
- };
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]!;
26
+ const base = parseInt(m[2]!, 10);
27
+ const count = parseInt(m[3]!, 10);
28
+ const words = m[4]!.split(m[5]!);
29
+
30
+ function decode(n: number): string {
31
+ const prefix = n < base ? '' : decode(Math.floor(n / base));
32
+ const rem = n % base;
33
+ return prefix + (rem > 35 ? String.fromCharCode(rem + 29) : rem.toString(36));
34
+ }
35
+
36
+ let result = encoded;
37
+ for (let i = count - 1; i >= 0; i--) {
38
+ const word = words[i];
39
+ if (word) result = result.replace(new RegExp(`\\b${decode(i)}\\b`, 'g'), word);
40
+ }
50
41
 
51
- // Instead of `with`, run inside a Function with env injected
52
- const runner = new Function(
53
- 'env',
54
- `
55
- const { eval, window, document } = env;
56
- ${code}
57
- `
58
- );
59
-
60
- runner(env);
61
-
62
- // prettify captured code
63
- captured = (captured + '')
64
- .replace(/;/g, ';\n')
65
- .replace(/{/g, '\n{\n')
66
- .replace(/}/g, '\n}\n')
67
- .replace(/\n;\n/g, ';\n')
68
- .replace(/\n\n/g, '\n');
69
-
70
- let lines = captured.split('\n');
71
- lines = indent(lines);
72
-
73
- return lines.join('\n');
42
+ return result;
74
43
  }
44
+
75
45
  // @ts-ignore
76
- const extract = async (videoUrl: PolyURL, referer = 'https://animepahe.pw/'): Promise<ISource> => {
77
- const extractedData: ISource = {
78
- // subtitles: [],
79
- // intro: { start: 0, end: 0 },
80
- // outro: { start: 0, end: 0 },
81
- sources: [],
82
- };
46
+ const extract = async (videoUrl: PolyURL, referer = 'https://animepahe.ru/'): Promise<ISource> => {
47
+ const kwikUrl = typeof videoUrl === 'string' ? videoUrl : (videoUrl as any).href;
48
+ const kwikHost = kwikUrl.match(/^https?:\/\/([^/]+)/)?.[1] ?? 'kwik.cx';
49
+
50
+ const { html } = await NativeConsumet.makeGetRequestWithWebView(kwikUrl, {
51
+ 'Referer': referer,
52
+ 'User-Agent': ua,
53
+ });
83
54
 
84
- try {
85
- const response = await fetch(`${videoUrl.href}`, {
86
- headers: {
87
- 'Referer': referer,
88
- 'User-Agent': USER_AGENT!,
89
- },
90
- });
91
-
92
- const data = await response.text();
93
-
94
- const unpackedSourceCode = unPack(data.match(/<script\b[^>]*>\s*(eval\([\s\S]*?\))\s*<\/script>/i)![1]!);
95
- const re = /https?:\/\/[^'"\s]+?\.m3u8(?:\?[^'"\s]*)?/i;
96
- const source = unpackedSourceCode.match(re)![0]!;
97
- extractedData.sources.push({
98
- url: source,
99
- isM3U8: source.includes('.m3u8'),
100
- });
101
-
102
- return extractedData;
103
- } catch (err) {
104
- throw new Error((err as Error).message);
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;
105
69
  }
106
- };
107
70
 
108
- return {
109
- serverName,
110
- sources,
111
- extract,
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
+ return {
86
+ sources: [{ url: m3u8, isM3U8: m3u8.includes('.m3u8') }],
87
+ headers: { Referer: `https://${kwikHost}/` },
88
+ };
112
89
  };
90
+
91
+ return { serverName, sources, extract };
113
92
  }
93
+
94
+ export default Kwik;
@@ -1,182 +1,254 @@
1
- import axios from 'axios';
2
-
3
1
  import { type ExtractorContext, type ISource, type IVideo, type IVideoExtractor, type ISubtitle } from '../models';
4
2
  import type { PolyURL } from '../utils/url-polyfill';
5
3
 
4
+ const MEGA_KEY_STR = 'i?LMTAx0Q6,:}50U';
5
+ const MEGA_IV_STR = "W0;27ToaUpl_P%'c";
6
+
7
+ /** Matches the encrypted segment token inside a URL: `/segment/<base64url-token>` */
8
+ const SEGMENT_RE = /\/segment\/([A-Za-z0-9_-]+)/;
9
+
6
10
  /**
7
11
  * MegaPlay extractor factory that relies on the shared extractor context
8
- * @param ctx ExtractorContext containing axios, load, USER_AGENT, PolyURL
12
+ * @param ctx ExtractorContext containing axios, load, CryptoJS, USER_AGENT, PolyURL
9
13
  * @returns Object with extract method implementing IVideoExtractor interface
10
14
  */
11
15
  export function MegaPlay(ctx: ExtractorContext): IVideoExtractor {
12
16
  const serverName = 'MegaPlay';
13
17
  const sources: IVideo[] = [];
14
- const client = ctx.axios ?? axios;
18
+ const client = ctx.axios;
15
19
  const load = ctx.load;
20
+ const CryptoJS = ctx.CryptoJS;
16
21
  const userAgent =
17
22
  ctx.USER_AGENT ||
18
23
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36';
19
24
 
20
- const extract = async (videoUrl: PolyURL, referer?: string): Promise<ISource> => {
25
+ function megaPlayDecrypt(encB64Url: string): string {
26
+ // base64url → base64 (with padding)
27
+ const b64 = encB64Url.replace(/-/g, '+').replace(/_/g, '/');
28
+ const padded = b64 + '='.repeat((4 - (b64.length % 4)) % 4);
29
+
30
+ // AES-256 key: 16-char string + 16 null bytes (Latin1 = 1 byte per char for ASCII)
31
+ const key = CryptoJS.enc.Latin1.parse(MEGA_KEY_STR + '\0'.repeat(16));
32
+
33
+ // IV: raw bytes of the 16-char IV string
34
+ const iv = CryptoJS.enc.Latin1.parse(MEGA_IV_STR);
35
+
36
+ const ciphertext = CryptoJS.enc.Base64.parse(padded);
37
+ const cipherParams = CryptoJS.lib.CipherParams.create({ ciphertext });
38
+
39
+ const decrypted = CryptoJS.AES.decrypt(cipherParams, key, {
40
+ iv,
41
+ mode: CryptoJS.mode.CBC,
42
+ padding: CryptoJS.pad.Pkcs7,
43
+ });
44
+
45
+ return decrypted.toString(CryptoJS.enc.Utf8);
46
+ }
47
+
48
+ function resolveSegmentUrl(raw: string): string {
49
+ const m = raw.match(SEGMENT_RE);
50
+ if (!m || !m[1]) return raw;
21
51
  try {
22
- const embedHref = typeof videoUrl === 'string' ? videoUrl : videoUrl.href;
23
- const urlObj = typeof videoUrl === 'object' && videoUrl.origin ? videoUrl : new (ctx.PolyURL || URL)(embedHref);
24
- const origin = urlObj.origin || 'https://megaplay.buzz';
25
- const pageReferer = referer || embedHref;
52
+ const decrypted = megaPlayDecrypt(m[1]);
53
+ return decrypted || raw;
54
+ } catch {
55
+ return raw;
56
+ }
57
+ }
58
+
59
+ function extractStreamUrl(data: any): string | null {
60
+ if (!data || typeof data !== 'object') return null;
26
61
 
27
- const pageHeaders = {
62
+ // ── Case 1: encrypted payload { enc: "base64url…" } ──────────────────
63
+ if (typeof data.enc === 'string' && data.enc.length > 0) {
64
+ try {
65
+ const plain = megaPlayDecrypt(data.enc);
66
+ if (plain) {
67
+ // Decrypted value might be JSON: { sources: [{ file: "..." }] }
68
+ try {
69
+ const parsed = JSON.parse(plain);
70
+ const url =
71
+ (typeof parsed?.sources?.file === 'string' ? parsed.sources.file : null) ||
72
+ (Array.isArray(parsed?.sources) && parsed.sources[0]?.file ? String(parsed.sources[0].file) : null) ||
73
+ (typeof parsed?.file === 'string' ? parsed.file : null);
74
+ if (url) return resolveSegmentUrl(url);
75
+ } catch {
76
+ // not JSON — fall through and treat as raw URL
77
+ }
78
+ if (/^https?:\/\//i.test(plain) || plain.includes('.m3u8')) {
79
+ return plain.trim();
80
+ }
81
+ }
82
+ } catch {
83
+ // decrypt failed — fall through to plain sources
84
+ }
85
+ }
86
+
87
+ // ── Case 2: plain / segment-token sources ──────────────────────────────
88
+ const rawUrl: string | null =
89
+ (typeof data?.sources?.file === 'string' ? data.sources.file : null) ||
90
+ (Array.isArray(data?.sources) && data.sources[0]?.file ? String(data.sources[0].file) : null);
91
+
92
+ if (rawUrl) return resolveSegmentUrl(rawUrl);
93
+
94
+ return null;
95
+ }
96
+
97
+ const extract = async (videoUrl: PolyURL, referer?: string): Promise<ISource> => {
98
+ const embedHref = typeof videoUrl === 'string' ? videoUrl : videoUrl.href;
99
+ const urlObj = typeof videoUrl === 'object' && videoUrl.origin ? videoUrl : new (ctx.PolyURL || URL)(embedHref);
100
+ const origin = urlObj.origin || 'https://megaplay.buzz';
101
+ const pageReferer = referer || embedHref;
102
+
103
+ // ── Collect cookies across requests so the video player can send them ────
104
+ const cookieJar: string[] = [];
105
+
106
+ const parseCookies = (headers: any): string[] => {
107
+ const raw = headers?.['set-cookie'];
108
+ if (!raw) return [];
109
+ const arr = Array.isArray(raw) ? raw : [raw];
110
+ // Keep only the name=value part (strip path/domain/etc.)
111
+ return arr.map((c: string) => c.split(';')[0] ?? '').filter(Boolean);
112
+ };
113
+
114
+ const pageRes = await client.get(embedHref, {
115
+ headers: {
28
116
  'User-Agent': userAgent,
29
117
  'Referer': pageReferer,
30
118
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
31
- };
119
+ },
120
+ });
121
+ cookieJar.push(...parseCookies(pageRes.headers));
32
122
 
33
- const { data: html } = await client.get(embedHref, { headers: pageHeaders });
123
+ const $ = load(pageRes.data);
124
+ const playerDiv = $('#megaplay-player');
34
125
 
35
- const $ = load(html);
36
- const playerDiv = $('#megaplay-player');
126
+ if (!playerDiv.length) {
127
+ throw new Error('[MegaPlay] Could not find player element (#megaplay-player)');
128
+ }
37
129
 
38
- if (!playerDiv.length) {
39
- throw new Error('[MegaPlay] Could not find player element (#megaplay-player)');
40
- }
130
+ const mediaId = playerDiv.attr('data-id');
131
+ if (!mediaId) {
132
+ throw new Error('[MegaPlay] Could not find data-id on player element');
133
+ }
41
134
 
42
- const mediaId = playerDiv.attr('data-id');
43
- if (!mediaId) {
44
- throw new Error('[MegaPlay] Could not find data-id on player element');
45
- }
135
+ const sParam = urlObj.searchParams?.get('s');
136
+ const sQuery = sParam ? `&s=${encodeURIComponent(sParam)}` : '';
46
137
 
47
- const sParam = urlObj.searchParams?.get('s');
48
- const sQuery = sParam ? `&s=${encodeURIComponent(sParam)}` : '';
138
+ const cookieHeader = () => cookieJar.join('; ');
49
139
 
50
- const ajaxHeaders = {
51
- 'X-Requested-With': 'XMLHttpRequest',
52
- 'Referer': `${origin}/`,
53
- 'User-Agent': userAgent,
54
- 'Accept': 'application/json, text/javascript, */*; q=0.01',
55
- };
140
+ const ajaxHeaders = (): Record<string, string> => ({
141
+ 'X-Requested-With': 'XMLHttpRequest',
142
+ 'Referer': `${origin}/`,
143
+ 'Origin': origin,
144
+ 'User-Agent': userAgent,
145
+ 'Accept': 'application/json, text/javascript, */*; q=0.01',
146
+ ...(cookieJar.length ? { Cookie: cookieHeader() } : {}),
147
+ });
56
148
 
57
- let defSourcesJson: any = null;
58
- let defStreamUrl: string | null = null;
149
+ const fetchJson = async (url: string): Promise<any | null> => {
59
150
  try {
60
- const { data: resData } = await client.get(`${origin}/stream/getSources?id=${mediaId}${sQuery}`, {
61
- headers: ajaxHeaders,
62
- });
63
- defSourcesJson = typeof resData === 'string' ? JSON.parse(resData) : resData;
64
- defStreamUrl =
65
- defSourcesJson?.sources?.file ||
66
- (Array.isArray(defSourcesJson?.sources) ? defSourcesJson.sources[0]?.file : null);
151
+ const res = await client.get(url, { headers: ajaxHeaders() });
152
+ cookieJar.push(...parseCookies(res.headers));
153
+ const data = res.data;
154
+ return typeof data === 'string' ? JSON.parse(data) : data;
67
155
  } catch {
68
- // Fallback to getSourcesNew
156
+ return null;
69
157
  }
158
+ };
70
159
 
71
- let newSourcesJson: any = null;
72
- let newStreamUrl: string | null = null;
73
- try {
74
- const { data: newResData } = await client.get(`${origin}/stream/getSourcesNew?id=${mediaId}${sQuery}`, {
75
- headers: ajaxHeaders,
76
- });
77
- newSourcesJson = typeof newResData === 'string' ? JSON.parse(newResData) : newResData;
78
- newStreamUrl =
79
- newSourcesJson?.sources?.file ||
80
- (Array.isArray(newSourcesJson?.sources) ? newSourcesJson.sources[0]?.file : null);
81
- } catch {
82
- // Ignore if defStreamUrl succeeded
83
- }
160
+ const [defSourcesJson, newSourcesJson] = await Promise.all([
161
+ fetchJson(`${origin}/stream/getSources?id=${mediaId}${sQuery}`),
162
+ fetchJson(`${origin}/stream/getSourcesNew?id=${mediaId}${sQuery}`),
163
+ ]);
84
164
 
85
- const streamUrl = defStreamUrl || newStreamUrl;
86
- if (!streamUrl) {
87
- throw new Error('[MegaPlay] No video stream URL found from /getSources or /getSourcesNew');
88
- }
165
+ const streamUrl = extractStreamUrl(defSourcesJson) || extractStreamUrl(newSourcesJson);
89
166
 
90
- const cleanStreamUrl = String(streamUrl).replace(/\\/g, '');
91
- const isM3U8 = cleanStreamUrl.includes('.m3u8');
92
-
93
- const extractedSources: IVideo[] = [];
94
- const defaultSource: IVideo = {
95
- url: cleanStreamUrl,
96
- isM3U8,
97
- quality: 'auto',
98
- };
99
-
100
- if (isM3U8) {
101
- try {
102
- const { data: m3u8Data } = await client.get(cleanStreamUrl, {
103
- headers: {
104
- 'Referer': `${origin}/`,
105
- 'User-Agent': userAgent,
106
- },
107
- });
167
+ if (!streamUrl) {
168
+ throw new Error('[MegaPlay] No video stream URL found from /getSources or /getSourcesNew');
169
+ }
170
+
171
+ const cleanStreamUrl = streamUrl.replace(/\\/g, '').trim();
172
+ const isM3U8 = cleanStreamUrl.includes('.m3u8');
108
173
 
109
- if (typeof m3u8Data === 'string' && m3u8Data.includes('#EXT-X-STREAM-INF')) {
110
- const lines = m3u8Data.split('\n');
111
- const streamBasePath = cleanStreamUrl.substring(0, cleanStreamUrl.lastIndexOf('/'));
112
- const streamOrigin = new (ctx.PolyURL || URL)(cleanStreamUrl).origin;
113
-
114
- for (let i = 0; i < lines.length; i++) {
115
- const line = lines[i]?.trim();
116
- if (line && line.startsWith('#EXT-X-STREAM-INF')) {
117
- const resolutionMatch = line.match(/RESOLUTION=\d+x(\d+)/);
118
- const quality = resolutionMatch ? `${resolutionMatch[1]}p` : `quality_${extractedSources.length + 1}`;
119
- const nextLine = lines[i + 1]?.trim();
120
- if (nextLine && !nextLine.startsWith('#')) {
121
- const variantUrl =
122
- nextLine.startsWith('http://') || nextLine.startsWith('https://')
123
- ? nextLine
124
- : nextLine.startsWith('/')
125
- ? `${streamOrigin}${nextLine}`
126
- : `${streamBasePath}/${nextLine}`;
127
-
128
- extractedSources.push({
129
- url: variantUrl,
130
- isM3U8: true,
131
- quality,
132
- });
133
- }
174
+ const extractedSources: IVideo[] = [];
175
+ const defaultSource: IVideo = { url: cleanStreamUrl, isM3U8, quality: 'auto' };
176
+
177
+ if (isM3U8) {
178
+ try {
179
+ const { data: m3u8Data } = await client.get(cleanStreamUrl, {
180
+ headers: { 'Referer': `${origin}/`, 'User-Agent': userAgent },
181
+ });
182
+
183
+ if (typeof m3u8Data === 'string' && m3u8Data.includes('#EXT-X-STREAM-INF')) {
184
+ const lines = m3u8Data.split('\n');
185
+ const streamBasePath = cleanStreamUrl.substring(0, cleanStreamUrl.lastIndexOf('/'));
186
+ const streamOrigin = new (ctx.PolyURL || URL)(cleanStreamUrl).origin;
187
+
188
+ for (let i = 0; i < lines.length; i++) {
189
+ const line = lines[i]?.trim();
190
+ if (line?.startsWith('#EXT-X-STREAM-INF')) {
191
+ const resMatch = line.match(/RESOLUTION=\d+x(\d+)/);
192
+ const quality = resMatch ? `${resMatch[1]}p` : `quality_${extractedSources.length + 1}`;
193
+ const next = lines[i + 1]?.trim();
194
+ if (next && !next.startsWith('#')) {
195
+ const variantUrl =
196
+ next.startsWith('http://') || next.startsWith('https://')
197
+ ? next
198
+ : next.startsWith('/')
199
+ ? `${streamOrigin}${next}`
200
+ : `${streamBasePath}/${next}`;
201
+ extractedSources.push({ url: variantUrl, isM3U8: true, quality });
134
202
  }
135
203
  }
136
204
  }
137
- } catch {
138
- // If fetching variants fails, defaultSource will be returned
139
205
  }
206
+ } catch {
207
+ // variants fetch failed — defaultSource will be used
140
208
  }
209
+ }
141
210
 
142
- const finalSources = extractedSources.length > 0 ? [...extractedSources, defaultSource] : [defaultSource];
143
-
144
- const tracks = defSourcesJson?.tracks || newSourcesJson?.tracks || [];
145
- const subtitles: ISubtitle[] = [];
146
- if (Array.isArray(tracks)) {
147
- for (const track of tracks) {
148
- if (track?.file) {
149
- subtitles.push({
150
- url: String(track.file).replace(/\\/g, ''),
151
- lang: track.label || track.kind || 'English',
152
- });
153
- }
211
+ const finalSources = extractedSources.length > 0 ? [...extractedSources, defaultSource] : [defaultSource];
212
+
213
+ const tracks = defSourcesJson?.tracks ?? newSourcesJson?.tracks ?? [];
214
+ const subtitles: ISubtitle[] = [];
215
+ if (Array.isArray(tracks)) {
216
+ for (const track of tracks) {
217
+ if (track?.file) {
218
+ subtitles.push({
219
+ url: String(track.file).replace(/\\/g, ''),
220
+ lang: track.label || track.kind || 'English',
221
+ });
154
222
  }
155
223
  }
224
+ }
156
225
 
157
- const intro = defSourcesJson?.intro || newSourcesJson?.intro;
158
- const outro = defSourcesJson?.outro || newSourcesJson?.outro;
159
-
160
- return {
161
- sources: finalSources,
162
- subtitles,
163
- headers: {
164
- Referer: `${origin}/`,
165
- },
166
- intro: intro ? { start: intro.start, end: intro.end } : undefined,
167
- outro: outro ? { start: outro.start, end: outro.end } : undefined,
168
- embedURL: embedHref,
169
- };
170
- } catch (error) {
171
- throw new Error((error as Error).message);
226
+ const intro = defSourcesJson?.intro ?? newSourcesJson?.intro;
227
+ const outro = defSourcesJson?.outro ?? newSourcesJson?.outro;
228
+
229
+ // Build player headers — these must be sent with every HLS request.
230
+ // The CDN (fetch.nexabloom.top) is IP-bound: the URL is generated for the
231
+ // requesting IP, so extraction and playback must share the same IP.
232
+ const playerHeaders: Record<string, string> = {
233
+ 'Referer': `${origin}/`,
234
+ 'Origin': origin,
235
+ 'User-Agent': userAgent,
236
+ };
237
+ if (cookieJar.length) {
238
+ playerHeaders.Cookie = cookieHeader();
172
239
  }
173
- };
174
240
 
175
- return {
176
- serverName,
177
- sources,
178
- extract,
241
+ return {
242
+ sources: finalSources,
243
+ subtitles,
244
+ headers: playerHeaders,
245
+ intro: intro ? { start: intro.start, end: intro.end } : undefined,
246
+ outro: outro ? { start: outro.start, end: outro.end } : undefined,
247
+ embedURL: embedHref,
248
+ };
179
249
  };
250
+
251
+ return { serverName, sources, extract };
180
252
  }
181
253
 
182
254
  export default MegaPlay;
@@ -9,7 +9,7 @@ import type { PolyURL } from '../utils/url-polyfill';
9
9
  export function VidHide(ctx: ExtractorContext): IVideoExtractor {
10
10
  const serverName = 'VidHide';
11
11
  const sources: IVideo[] = [];
12
- const { axios, USER_AGENT } = ctx;
12
+ const { axios, USER_AGENT, NativeConsumet } = ctx;
13
13
 
14
14
  const extract = async (videoUrl: PolyURL): Promise<ISource> => {
15
15
  try {
@@ -24,11 +24,17 @@ export function VidHide(ctx: ExtractorContext): IVideoExtractor {
24
24
  throw new Error('Video not found');
25
25
  });
26
26
 
27
- const unpackedData = eval(
28
- /(eval)(\(f.*?)(\n<\/script>)/m.exec(data.replace(/\n/g, ' '))![2]!.replace('eval', '')
29
- );
27
+ const packedScript = /(eval)(\(f.*?)(\n<\/script>)/m.exec(data.replace(/\n/g, ' '))?.[2]?.replace('eval', '');
28
+
29
+ if (!packedScript) throw new Error('No packed script found');
30
+
31
+ const unpackedData = await NativeConsumet.deobfuscateScript(packedScript);
32
+ if (!unpackedData) throw new Error('Failed to deobfuscate script');
33
+
30
34
  const links = unpackedData.match(/https?:\/\/[^"]+?\.m3u8[^"]*/g) ?? [];
31
35
  const m3u8Link = links[0];
36
+ if (!m3u8Link) throw new Error('No m3u8 link found');
37
+
32
38
  const m3u8Content = await axios.get(m3u8Link, {
33
39
  headers: {
34
40
  'Referer': m3u8Link,
@@ -76,3 +82,5 @@ export function VidHide(ctx: ExtractorContext): IVideoExtractor {
76
82
  extract,
77
83
  };
78
84
  }
85
+
86
+ export default VidHide;
@@ -1,5 +1,6 @@
1
1
  import type { AxiosInstance } from 'axios';
2
2
  import type { CheerioAPI } from 'cheerio';
3
+ import type CryptoJS from 'crypto-js';
3
4
  import type { PolyURL, PolyURLSearchParams } from '../utils/url-polyfill';
4
5
  import type {
5
6
  bypassDdosGuard,
@@ -18,6 +19,8 @@ import type {
18
19
  export interface ExtractorContext {
19
20
  axios: AxiosInstance;
20
21
  load: (html: string) => CheerioAPI;
22
+ /** CryptoJS library — use instead of importing crypto-js directly */
23
+ CryptoJS: typeof CryptoJS;
21
24
  USER_AGENT?: string;
22
25
  PolyURL: typeof PolyURL;
23
26
  PolyURLSearchParams: typeof PolyURLSearchParams;
@@ -1,5 +1,6 @@
1
1
  import type { AxiosInstance } from 'axios';
2
2
  import type { CheerioAPI } from 'cheerio';
3
+ import type CryptoJS from 'crypto-js';
3
4
  import type AnimeParser from './anime-parser';
4
5
  import type MovieParser from './movie-parser';
5
6
  import type { ExtractorContext, ExtractorContextConfig } from './extractor-context';
@@ -131,6 +132,9 @@ export interface ExtractorRegistry {
131
132
  HubCloud: (ctx?: ExtractorContext) => {
132
133
  extract: (url: PolyURL | string, ...args: any[]) => Promise<any>;
133
134
  };
135
+ FlixCloud: (ctx?: ExtractorContext) => {
136
+ extract: (url: PolyURL, referer?: string) => Promise<any>;
137
+ };
134
138
  }
135
139
 
136
140
  export type ProviderConfig = {
@@ -151,6 +155,8 @@ export type ProviderConfig = {
151
155
  export interface ProviderContext {
152
156
  axios: AxiosInstance;
153
157
  load: (html: string) => CheerioAPI;
158
+ /** CryptoJS library — use instead of importing crypto-js directly */
159
+ CryptoJS: typeof CryptoJS;
154
160
  USER_AGENT: string;
155
161
  AnimeParser: typeof AnimeParser;
156
162
  MovieParser: typeof MovieParser;
@@ -221,6 +221,7 @@ export enum StreamingServers {
221
221
  GDFlix = 'gdflix',
222
222
  Gofile = 'gofile',
223
223
  HubCloud = 'hubcloud',
224
+ FlixCloud = 'flixcloud',
224
225
  }
225
226
 
226
227
  export enum MediaStatus {