react-native-consumet 1.0.0-rc.0 → 1.0.0-rc.2

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 (245) hide show
  1. package/android/generated/java/com/consumet/NativeConsumetSpec.java +4 -0
  2. package/android/generated/jni/RNConsumetSpec-generated.cpp +6 -0
  3. package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI-generated.cpp +8 -0
  4. package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI.h +9 -0
  5. package/android/src/main/java/com/consumet/ConsumetModule.kt +7 -0
  6. package/android/src/main/java/com/consumet/DdosGuardModule.kt +248 -189
  7. package/ios/generated/RNConsumetSpec/RNConsumetSpec-generated.mm +7 -0
  8. package/ios/generated/RNConsumetSpec/RNConsumetSpec.h +2 -0
  9. package/ios/generated/RNConsumetSpecJSI-generated.cpp +8 -0
  10. package/ios/generated/RNConsumetSpecJSI.h +9 -0
  11. package/lib/commonjs/NativeConsumet.ts +28 -26
  12. package/lib/commonjs/extension-registry.json +13 -13
  13. package/lib/commonjs/extractors/filemoon.js +2 -2
  14. package/lib/commonjs/extractors/kwik.js +60 -15
  15. package/lib/commonjs/extractors/kwik.js.map +1 -1
  16. package/lib/commonjs/extractors/megacloud.js +6 -6
  17. package/lib/commonjs/index.js +2 -11
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/commonjs/models/types.js +4 -4
  20. package/lib/commonjs/models/video-extractor.js +4 -4
  21. package/lib/commonjs/providers/anime/animedrive.js +12 -12
  22. package/lib/commonjs/providers/anime/animekai.js +41 -41
  23. package/lib/commonjs/providers/anime/animepahe/animepahe.js +16 -15
  24. package/lib/commonjs/providers/anime/animepahe/animepahe.js.map +1 -1
  25. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js +12 -9
  26. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js.map +1 -1
  27. package/lib/commonjs/providers/anime/animesuge/animesuge.js +78 -0
  28. package/lib/commonjs/providers/anime/animesuge/animesuge.js.map +1 -0
  29. package/lib/commonjs/providers/anime/animesuge/create-animesuge.js +312 -0
  30. package/lib/commonjs/providers/anime/animesuge/create-animesuge.js.map +1 -0
  31. package/lib/commonjs/providers/anime/animeunity.js +13 -13
  32. package/lib/commonjs/providers/anime/index.js +4 -4
  33. package/lib/commonjs/providers/anime/index.js.map +1 -1
  34. package/lib/commonjs/providers/anime/marin.js +12 -12
  35. package/lib/commonjs/providers/anime/zoro/create-zoro.js +2 -2
  36. package/lib/commonjs/providers/anime/zoro/create-zoro.js.map +1 -1
  37. package/lib/commonjs/providers/anime/zoro/zoro.js +76 -74
  38. package/lib/commonjs/providers/anime/zoro/zoro.js.map +1 -1
  39. package/lib/commonjs/providers/manga/brmangas.js +3 -3
  40. package/lib/commonjs/providers/meta/anilist.js +91 -91
  41. package/lib/commonjs/providers/meta/mal.js +12 -12
  42. package/lib/commonjs/providers/meta/tmdb.js +21 -21
  43. package/lib/commonjs/providers/movies/himovies/create-himovies.js +16 -16
  44. package/lib/commonjs/providers/movies/himovies/himovies.js +16 -16
  45. package/lib/commonjs/providers/movies/multimovies.js +15 -15
  46. package/lib/commonjs/providers/movies/multistream/index.js +21 -20
  47. package/lib/commonjs/providers/movies/multistream/index.js.map +1 -1
  48. package/lib/commonjs/providers/movies/multistream/utils.js +142 -130
  49. package/lib/commonjs/providers/movies/multistream/utils.js.map +1 -1
  50. package/lib/commonjs/utils/ExtractorManager.js +15 -15
  51. package/lib/commonjs/utils/ExtractorManager.js.map +1 -1
  52. package/lib/commonjs/utils/ProviderManager.js +2 -1
  53. package/lib/commonjs/utils/ProviderManager.js.map +1 -1
  54. package/lib/commonjs/utils/create-extractor-context.js +9 -1
  55. package/lib/commonjs/utils/create-extractor-context.js.map +1 -1
  56. package/lib/commonjs/utils/create-provider-context.js +6 -2
  57. package/lib/commonjs/utils/create-provider-context.js.map +1 -1
  58. package/lib/commonjs/utils/extension-utils.js +44 -54
  59. package/lib/commonjs/utils/extension-utils.js.map +1 -1
  60. package/lib/commonjs/utils/index.js +2 -2
  61. package/lib/commonjs/utils/provider-maps.js +31 -0
  62. package/lib/commonjs/utils/provider-maps.js.map +1 -0
  63. package/lib/commonjs/utils/providers-list.js +4 -4
  64. package/lib/commonjs/utils/url-polyfill.js +4 -4
  65. package/lib/module/NativeConsumet.ts +28 -26
  66. package/lib/module/extension-registry.json +13 -13
  67. package/lib/module/extractors/filemoon.js +2 -2
  68. package/lib/module/extractors/kwik.js +60 -15
  69. package/lib/module/extractors/kwik.js.map +1 -1
  70. package/lib/module/extractors/megacloud.js +6 -6
  71. package/lib/module/index.js +3 -7
  72. package/lib/module/index.js.map +1 -1
  73. package/lib/module/models/types.js +4 -4
  74. package/lib/module/models/video-extractor.js +4 -4
  75. package/lib/module/providers/anime/animedrive.js +12 -12
  76. package/lib/module/providers/anime/animekai.js +41 -41
  77. package/lib/module/providers/anime/animepahe/animepahe.js +14 -14
  78. package/lib/module/providers/anime/animepahe/animepahe.js.map +1 -1
  79. package/lib/module/providers/anime/animepahe/create-animepahe.js +13 -9
  80. package/lib/module/providers/anime/animepahe/create-animepahe.js.map +1 -1
  81. package/lib/module/providers/anime/animesuge/animesuge.js +73 -0
  82. package/lib/module/providers/anime/animesuge/animesuge.js.map +1 -0
  83. package/lib/module/providers/anime/animesuge/create-animesuge.js +309 -0
  84. package/lib/module/providers/anime/animesuge/create-animesuge.js.map +1 -0
  85. package/lib/module/providers/anime/animeunity.js +13 -13
  86. package/lib/module/providers/anime/index.js +2 -2
  87. package/lib/module/providers/anime/index.js.map +1 -1
  88. package/lib/module/providers/anime/marin.js +12 -12
  89. package/lib/module/providers/anime/zoro/create-zoro.js +3 -2
  90. package/lib/module/providers/anime/zoro/create-zoro.js.map +1 -1
  91. package/lib/module/providers/anime/zoro/zoro.js +74 -73
  92. package/lib/module/providers/anime/zoro/zoro.js.map +1 -1
  93. package/lib/module/providers/manga/brmangas.js +3 -3
  94. package/lib/module/providers/meta/anilist.js +91 -91
  95. package/lib/module/providers/meta/mal.js +12 -12
  96. package/lib/module/providers/meta/tmdb.js +21 -21
  97. package/lib/module/providers/movies/himovies/create-himovies.js +16 -16
  98. package/lib/module/providers/movies/himovies/himovies.js +16 -16
  99. package/lib/module/providers/movies/multimovies.js +15 -15
  100. package/lib/module/providers/movies/multistream/index.js +21 -20
  101. package/lib/module/providers/movies/multistream/index.js.map +1 -1
  102. package/lib/module/providers/movies/multistream/utils.js +141 -129
  103. package/lib/module/providers/movies/multistream/utils.js.map +1 -1
  104. package/lib/module/utils/ExtractorManager.js +16 -16
  105. package/lib/module/utils/ExtractorManager.js.map +1 -1
  106. package/lib/module/utils/ProviderManager.js +2 -1
  107. package/lib/module/utils/ProviderManager.js.map +1 -1
  108. package/lib/module/utils/create-extractor-context.js +10 -1
  109. package/lib/module/utils/create-extractor-context.js.map +1 -1
  110. package/lib/module/utils/create-provider-context.js +8 -4
  111. package/lib/module/utils/create-provider-context.js.map +1 -1
  112. package/lib/module/utils/extension-utils.js +23 -33
  113. package/lib/module/utils/extension-utils.js.map +1 -1
  114. package/lib/module/utils/index.js +1 -1
  115. package/lib/module/utils/index.js.map +1 -1
  116. package/lib/module/utils/provider-maps.js +27 -0
  117. package/lib/module/utils/provider-maps.js.map +1 -0
  118. package/lib/module/utils/providers-list.js +4 -4
  119. package/lib/module/utils/url-polyfill.js +4 -4
  120. package/lib/typescript/commonjs/src/NativeConsumet.d.ts +2 -0
  121. package/lib/typescript/commonjs/src/NativeConsumet.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/src/extractors/kwik.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/src/index.d.ts +6 -6
  124. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/src/models/extractor-context.d.ts +8 -0
  126. package/lib/typescript/commonjs/src/models/extractor-context.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/src/models/index.d.ts +2 -2
  128. package/lib/typescript/commonjs/src/models/index.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/src/models/provider-context.d.ts +6 -2
  130. package/lib/typescript/commonjs/src/models/provider-context.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/src/providers/anime/animepahe/animepahe.d.ts.map +1 -1
  132. package/lib/typescript/commonjs/src/providers/anime/animepahe/create-animepahe.d.ts +1 -1
  133. package/lib/typescript/commonjs/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/src/providers/anime/animesuge/animesuge.d.ts +34 -0
  135. package/lib/typescript/commonjs/src/providers/anime/animesuge/animesuge.d.ts.map +1 -0
  136. package/lib/typescript/commonjs/src/providers/anime/animesuge/create-animesuge.d.ts +14 -0
  137. package/lib/typescript/commonjs/src/providers/anime/animesuge/create-animesuge.d.ts.map +1 -0
  138. package/lib/typescript/commonjs/src/providers/anime/index.d.ts +2 -2
  139. package/lib/typescript/commonjs/src/providers/anime/index.d.ts.map +1 -1
  140. package/lib/typescript/commonjs/src/providers/anime/zoro/create-zoro.d.ts +1 -1
  141. package/lib/typescript/commonjs/src/providers/anime/zoro/create-zoro.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/providers/anime/zoro/zoro.d.ts.map +1 -1
  143. package/lib/typescript/commonjs/src/providers/movies/multistream/index.d.ts +1 -1
  144. package/lib/typescript/commonjs/src/providers/movies/multistream/index.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/src/providers/movies/multistream/utils.d.ts +2 -2
  146. package/lib/typescript/commonjs/src/providers/movies/multistream/utils.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts +1 -1
  148. package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/utils/create-extractor-context.d.ts.map +1 -1
  150. package/lib/typescript/commonjs/src/utils/create-provider-context.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/src/utils/extension-utils.d.ts +1 -20
  152. package/lib/typescript/commonjs/src/utils/extension-utils.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/src/utils/index.d.ts +2 -1
  154. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/src/utils/provider-maps.d.ts +27 -0
  156. package/lib/typescript/commonjs/src/utils/provider-maps.d.ts.map +1 -0
  157. package/lib/typescript/module/src/NativeConsumet.d.ts +2 -0
  158. package/lib/typescript/module/src/NativeConsumet.d.ts.map +1 -1
  159. package/lib/typescript/module/src/extractors/kwik.d.ts.map +1 -1
  160. package/lib/typescript/module/src/index.d.ts +6 -6
  161. package/lib/typescript/module/src/index.d.ts.map +1 -1
  162. package/lib/typescript/module/src/models/extractor-context.d.ts +8 -0
  163. package/lib/typescript/module/src/models/extractor-context.d.ts.map +1 -1
  164. package/lib/typescript/module/src/models/index.d.ts +2 -2
  165. package/lib/typescript/module/src/models/index.d.ts.map +1 -1
  166. package/lib/typescript/module/src/models/provider-context.d.ts +6 -2
  167. package/lib/typescript/module/src/models/provider-context.d.ts.map +1 -1
  168. package/lib/typescript/module/src/providers/anime/animepahe/animepahe.d.ts.map +1 -1
  169. package/lib/typescript/module/src/providers/anime/animepahe/create-animepahe.d.ts +1 -1
  170. package/lib/typescript/module/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  171. package/lib/typescript/module/src/providers/anime/animesuge/animesuge.d.ts +34 -0
  172. package/lib/typescript/module/src/providers/anime/animesuge/animesuge.d.ts.map +1 -0
  173. package/lib/typescript/module/src/providers/anime/animesuge/create-animesuge.d.ts +14 -0
  174. package/lib/typescript/module/src/providers/anime/animesuge/create-animesuge.d.ts.map +1 -0
  175. package/lib/typescript/module/src/providers/anime/index.d.ts +2 -2
  176. package/lib/typescript/module/src/providers/anime/index.d.ts.map +1 -1
  177. package/lib/typescript/module/src/providers/anime/zoro/create-zoro.d.ts +1 -1
  178. package/lib/typescript/module/src/providers/anime/zoro/create-zoro.d.ts.map +1 -1
  179. package/lib/typescript/module/src/providers/anime/zoro/zoro.d.ts.map +1 -1
  180. package/lib/typescript/module/src/providers/movies/multistream/index.d.ts +1 -1
  181. package/lib/typescript/module/src/providers/movies/multistream/index.d.ts.map +1 -1
  182. package/lib/typescript/module/src/providers/movies/multistream/utils.d.ts +2 -2
  183. package/lib/typescript/module/src/providers/movies/multistream/utils.d.ts.map +1 -1
  184. package/lib/typescript/module/src/utils/ProviderManager.d.ts +1 -1
  185. package/lib/typescript/module/src/utils/ProviderManager.d.ts.map +1 -1
  186. package/lib/typescript/module/src/utils/create-extractor-context.d.ts.map +1 -1
  187. package/lib/typescript/module/src/utils/create-provider-context.d.ts.map +1 -1
  188. package/lib/typescript/module/src/utils/extension-utils.d.ts +1 -20
  189. package/lib/typescript/module/src/utils/extension-utils.d.ts.map +1 -1
  190. package/lib/typescript/module/src/utils/index.d.ts +2 -1
  191. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  192. package/lib/typescript/module/src/utils/provider-maps.d.ts +27 -0
  193. package/lib/typescript/module/src/utils/provider-maps.d.ts.map +1 -0
  194. package/package.json +6 -2
  195. package/src/NativeConsumet.ts +2 -0
  196. package/src/extension-registry.json +81 -81
  197. package/src/extractors/StreamP2P.ts +60 -60
  198. package/src/extractors/filemoon.ts +58 -58
  199. package/src/extractors/index.ts +41 -41
  200. package/src/extractors/kwik.ts +113 -50
  201. package/src/extractors/megacloud.ts +163 -163
  202. package/src/extractors/mixdrop.ts +31 -31
  203. package/src/extractors/mp4upload.ts +31 -31
  204. package/src/extractors/streamhub.ts +58 -58
  205. package/src/extractors/streamwish.ts +120 -120
  206. package/src/extractors/vidhide.ts +59 -59
  207. package/src/index.tsx +176 -175
  208. package/src/models/extension-manifest.ts +77 -77
  209. package/src/models/extractor-context.ts +55 -41
  210. package/src/models/index.ts +107 -106
  211. package/src/models/provider-context.ts +192 -182
  212. package/src/models/types.ts +531 -531
  213. package/src/models/video-extractor.ts +48 -48
  214. package/src/providers/anime/animedrive.ts +245 -245
  215. package/src/providers/anime/animekai.ts +627 -627
  216. package/src/providers/anime/animepahe/animepahe.ts +76 -76
  217. package/src/providers/anime/animepahe/create-animepahe.ts +350 -348
  218. package/src/providers/anime/animesuge/animesuge.ts +77 -0
  219. package/src/providers/anime/animesuge/create-animesuge.ts +327 -0
  220. package/src/providers/anime/animeunity.ts +216 -216
  221. package/src/providers/anime/index.ts +21 -21
  222. package/src/providers/anime/marin.ts +319 -319
  223. package/src/providers/anime/zoro/create-zoro.ts +656 -655
  224. package/src/providers/anime/zoro/zoro.ts +198 -197
  225. package/src/providers/index.ts +7 -7
  226. package/src/providers/manga/brmangas.ts +144 -144
  227. package/src/providers/meta/anilist.ts +2108 -2108
  228. package/src/providers/meta/mal.ts +635 -635
  229. package/src/providers/meta/tmdb.ts +470 -470
  230. package/src/providers/movies/himovies/create-himovies.ts +529 -529
  231. package/src/providers/movies/himovies/himovies.ts +90 -90
  232. package/src/providers/movies/index.ts +15 -15
  233. package/src/providers/movies/multimovies.ts +495 -495
  234. package/src/providers/movies/multistream/index.ts +232 -231
  235. package/src/providers/movies/multistream/utils.ts +147 -270
  236. package/src/utils/ExtractorManager.ts +311 -311
  237. package/src/utils/ProviderManager.ts +423 -424
  238. package/src/utils/create-extractor-context.ts +36 -22
  239. package/src/utils/create-provider-context.ts +117 -107
  240. package/src/utils/extension-utils.ts +105 -114
  241. package/src/utils/index.ts +96 -95
  242. package/src/utils/provider-maps.ts +31 -0
  243. package/src/utils/providers-list.ts +27 -27
  244. package/src/utils/url-polyfill.ts +642 -642
  245. package/src/utils/utils.ts +374 -374
