react-native-consumet 0.4.2 → 0.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 (100) hide show
  1. package/android/src/main/java/com/consumet/ConsumetModule.kt +3 -3
  2. package/lib/commonjs/index.js +1 -0
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/models/index.js.map +1 -1
  5. package/lib/commonjs/models/proxy.js +80 -25
  6. package/lib/commonjs/models/proxy.js.map +1 -1
  7. package/lib/commonjs/models/types.js.map +1 -1
  8. package/lib/commonjs/providers/anime/animekai.js +19 -14
  9. package/lib/commonjs/providers/anime/animekai.js.map +1 -1
  10. package/lib/commonjs/providers/anime/animepahe.js +5 -0
  11. package/lib/commonjs/providers/anime/animepahe.js.map +1 -1
  12. package/lib/commonjs/providers/anime/zoro.js +26 -19
  13. package/lib/commonjs/providers/anime/zoro.js.map +1 -1
  14. package/lib/commonjs/providers/meta/anilist.js +45 -214
  15. package/lib/commonjs/providers/meta/anilist.js.map +1 -1
  16. package/lib/commonjs/providers/meta/mal.js +4 -4
  17. package/lib/commonjs/providers/meta/mal.js.map +1 -1
  18. package/lib/commonjs/providers/meta/tmdb.js +8 -15
  19. package/lib/commonjs/providers/meta/tmdb.js.map +1 -1
  20. package/lib/commonjs/providers/movies/multimovies.js +16 -8
  21. package/lib/commonjs/providers/movies/multimovies.js.map +1 -1
  22. package/lib/commonjs/utils/index.js +4 -4
  23. package/lib/commonjs/utils/utils.js +140 -4
  24. package/lib/commonjs/utils/utils.js.map +1 -1
  25. package/lib/module/index.js +1 -0
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/models/index.js.map +1 -1
  28. package/lib/module/models/proxy.js +80 -25
  29. package/lib/module/models/proxy.js.map +1 -1
  30. package/lib/module/models/types.js.map +1 -1
  31. package/lib/module/providers/anime/animekai.js +18 -14
  32. package/lib/module/providers/anime/animekai.js.map +1 -1
  33. package/lib/module/providers/anime/animepahe.js +5 -0
  34. package/lib/module/providers/anime/animepahe.js.map +1 -1
  35. package/lib/module/providers/anime/zoro.js +25 -19
  36. package/lib/module/providers/anime/zoro.js.map +1 -1
  37. package/lib/module/providers/meta/anilist.js +46 -215
  38. package/lib/module/providers/meta/anilist.js.map +1 -1
  39. package/lib/module/providers/meta/mal.js +5 -5
  40. package/lib/module/providers/meta/mal.js.map +1 -1
  41. package/lib/module/providers/meta/tmdb.js +9 -16
  42. package/lib/module/providers/meta/tmdb.js.map +1 -1
  43. package/lib/module/providers/movies/multimovies.js +16 -8
  44. package/lib/module/providers/movies/multimovies.js.map +1 -1
  45. package/lib/module/utils/index.js +2 -2
  46. package/lib/module/utils/index.js.map +1 -1
  47. package/lib/module/utils/utils.js +126 -1
  48. package/lib/module/utils/utils.js.map +1 -1
  49. package/lib/typescript/commonjs/src/index.d.ts +3 -2
  50. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  51. package/lib/typescript/commonjs/src/models/index.d.ts +2 -2
  52. package/lib/typescript/commonjs/src/models/index.d.ts.map +1 -1
  53. package/lib/typescript/commonjs/src/models/proxy.d.ts +6 -7
  54. package/lib/typescript/commonjs/src/models/proxy.d.ts.map +1 -1
  55. package/lib/typescript/commonjs/src/models/types.d.ts +36 -7
  56. package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
  57. package/lib/typescript/commonjs/src/providers/anime/animekai.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/src/providers/anime/animepahe.d.ts.map +1 -1
  59. package/lib/typescript/commonjs/src/providers/anime/zoro.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts +0 -3
  61. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/src/providers/meta/tmdb.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/src/providers/movies/multimovies.d.ts.map +1 -1
  64. package/lib/typescript/commonjs/src/utils/index.d.ts +2 -2
  65. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/src/utils/utils.d.ts +15 -1
  67. package/lib/typescript/commonjs/src/utils/utils.d.ts.map +1 -1
  68. package/lib/typescript/module/src/index.d.ts +3 -2
  69. package/lib/typescript/module/src/index.d.ts.map +1 -1
  70. package/lib/typescript/module/src/models/index.d.ts +2 -2
  71. package/lib/typescript/module/src/models/index.d.ts.map +1 -1
  72. package/lib/typescript/module/src/models/proxy.d.ts +6 -7
  73. package/lib/typescript/module/src/models/proxy.d.ts.map +1 -1
  74. package/lib/typescript/module/src/models/types.d.ts +36 -7
  75. package/lib/typescript/module/src/models/types.d.ts.map +1 -1
  76. package/lib/typescript/module/src/providers/anime/animekai.d.ts.map +1 -1
  77. package/lib/typescript/module/src/providers/anime/animepahe.d.ts.map +1 -1
  78. package/lib/typescript/module/src/providers/anime/zoro.d.ts.map +1 -1
  79. package/lib/typescript/module/src/providers/meta/anilist.d.ts +0 -3
  80. package/lib/typescript/module/src/providers/meta/anilist.d.ts.map +1 -1
  81. package/lib/typescript/module/src/providers/meta/tmdb.d.ts.map +1 -1
  82. package/lib/typescript/module/src/providers/movies/multimovies.d.ts.map +1 -1
  83. package/lib/typescript/module/src/utils/index.d.ts +2 -2
  84. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  85. package/lib/typescript/module/src/utils/utils.d.ts +15 -1
  86. package/lib/typescript/module/src/utils/utils.d.ts.map +1 -1
  87. package/package.json +8 -11
  88. package/src/{index.ts → index.tsx} +5 -0
  89. package/src/models/index.ts +4 -0
  90. package/src/models/proxy.ts +80 -30
  91. package/src/models/types.ts +37 -3
  92. package/src/providers/anime/animekai.ts +17 -14
  93. package/src/providers/anime/animepahe.ts +8 -0
  94. package/src/providers/anime/zoro.ts +25 -20
  95. package/src/providers/meta/anilist.ts +81 -330
  96. package/src/providers/meta/mal.ts +5 -5
  97. package/src/providers/meta/tmdb.ts +11 -16
  98. package/src/providers/movies/multimovies.ts +15 -11
  99. package/src/utils/index.ts +2 -2
  100. package/src/utils/utils.ts +162 -1
