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.
- package/lib/commonjs/extension-registry.json +30 -1
- package/lib/commonjs/extractors/flixcloud.js +179 -0
- package/lib/commonjs/extractors/flixcloud.js.map +1 -0
- package/lib/commonjs/extractors/index.js +7 -0
- package/lib/commonjs/extractors/index.js.map +1 -1
- package/lib/commonjs/extractors/kwik.js +59 -74
- package/lib/commonjs/extractors/kwik.js.map +1 -1
- package/lib/commonjs/extractors/megaplay.js +196 -124
- package/lib/commonjs/extractors/megaplay.js.map +1 -1
- package/lib/commonjs/extractors/vidhide.js +9 -2
- package/lib/commonjs/extractors/vidhide.js.map +1 -1
- package/lib/commonjs/models/types.js +1 -0
- package/lib/commonjs/models/types.js.map +1 -1
- package/lib/commonjs/providers/anime/animepahe/create-animepahe.js +107 -137
- package/lib/commonjs/providers/anime/animepahe/create-animepahe.js.map +1 -1
- package/lib/commonjs/providers/anime/anineko/anineko.js +31 -0
- package/lib/commonjs/providers/anime/anineko/anineko.js.map +1 -0
- package/lib/commonjs/providers/anime/anineko/create-anineko.js +447 -0
- package/lib/commonjs/providers/anime/anineko/create-anineko.js.map +1 -0
- package/lib/commonjs/providers/anime/index.js +9 -1
- package/lib/commonjs/providers/anime/index.js.map +1 -1
- package/lib/commonjs/providers/anime/reanime/create-reanime.js +255 -0
- package/lib/commonjs/providers/anime/reanime/create-reanime.js.map +1 -0
- package/lib/commonjs/providers/anime/reanime/reanime.js +31 -0
- package/lib/commonjs/providers/anime/reanime/reanime.js.map +1 -0
- package/lib/commonjs/utils/ExtractorManager.js +8 -1
- package/lib/commonjs/utils/ExtractorManager.js.map +1 -1
- package/lib/commonjs/utils/ProviderManager.js +8 -1
- package/lib/commonjs/utils/ProviderManager.js.map +1 -1
- package/lib/commonjs/utils/create-extractor-context.js +3 -0
- package/lib/commonjs/utils/create-extractor-context.js.map +1 -1
- package/lib/commonjs/utils/create-provider-context.js +2 -0
- package/lib/commonjs/utils/create-provider-context.js.map +1 -1
- package/lib/commonjs/utils/extension-utils.js +6 -2
- package/lib/commonjs/utils/extension-utils.js.map +1 -1
- package/lib/module/extension-registry.json +30 -1
- package/lib/module/extractors/flixcloud.js +174 -0
- package/lib/module/extractors/flixcloud.js.map +1 -0
- package/lib/module/extractors/index.js +2 -1
- package/lib/module/extractors/index.js.map +1 -1
- package/lib/module/extractors/kwik.js +58 -74
- package/lib/module/extractors/kwik.js.map +1 -1
- package/lib/module/extractors/megaplay.js +196 -123
- package/lib/module/extractors/megaplay.js.map +1 -1
- package/lib/module/extractors/vidhide.js +8 -2
- package/lib/module/extractors/vidhide.js.map +1 -1
- package/lib/module/models/types.js +1 -0
- package/lib/module/models/types.js.map +1 -1
- package/lib/module/providers/anime/animepahe/create-animepahe.js +107 -138
- package/lib/module/providers/anime/animepahe/create-animepahe.js.map +1 -1
- package/lib/module/providers/anime/anineko/anineko.js +25 -0
- package/lib/module/providers/anime/anineko/anineko.js.map +1 -0
- package/lib/module/providers/anime/anineko/create-anineko.js +443 -0
- package/lib/module/providers/anime/anineko/create-anineko.js.map +1 -0
- package/lib/module/providers/anime/index.js +9 -1
- package/lib/module/providers/anime/index.js.map +1 -1
- package/lib/module/providers/anime/reanime/create-reanime.js +251 -0
- package/lib/module/providers/anime/reanime/create-reanime.js.map +1 -0
- package/lib/module/providers/anime/reanime/reanime.js +25 -0
- package/lib/module/providers/anime/reanime/reanime.js.map +1 -0
- package/lib/module/utils/ExtractorManager.js +8 -1
- package/lib/module/utils/ExtractorManager.js.map +1 -1
- package/lib/module/utils/ProviderManager.js +8 -1
- package/lib/module/utils/ProviderManager.js.map +1 -1
- package/lib/module/utils/create-extractor-context.js +2 -0
- package/lib/module/utils/create-extractor-context.js.map +1 -1
- package/lib/module/utils/create-provider-context.js +2 -0
- package/lib/module/utils/create-provider-context.js.map +1 -1
- package/lib/module/utils/extension-utils.js +7 -3
- package/lib/module/utils/extension-utils.js.map +1 -1
- package/lib/typescript/commonjs/src/extractors/flixcloud.d.ts +18 -0
- package/lib/typescript/commonjs/src/extractors/flixcloud.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/extractors/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/extractors/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/kwik.d.ts +1 -0
- package/lib/typescript/commonjs/src/extractors/kwik.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/megaplay.d.ts +1 -1
- package/lib/typescript/commonjs/src/extractors/megaplay.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/vidhide.d.ts +1 -0
- package/lib/typescript/commonjs/src/extractors/vidhide.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/extractor-context.d.ts +3 -0
- package/lib/typescript/commonjs/src/models/extractor-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/provider-context.d.ts +6 -0
- package/lib/typescript/commonjs/src/models/provider-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/types.d.ts +2 -1
- 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/anime/anineko/anineko.d.ts +23 -0
- package/lib/typescript/commonjs/src/providers/anime/anineko/anineko.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/anime/anineko/create-anineko.d.ts +52 -0
- package/lib/typescript/commonjs/src/providers/anime/anineko/create-anineko.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/anime/index.d.ts +8 -0
- package/lib/typescript/commonjs/src/providers/anime/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/reanime/create-reanime.d.ts +18 -0
- package/lib/typescript/commonjs/src/providers/anime/reanime/create-reanime.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/anime/reanime/reanime.d.ts +19 -0
- package/lib/typescript/commonjs/src/providers/anime/reanime/reanime.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/ExtractorManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/create-extractor-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/create-provider-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/extension-utils.d.ts +2 -0
- package/lib/typescript/commonjs/src/utils/extension-utils.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/flixcloud.d.ts +18 -0
- package/lib/typescript/module/src/extractors/flixcloud.d.ts.map +1 -0
- package/lib/typescript/module/src/extractors/index.d.ts +2 -1
- package/lib/typescript/module/src/extractors/index.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/kwik.d.ts +1 -0
- package/lib/typescript/module/src/extractors/kwik.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/megaplay.d.ts +1 -1
- package/lib/typescript/module/src/extractors/megaplay.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/vidhide.d.ts +1 -0
- package/lib/typescript/module/src/extractors/vidhide.d.ts.map +1 -1
- package/lib/typescript/module/src/models/extractor-context.d.ts +3 -0
- package/lib/typescript/module/src/models/extractor-context.d.ts.map +1 -1
- package/lib/typescript/module/src/models/provider-context.d.ts +6 -0
- package/lib/typescript/module/src/models/provider-context.d.ts.map +1 -1
- package/lib/typescript/module/src/models/types.d.ts +2 -1
- 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/anime/anineko/anineko.d.ts +23 -0
- package/lib/typescript/module/src/providers/anime/anineko/anineko.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/anime/anineko/create-anineko.d.ts +52 -0
- package/lib/typescript/module/src/providers/anime/anineko/create-anineko.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/anime/index.d.ts +8 -0
- package/lib/typescript/module/src/providers/anime/index.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/reanime/create-reanime.d.ts +18 -0
- package/lib/typescript/module/src/providers/anime/reanime/create-reanime.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/anime/reanime/reanime.d.ts +19 -0
- package/lib/typescript/module/src/providers/anime/reanime/reanime.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/ExtractorManager.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/ProviderManager.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/create-extractor-context.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/create-provider-context.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/extension-utils.d.ts +2 -0
- package/lib/typescript/module/src/utils/extension-utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/extension-registry.json +30 -1
- package/src/extractors/flixcloud.ts +139 -0
- package/src/extractors/index.ts +2 -0
- package/src/extractors/kwik.ts +74 -93
- package/src/extractors/megaplay.ts +205 -133
- package/src/extractors/vidhide.ts +12 -4
- package/src/models/extractor-context.ts +3 -0
- package/src/models/provider-context.ts +6 -0
- package/src/models/types.ts +1 -0
- package/src/providers/anime/animepahe/create-animepahe.ts +118 -158
- package/src/providers/anime/anineko/anineko.ts +44 -0
- package/src/providers/anime/anineko/create-anineko.ts +489 -0
- package/src/providers/anime/index.ts +8 -0
- package/src/providers/anime/reanime/create-reanime.ts +283 -0
- package/src/providers/anime/reanime/reanime.ts +41 -0
- package/src/utils/ExtractorManager.ts +7 -0
- package/src/utils/ProviderManager.ts +7 -0
- package/src/utils/create-extractor-context.ts +2 -0
- package/src/utils/create-provider-context.ts +2 -0
- package/src/utils/extension-utils.ts +5 -0
package/src/extractors/kwik.ts
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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.
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
123
|
+
const $ = load(pageRes.data);
|
|
124
|
+
const playerDiv = $('#megaplay-player');
|
|
34
125
|
|
|
35
|
-
|
|
36
|
-
|
|
126
|
+
if (!playerDiv.length) {
|
|
127
|
+
throw new Error('[MegaPlay] Could not find player element (#megaplay-player)');
|
|
128
|
+
}
|
|
37
129
|
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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
|
-
|
|
48
|
-
const sQuery = sParam ? `&s=${encodeURIComponent(sParam)}` : '';
|
|
138
|
+
const cookieHeader = () => cookieJar.join('; ');
|
|
49
139
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
58
|
-
let defStreamUrl: string | null = null;
|
|
149
|
+
const fetchJson = async (url: string): Promise<any | null> => {
|
|
59
150
|
try {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
156
|
+
return null;
|
|
69
157
|
}
|
|
158
|
+
};
|
|
70
159
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
|
28
|
-
|
|
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;
|