@@ -1,163 +1,163 @@
1
- import { type ExtractorContext, type IVideo, type ISource, type IVideoExtractor } from '../models';
2
-
3
- /**
4
- * MegaCloud extractor function
5
- * @param ctx ExtractorContext containing axios, load, USER_AGENT
6
- * @returns Object with extract method implementing IVideoExtractor interface
7
- */
8
- export function MegaCloud(ctx: ExtractorContext): IVideoExtractor {
9
- const serverName = 'MegaCloud';
10
- const sources: IVideo[] = [];
11
- const { axios, load, USER_AGENT, PolyURL } = ctx;
12
- /**
13
- * Thanks to https://github.com/yogesh-hacker for the original implementation.
14
- */
15
-
16
- async function getSources(embed_url: URL, site: string) {
17
- const regex = /\/([^/?]+)(?=\?)/;
18
- const xrax = embed_url.toString().match(regex)?.[1];
19
- const basePath = embed_url.pathname.split('/').slice(0, 4).join('/');
20
-
21
- const url = `${embed_url.origin}${basePath}/getSources?id=${xrax}}`;
22
- const getKeyType = url.includes('mega') ? 'mega' : url.includes('videostr') ? 'vidstr' : 'rabbit';
23
- // console.log(`🔗 Fetching sources from: ${url} with key type: ${getKeyType}`);
24
- //gets the base64 encoded string from the URL and key in parallel
25
- let key;
26
-
27
- const headers = {
28
- 'Accept': '*/*',
29
- 'X-Requested-With': 'XMLHttpRequest',
30
- 'Referer': site,
31
- 'User-Agent': USER_AGENT,
32
- };
33
-
34
- try {
35
- const { data: keyData } = await axios?.get(
36
- 'https://raw.githubusercontent.com/yogesh-hacker/MegacloudKeys/refs/heads/main/keys.json'
37
- );
38
- key = keyData;
39
- } catch (err) {
40
- console.error('❌ Error fetching key:', err);
41
- return;
42
- }
43
- // console.log(`🔗 Fetched data: ${key[getKeyType]}`);
44
- let videoTag;
45
- let embedRes;
46
- try {
47
- embedRes = await axios?.get(embed_url.href, { headers });
48
- const $ = load(embedRes.data);
49
- videoTag = $('#megacloud-player');
50
- } catch (error) {
51
- console.error('❌ Error fetching embed URL:', error);
52
- return;
53
- }
54
-
55
- if (!videoTag.length) {
56
- console.error('❌ Looks like URL expired!');
57
- return;
58
- }
59
-
60
- const rawText = embedRes.data;
61
-
62
- let nonceMatch = rawText.match(/\b[a-zA-Z0-9]{48}\b/);
63
- if (!nonceMatch) {
64
- const altMatch = rawText.match(/\b([a-zA-Z0-9]{16})\b.*?\b([a-zA-Z0-9]{16})\b.*?\b([a-zA-Z0-9]{16})\b/);
65
- if (altMatch) nonceMatch = [altMatch.slice(1).join('')];
66
- }
67
-
68
- const nonce = nonceMatch?.[0];
69
- if (!nonce) return console.error('❌ Nonce not found!');
70
- const fileId = videoTag.attr('data-id');
71
-
72
- const { data: encryptedResData } = await axios.get(
73
- `${embed_url.origin}${basePath}/getSources?id=${fileId}&_k=${nonce}`,
74
- {
75
- headers,
76
- }
77
- );
78
- // console.log(
79
- // `🔗 Encrypted response:`,
80
- // encryptedResData,
81
- // `${embed_url.origin}${basePath}/getSources?id=${xrax}&_k=${nonce}`
82
- // );
83
- const encrypted = encryptedResData.encrypted;
84
- const sources = encryptedResData.sources;
85
- let videoSrc = [];
86
-
87
- if (encrypted) {
88
- const decodeUrl =
89
- 'https://script.google.com/macros/s/AKfycbxHbYHbrGMXYD2-bC-C43D3njIbU-wGiYQuJL61H4vyy6YVXkybMNNEPJNPPuZrD1gRVA/exec';
90
-
91
- const params = new URLSearchParams({
92
- encrypted_data: sources,
93
- nonce: nonce,
94
- secret: key[getKeyType],
95
- });
96
-
97
- const decodeRes = await axios.get(`${decodeUrl}?${params.toString()}`);
98
- videoSrc = JSON.parse(decodeRes.data.replace(/\n/g, ' ').match(/\\\[.*?\\\\]/)?.[0]);
99
- // console.log(`🔗 Video URL: ${videoUrl}`, decodeRes.data.match(/"file":"(.*?)"/));
100
- } else {
101
- videoSrc = sources;
102
- }
103
- return {
104
- sources: videoSrc,
105
- tracks: encryptedResData.tracks,
106
- intro: encryptedResData?.intro,
107
- outro: encryptedResData?.outro,
108
- };
109
- }
110
- // @ts-ignore
111
- const extract = async (embedIframeURL: PolyURL, referer = 'https://hianime.to'): Promise<ISource> => {
112
- const extractedData: ISource = {
113
- subtitles: [],
114
- intro: { start: 0, end: 0 },
115
- outro: { start: 0, end: 0 },
116
- sources: [],
117
- };
118
- // console.log(ctx);
119
- try {
120
- const resp = await getSources(embedIframeURL, referer);
121
-
122
- if (!resp) return extractedData;
123
-
124
- if (Array.isArray(resp.sources)) {
125
- extractedData.sources = resp.sources.map((s: { file: any; type: string }) => ({
126
- url: s.file,
127
- isM3U8: s.type === 'hls',
128
- type: s.type,
129
- }));
130
- }
131
-
132
- extractedData.intro = resp.intro ? resp.intro : extractedData.intro;
133
- extractedData.outro = resp.outro ? resp.outro : extractedData.outro;
134
-
135
- extractedData.subtitles = resp.tracks.map((track: { file: any; label: any; kind: any }) => ({
136
- url: track.file,
137
- lang: track.label ? track.label : track.kind,
138
- }));
139
-
140
- extractedData.intro = resp.intro ?? extractedData.intro;
141
- extractedData.outro = resp.outro ?? extractedData.outro;
142
-
143
- extractedData.subtitles =
144
- resp.tracks?.map((track: { file: string; label?: string; kind: string }) => ({
145
- url: track.file,
146
- lang: track.label || track.kind,
147
- })) ?? [];
148
-
149
- // console.log(`[MegaCloud] Extracted ${extractedData.sources.length} source(s)`);
150
-
151
- return extractedData;
152
- } catch (err) {
153
- // console.error('[MegaCloud] Extraction error', err);
154
- throw err;
155
- }
156
- };
157
-
158
- return {
159
- serverName,
160
- sources,
161
- extract,
162
- };
163
- }
1
+ import { type ExtractorContext, type IVideo, type ISource, type IVideoExtractor } from '../models';
2
+
3
+ /**
4
+ * MegaCloud extractor function
5
+ * @param ctx ExtractorContext containing axios, load, USER_AGENT
6
+ * @returns Object with extract method implementing IVideoExtractor interface
7
+ */
8
+ export function MegaCloud(ctx: ExtractorContext): IVideoExtractor {
9
+ const serverName = 'MegaCloud';
10
+ const sources: IVideo[] = [];
11
+ const { axios, load, USER_AGENT, PolyURL } = ctx;
12
+ /**
13
+ * Thanks to https://github.com/yogesh-hacker for the original implementation.
14
+ */
15
+
16
+ async function getSources(embed_url: URL, site: string) {
17
+ const regex = /\/([^/?]+)(?=\?)/;
18
+ const xrax = embed_url.toString().match(regex)?.[1];
19
+ const basePath = embed_url.pathname.split('/').slice(0, 4).join('/');
20
+
21
+ const url = `${embed_url.origin}${basePath}/getSources?id=${xrax}}`;
22
+ const getKeyType = url.includes('mega') ? 'mega' : url.includes('videostr') ? 'vidstr' : 'rabbit';
23
+ // console.log(`🔗 Fetching sources from: ${url} with key type: ${getKeyType}`);
24
+ //gets the base64 encoded string from the URL and key in parallel
25
+ let key;
26
+
27
+ const headers = {
28
+ 'Accept': '*/*',
29
+ 'X-Requested-With': 'XMLHttpRequest',
30
+ 'Referer': site,
31
+ 'User-Agent': USER_AGENT,
32
+ };
33
+
34
+ try {
35
+ const { data: keyData } = await axios?.get(
36
+ 'https://raw.githubusercontent.com/yogesh-hacker/MegacloudKeys/refs/heads/main/keys.json'
37
+ );
38
+ key = keyData;
39
+ } catch (err) {
40
+ console.error('❌ Error fetching key:', err);
41
+ return;
42
+ }
43
+ // console.log(`🔗 Fetched data: ${key[getKeyType]}`);
44
+ let videoTag;
45
+ let embedRes;
46
+ try {
47
+ embedRes = await axios?.get(embed_url.href, { headers });
48
+ const $ = load(embedRes.data);
49
+ videoTag = $('#megacloud-player');
50
+ } catch (error) {
51
+ console.error('❌ Error fetching embed URL:', error);
52
+ return;
53
+ }
54
+
55
+ if (!videoTag.length) {
56
+ console.error('❌ Looks like URL expired!');
57
+ return;
58
+ }
59
+
60
+ const rawText = embedRes.data;
61
+
62
+ let nonceMatch = rawText.match(/\b[a-zA-Z0-9]{48}\b/);
63
+ if (!nonceMatch) {
64
+ const altMatch = rawText.match(/\b([a-zA-Z0-9]{16})\b.*?\b([a-zA-Z0-9]{16})\b.*?\b([a-zA-Z0-9]{16})\b/);
65
+ if (altMatch) nonceMatch = [altMatch.slice(1).join('')];
66
+ }
67
+
68
+ const nonce = nonceMatch?.[0];
69
+ if (!nonce) return console.error('❌ Nonce not found!');
70
+ const fileId = videoTag.attr('data-id');
71
+
72
+ const { data: encryptedResData } = await axios.get(
73
+ `${embed_url.origin}${basePath}/getSources?id=${fileId}&_k=${nonce}`,
74
+ {
75
+ headers,
76
+ }
77
+ );
78
+ // console.log(
79
+ // `🔗 Encrypted response:`,
80
+ // encryptedResData,
81
+ // `${embed_url.origin}${basePath}/getSources?id=${xrax}&_k=${nonce}`
82
+ // );
83
+ const encrypted = encryptedResData.encrypted;
84
+ const sources = encryptedResData.sources;
85
+ let videoSrc = [];
86
+
87
+ if (encrypted) {
88
+ const decodeUrl =
89
+ 'https://script.google.com/macros/s/AKfycbxHbYHbrGMXYD2-bC-C43D3njIbU-wGiYQuJL61H4vyy6YVXkybMNNEPJNPPuZrD1gRVA/exec';
90
+
91
+ const params = new URLSearchParams({
92
+ encrypted_data: sources,
93
+ nonce: nonce,
94
+ secret: key[getKeyType],
95
+ });
96
+
97
+ const decodeRes = await axios.get(`${decodeUrl}?${params.toString()}`);
98
+ videoSrc = JSON.parse(decodeRes.data.replace(/\n/g, ' ').match(/\\\[.*?\\\\]/)?.[0]);
99
+ // console.log(`🔗 Video URL: ${videoUrl}`, decodeRes.data.match(/"file":"(.*?)"/));
100
+ } else {
101
+ videoSrc = sources;
102
+ }
103
+ return {
104
+ sources: videoSrc,
105
+ tracks: encryptedResData.tracks,
106
+ intro: encryptedResData?.intro,
107
+ outro: encryptedResData?.outro,
108
+ };
109
+ }
110
+ // @ts-ignore
111
+ const extract = async (embedIframeURL: PolyURL, referer = 'https://hianime.to'): Promise<ISource> => {
112
+ const extractedData: ISource = {
113
+ subtitles: [],
114
+ intro: { start: 0, end: 0 },
115
+ outro: { start: 0, end: 0 },
116
+ sources: [],
117
+ };
118
+ // console.log(ctx);
119
+ try {
120
+ const resp = await getSources(embedIframeURL, referer);
121
+
122
+ if (!resp) return extractedData;
123
+
124
+ if (Array.isArray(resp.sources)) {
125
+ extractedData.sources = resp.sources.map((s: { file: any; type: string }) => ({
126
+ url: s.file,
127
+ isM3U8: s.type === 'hls',
128
+ type: s.type,
129
+ }));
130
+ }
131
+
132
+ extractedData.intro = resp.intro ? resp.intro : extractedData.intro;
133
+ extractedData.outro = resp.outro ? resp.outro : extractedData.outro;
134
+
135
+ extractedData.subtitles = resp.tracks.map((track: { file: any; label: any; kind: any }) => ({
136
+ url: track.file,
137
+ lang: track.label ? track.label : track.kind,
138
+ }));
139
+
140
+ extractedData.intro = resp.intro ?? extractedData.intro;
141
+ extractedData.outro = resp.outro ?? extractedData.outro;
142
+
143
+ extractedData.subtitles =
144
+ resp.tracks?.map((track: { file: string; label?: string; kind: string }) => ({
145
+ url: track.file,
146
+ lang: track.label || track.kind,
147
+ })) ?? [];
148
+
149
+ // console.log(`[MegaCloud] Extracted ${extractedData.sources.length} source(s)`);
150
+
151
+ return extractedData;
152
+ } catch (err) {
153
+ // console.error('[MegaCloud] Extraction error', err);
154
+ throw err;
155
+ }
156
+ };
157
+
158
+ return {
159
+ serverName,
160
+ sources,
161
+ extract,
162
+ };
163
+ }
@@ -1,31 +1,31 @@
1
- import axios from 'axios';
2
- import { VideoExtractor, type IVideo } from '../models';
3
-
4
- class MixDrop extends VideoExtractor {
5
- protected override serverName = 'MixDrop';
6
- protected override sources: IVideo[] = [];
7
-
8
- override extract = async (videoUrl: URL): Promise<IVideo[]> => {
9
- try {
10
- const { data } = await axios.get(videoUrl.href);
11
-
12
- const formated = eval(/(eval)(\(f.*?)(\n<\/script>)/m.exec(data.replace(/\n/g, ' '))![2]!.replace('eval', ''));
13
-
14
- const [poster, source] = formated
15
- .match(/poster="([^"]+)"|wurl="([^"]+)"/g)
16
- .map((x: string) => x.split(`="`)[1]!.replace(/"/g, ''))
17
- .map((x: string) => (x.startsWith('http') ? x : `https:${x}`));
18
-
19
- this.sources.push({
20
- url: source,
21
- isM3U8: source.includes('.m3u8'),
22
- poster: poster,
23
- });
24
-
25
- return this.sources;
26
- } catch (err) {
27
- throw new Error((err as Error).message);
28
- }
29
- };
30
- }
31
- export default MixDrop;
1
+ import axios from 'axios';
2
+ import { VideoExtractor, type IVideo } from '../models';
3
+
4
+ class MixDrop extends VideoExtractor {
5
+ protected override serverName = 'MixDrop';
6
+ protected override sources: IVideo[] = [];
7
+
8
+ override extract = async (videoUrl: URL): Promise<IVideo[]> => {
9
+ try {
10
+ const { data } = await axios.get(videoUrl.href);
11
+
12
+ const formated = eval(/(eval)(\(f.*?)(\n<\/script>)/m.exec(data.replace(/\n/g, ' '))![2]!.replace('eval', ''));
13
+
14
+ const [poster, source] = formated
15
+ .match(/poster="([^"]+)"|wurl="([^"]+)"/g)
16
+ .map((x: string) => x.split(`="`)[1]!.replace(/"/g, ''))
17
+ .map((x: string) => (x.startsWith('http') ? x : `https:${x}`));
18
+
19
+ this.sources.push({
20
+ url: source,
21
+ isM3U8: source.includes('.m3u8'),
22
+ poster: poster,
23
+ });
24
+
25
+ return this.sources;
26
+ } catch (err) {
27
+ throw new Error((err as Error).message);
28
+ }
29
+ };
30
+ }
31
+ export default MixDrop;
@@ -1,31 +1,31 @@
1
- import axios from 'axios';
2
- import { VideoExtractor, type IVideo } from '../models';
3
-
4
- class Mp4Upload extends VideoExtractor {
5
- protected override serverName = 'mp4upload';
6
- protected override sources: IVideo[] = [];
7
-
8
- override extract = async (videoUrl: URL): Promise<IVideo[]> => {
9
- try {
10
- const { data } = await axios.get(videoUrl.href);
11
-
12
- const playerSrc = data
13
- .replace(/\n/g, ' ')
14
- .match(/player\.src\(\s*{\s*type:\s*"[^"]+",\s*src:\s*"([^"]+)"\s*}\s*\);/);
15
- const streamUrl = playerSrc[1];
16
-
17
- if (!streamUrl) throw new Error('Stream url not found');
18
-
19
- this.sources.push({
20
- quality: 'auto',
21
- url: streamUrl,
22
- isM3U8: streamUrl.includes('.m3u8'),
23
- });
24
-
25
- return this.sources;
26
- } catch (err) {
27
- throw new Error((err as Error).message);
28
- }
29
- };
30
- }
31
- export default Mp4Upload;
1
+ import axios from 'axios';
2
+ import { VideoExtractor, type IVideo } from '../models';
3
+
4
+ class Mp4Upload extends VideoExtractor {
5
+ protected override serverName = 'mp4upload';
6
+ protected override sources: IVideo[] = [];
7
+
8
+ override extract = async (videoUrl: URL): Promise<IVideo[]> => {
9
+ try {
10
+ const { data } = await axios.get(videoUrl.href);
11
+
12
+ const playerSrc = data
13
+ .replace(/\n/g, ' ')
14
+ .match(/player\.src\(\s*{\s*type:\s*"[^"]+",\s*src:\s*"([^"]+)"\s*}\s*\);/);
15
+ const streamUrl = playerSrc[1];
16
+
17
+ if (!streamUrl) throw new Error('Stream url not found');
18
+
19
+ this.sources.push({
20
+ quality: 'auto',
21
+ url: streamUrl,
22
+ isM3U8: streamUrl.includes('.m3u8'),
23
+ });
24
+
25
+ return this.sources;
26
+ } catch (err) {
27
+ throw new Error((err as Error).message);
28
+ }
29
+ };
30
+ }
31
+ export default Mp4Upload;
@@ -1,58 +1,58 @@
1
- import axios from 'axios';
2
- import { VideoExtractor, type IVideo, type ISubtitle } from '../models';
3
-
4
- class StreamHub extends VideoExtractor {
5
- protected override serverName = 'StreamHub';
6
- protected override sources: IVideo[] = [];
7
-
8
- override extract = async (videoUrl: URL): Promise<{ sources: IVideo[] } & { subtitles: ISubtitle[] }> => {
9
- try {
10
- const result: { sources: IVideo[]; subtitles: ISubtitle[] } = {
11
- sources: [],
12
- subtitles: [],
13
- };
14
-
15
- const { data } = await axios.get(videoUrl.href).catch(() => {
16
- throw new Error('Video not found');
17
- });
18
-
19
- const unpackedData = eval(
20
- /(eval)(\(f.*?)(\n<\/script>)/m.exec(data.replace(/\n/g, ' '))![2]!.replace('eval', '')
21
- );
22
-
23
- const links = unpackedData.match(new RegExp('sources:\\[\\{src:"(.*?)"')) ?? [];
24
- const m3u8Content = await axios.get(links[1], {
25
- headers: {
26
- Referer: links[1],
27
- },
28
- });
29
-
30
- result.sources.push({
31
- quality: 'auto',
32
- url: links[1],
33
- isM3U8: links[1].includes('.m3u8'),
34
- });
35
-
36
- if (m3u8Content.data.includes('EXTM3U')) {
37
- const videoList = m3u8Content.data.split('#EXT-X-STREAM-INF:');
38
- for (const video of videoList ?? []) {
39
- if (!video.includes('m3u8')) continue;
40
-
41
- const url = video.split('\n')[1];
42
- const quality = video.split('RESOLUTION=')[1].split(',')[0].split('x')[1];
43
-
44
- result.sources.push({
45
- url: url,
46
- quality: `${quality}p`,
47
- isM3U8: url.includes('.m3u8'),
48
- });
49
- }
50
- }
51
-
52
- return result;
53
- } catch (err) {
54
- throw new Error((err as Error).message);
55
- }
56
- };
57
- }
58
- export default StreamHub;
1
+ import axios from 'axios';
2
+ import { VideoExtractor, type IVideo, type ISubtitle } from '../models';
3
+
4
+ class StreamHub extends VideoExtractor {
5
+ protected override serverName = 'StreamHub';
6
+ protected override sources: IVideo[] = [];
7
+
8
+ override extract = async (videoUrl: URL): Promise<{ sources: IVideo[] } & { subtitles: ISubtitle[] }> => {
9
+ try {
10
+ const result: { sources: IVideo[]; subtitles: ISubtitle[] } = {
11
+ sources: [],
12
+ subtitles: [],
13
+ };
14
+
15
+ const { data } = await axios.get(videoUrl.href).catch(() => {
16
+ throw new Error('Video not found');
17
+ });
18
+
19
+ const unpackedData = eval(
20
+ /(eval)(\(f.*?)(\n<\/script>)/m.exec(data.replace(/\n/g, ' '))![2]!.replace('eval', '')
21
+ );
22
+
23
+ const links = unpackedData.match(new RegExp('sources:\\[\\{src:"(.*?)"')) ?? [];
24
+ const m3u8Content = await axios.get(links[1], {
25
+ headers: {
26
+ Referer: links[1],
27
+ },
28
+ });
29
+
30
+ result.sources.push({
31
+ quality: 'auto',
32
+ url: links[1],
33
+ isM3U8: links[1].includes('.m3u8'),
34
+ });
35
+
36
+ if (m3u8Content.data.includes('EXTM3U')) {
37
+ const videoList = m3u8Content.data.split('#EXT-X-STREAM-INF:');
38
+ for (const video of videoList ?? []) {
39
+ if (!video.includes('m3u8')) continue;
40
+
41
+ const url = video.split('\n')[1];
42
+ const quality = video.split('RESOLUTION=')[1].split(',')[0].split('x')[1];
43
+
44
+ result.sources.push({
45
+ url: url,
46
+ quality: `${quality}p`,
47
+ isM3U8: url.includes('.m3u8'),
48
+ });
49
+ }
50
+ }
51
+
52
+ return result;
53
+ } catch (err) {
54
+ throw new Error((err as Error).message);
55
+ }
56
+ };
57
+ }
58
+ export default StreamHub;