@@ -13,9 +13,9 @@ import { MixDrop, StreamTape, StreamWish, VidHide } from '../../extractors';
13
13
 
14
14
  class MultiMovies extends MovieParser {
15
15
  override readonly name = 'MultiMovies';
16
- protected override baseUrl = 'https://multimovies.guru';
16
+ protected override baseUrl = 'https://multimovies.digital';
17
17
  protected override logo =
18
- 'https://multimovies.guru/wp-content/uploads/2024/01/cropped-CompressJPEG.online_512x512_image.png';
18
+ 'https://multimovies.digital/wp-content/uploads/2024/01/cropped-CompressJPEG.online_512x512_image.png';
19
19
  protected override classPath = 'MOVIES.MultiMovies';
20
20
  override supportedTypes = new Set([TvType.MOVIE, TvType.TVSERIES]);
21
21
  constructor(customBaseURL?: string) {
@@ -383,13 +383,15 @@ class MultiMovies extends MovieParser {
383
383
  const headers = {
384
384
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
385
385
  };
386
-
387
- const playerRes = await this.client.post(`${this.baseUrl}/wp-admin/admin-ajax.php`, formData, {
388
- headers,
386
+ console.log(`${this.baseUrl}/wp-admin/admin-ajax.php`, formData);
387
+ const response = await fetch(`${this.baseUrl}/wp-admin/admin-ajax.php`, {
388
+ method: 'POST',
389
+ headers: headers,
390
+ body: formData,
389
391
  });
390
-
391
- const iframeUrl =
392
- playerRes.data?.embed_url?.match(/<iframe[^>]+src="([^"]+)"[^>]*>/i)?.[1] || playerRes.data?.embed_url;
392
+ const playerRes = await response.json();
393
+ // console.log('playerRes', playerRes);
394
+ const iframeUrl = playerRes?.embed_url?.match(/<iframe[^>]+src="([^"]+)"[^>]*>/i)?.[1] || playerRes?.embed_url;
393
395
 
394
396
  // Handle non-multimovies case
395
397
  if (!iframeUrl.includes('multimovies')) {
@@ -417,12 +419,14 @@ class MultiMovies extends MovieParser {
417
419
  headers,
418
420
  });
419
421
 
422
+ // console.log('streamResponse', streamResponse.data);
423
+
420
424
  if (!streamResponse.data) {
421
425
  throw new Error('No stream data found');
422
426
  }
423
427
 
424
428
  const streamDetails = streamResponse.data;
425
- const mresultKeys = new Set(Object.keys(streamDetails.mresult));
429
+ const mresultKeys = new Set(Object.keys(JSON.parse(atob(streamDetails.mresult))));
426
430
  const siteUrlsKeys = new Set(Object.keys(streamDetails.siteUrls));
427
431
 
428
432
  // Find common keys
@@ -436,19 +440,19 @@ class MultiMovies extends MovieParser {
436
440
  streamDetails.siteFriendlyNames[site] === 'StreamHG'
437
441
  ? 'StreamWish'
438
442
  : streamDetails.siteFriendlyNames[site],
439
- url: streamDetails.siteUrls[site] + streamDetails.mresult[site],
443
+ url: streamDetails.siteUrls[site] + JSON.parse(atob(streamDetails.mresult))[site],
440
444
  };
441
445
  });
442
446
 
443
447
  return { servers, fileId };
444
448
  } else {
445
- //@Durgesh
446
449
  return {
447
450
  servers: [{ name: 'StreamWish', url: iframeUrl }],
448
451
  fileId: iframeUrl.split('/').pop() ?? '',
449
452
  };
450
453
  }
451
454
  } catch (err) {
455
+ console.log(err);
452
456
  throw new Error((err as Error).message);
453
457
  }
454
458
  }
@@ -30,7 +30,7 @@ import {
30
30
  convertDuration,
31
31
  substringAfter,
32
32
  substringBefore,
33
- compareTwoStrings,
33
+ calculateStringSimilarity,
34
34
  } from './utils';
35
35
  import {
36
36
  anilistSearchQuery,
@@ -88,7 +88,7 @@ export {
88
88
  AsianLoad,
89
89
  substringAfter,
90
90
  substringBefore,
91
- compareTwoStrings,
91
+ calculateStringSimilarity,
92
92
  VidMoly,
93
93
  getKKey,
94
94
  MegaUp,
@@ -1,3 +1,4 @@
1
+ import { compareTwoStrings } from 'string-similarity';
1
2
  // import sharp from 'sharp';
2
3
  import { load } from 'cheerio';
3
4
  // import * as blurhash from 'blurhash';
@@ -104,7 +105,7 @@ export function convertDuration(milliseconds: number) {
104
105
  return `PT${hours}H${minutes}M${seconds}S`;
105
106
  }
106
107
 
107
- export const compareTwoStrings = (first: string, second: string): number => {
108
+ export const calculateStringSimilarity = (first: string, second: string): number => {
108
109
  first = first.replace(/\s+/g, '');
109
110
  second = second.replace(/\s+/g, '');
110
111
 
@@ -176,3 +177,163 @@ export const getHashFromImage = (url: string) => {
176
177
  return 'hash';
177
178
  }
178
179
  };
180
+
181
+ // Function to find similar titles
182
+ export function findSimilarTitles(inputTitle: string, titles: any[]): any[] {
183
+ const results: (any & { similarity: number })[] = [];
184
+
185
+ titles?.forEach((titleObj: any) => {
186
+ const title = cleanTitle(
187
+ titleObj?.title
188
+ ?.toLowerCase()
189
+ ?.replace(/\([^\)]*\)/g, '')
190
+ .trim() || ''
191
+ );
192
+
193
+ // Calculate similarity score between inputTitle and title
194
+ const similarity = compareTwoStrings(cleanTitle(inputTitle?.toLowerCase() || ''), title);
195
+
196
+ if (similarity > 0.6) {
197
+ results.push({ ...titleObj, similarity });
198
+ }
199
+ });
200
+
201
+ const isSubAvailable = results.some((result) => result.episodes && result.episodes.sub > 0);
202
+
203
+ // If episodes.sub is available, sort the results
204
+ if (isSubAvailable) {
205
+ return results.sort((a, b) => {
206
+ // First sort by similarity in descending order
207
+ if (b.similarity !== a.similarity) {
208
+ return b.similarity - a.similarity;
209
+ }
210
+ // If similarity is the same, sort by episodes.sub in descending order
211
+ return (b.episodes?.sub || 0) - (a.episodes?.sub || 0);
212
+ });
213
+ }
214
+
215
+ // If episodes.sub is not available, return the original list
216
+ return results.sort((a, b) => b.similarity - a.similarity);
217
+ }
218
+
219
+ // Function to convert Roman numerals to Arabic numbers
220
+ function romanToArabic(roman: string): number {
221
+ const romanMap: Record<string, number> = {
222
+ i: 1,
223
+ v: 5,
224
+ x: 10,
225
+ l: 50,
226
+ c: 100,
227
+ d: 500,
228
+ m: 1000,
229
+ };
230
+
231
+ roman = roman.toLowerCase();
232
+ let result = 0;
233
+
234
+ for (let i = 0; i < roman.length; i++) {
235
+ const current = romanMap[roman[i]!]!;
236
+ const next = romanMap[roman[i + 1]!];
237
+
238
+ if (next && current < next) {
239
+ result += next - current;
240
+ i++;
241
+ } else {
242
+ result += current;
243
+ }
244
+ }
245
+
246
+ return result;
247
+ }
248
+
249
+ export function cleanTitle(title: string | undefined | null): string {
250
+ if (!title) return '';
251
+
252
+ return transformSpecificVariations(
253
+ removeSpecialChars(
254
+ title
255
+ .replaceAll(/[^A-Za-z0-9!@#$%^&*() ]/gim, ' ')
256
+ .replaceAll(/(th|rd|nd|st) (Season|season)/gim, '')
257
+ .replaceAll(/\([^\(]*\)$/gim, '')
258
+ .replaceAll('season', '')
259
+ .replaceAll(/\b(IX|IV|V?I{0,3})\b/gi, (match) => romanToArabic(match).toString())
260
+ .replaceAll(' ', ' ')
261
+ .replaceAll('"', '')
262
+ .trimEnd()
263
+ )
264
+ );
265
+ }
266
+
267
+ export function removeSpecialChars(title: string | undefined | null): string {
268
+ if (!title) return '';
269
+
270
+ return title
271
+ .replaceAll(/[^A-Za-z0-9!@#$%^&*()\-= ]/gim, ' ')
272
+ .replaceAll(/[^A-Za-z0-9\-= ]/gim, '')
273
+ .replaceAll(' ', ' ');
274
+ }
275
+
276
+ export function transformSpecificVariations(title: string | undefined | null): string {
277
+ if (!title) return '';
278
+
279
+ return title.replaceAll('yuu', 'yu').replaceAll(' ou', ' oh');
280
+ }
281
+
282
+ export function sanitizeTitle(title: string): string {
283
+ let resTitle = title.replace(/ *(\(dub\)|\(sub\)|\(uncensored\)|\(uncut\)|\(subbed\)|\(dubbed\))/i, '');
284
+ resTitle = resTitle.replace(/ *\([^)]+audio\)/i, '');
285
+ resTitle = resTitle.replace(/ BD( |$)/i, '');
286
+ resTitle = resTitle.replace(/\(TV\)/g, '');
287
+ resTitle = resTitle.trim();
288
+ resTitle = resTitle.substring(0, 99); // truncate
289
+ return resTitle;
290
+ }
291
+
292
+ export function stringSearch(string: string, pattern: string): number {
293
+ let count = 0;
294
+ string = string.toLowerCase();
295
+ pattern = pattern.toLowerCase();
296
+ string = string.replace(/[^a-zA-Z0-9 -]/g, '');
297
+ pattern = pattern.replace(/[^a-zA-Z0-9 -]/g, '');
298
+
299
+ for (let i = 0; i < string.length; i++) {
300
+ for (let j = 0; j < pattern.length; j++) {
301
+ if (pattern[j] !== string[i + j]) break;
302
+ if (j === pattern.length - 1) count++;
303
+ }
304
+ }
305
+ return count;
306
+ }
307
+
308
+ export function parseUrl(url: string): {
309
+ href: string;
310
+ origin: string;
311
+ pathname: string;
312
+ hostname: string;
313
+ search: string;
314
+ hash: string;
315
+ } {
316
+ // Simple URL parser for React Native
317
+ try {
318
+ const match = url.match(/^(https?:\/\/[^\/]+)(\/[^?#]*)?(\?[^#]*)?(#.*)?$/);
319
+ if (!match) throw new Error(`Invalid URL: ${url}`);
320
+
321
+ const origin = match[1] || '';
322
+ const pathname = match[2] || '/';
323
+ const search = match[3] || '';
324
+ const hash = match[4] || '';
325
+
326
+ return {
327
+ href: url,
328
+ origin,
329
+ pathname,
330
+ hostname: origin.replace(/^https?:\/\//, ''),
331
+ search,
332
+ hash,
333
+ };
334
+ } catch (e) {
335
+ console.error(`Error parsing URL: ${url}`, e);
336
+ // Return a minimal object with href to prevent crashes
337
+ return { href: url, origin: '', pathname: '', hostname: '', search: '', hash: '' };
338
+ }
339
+ }