react-native-consumet 0.6.1 → 0.6.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 (69) hide show
  1. package/android/build.gradle +6 -4
  2. package/android/generated/java/com/consumet/NativeConsumetSpec.java +5 -0
  3. package/android/generated/jni/RNConsumetSpec-generated.cpp +6 -0
  4. package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI-generated.cpp +8 -0
  5. package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI.h +9 -0
  6. package/android/src/main/java/com/consumet/ConsumetModule.kt +7 -1
  7. package/android/src/main/java/com/consumet/DdosGuardModule.kt +176 -33
  8. package/ios/generated/RNConsumetSpec/RNConsumetSpec-generated.mm +7 -0
  9. package/ios/generated/RNConsumetSpec/RNConsumetSpec.h +4 -0
  10. package/ios/generated/RNConsumetSpecJSI-generated.cpp +8 -0
  11. package/ios/generated/RNConsumetSpecJSI.h +9 -0
  12. package/lib/commonjs/NativeConsumet.ts +9 -0
  13. package/lib/commonjs/index.js +4 -2
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/providers/anime/animepahe.js +0 -1
  16. package/lib/commonjs/providers/anime/animepahe.js.map +1 -1
  17. package/lib/commonjs/providers/meta/anilist.js +26 -16
  18. package/lib/commonjs/providers/meta/anilist.js.map +1 -1
  19. package/lib/commonjs/providers/movies/index.js +3 -1
  20. package/lib/commonjs/providers/movies/index.js.map +1 -1
  21. package/lib/commonjs/providers/movies/netflixmirror.js +243 -0
  22. package/lib/commonjs/providers/movies/netflixmirror.js.map +1 -0
  23. package/lib/commonjs/utils/providers-list.js +1 -1
  24. package/lib/commonjs/utils/providers-list.js.map +1 -1
  25. package/lib/module/NativeConsumet.ts +9 -0
  26. package/lib/module/index.js +2 -1
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/module/providers/anime/animepahe.js +0 -1
  29. package/lib/module/providers/anime/animepahe.js.map +1 -1
  30. package/lib/module/providers/meta/anilist.js +26 -16
  31. package/lib/module/providers/meta/anilist.js.map +1 -1
  32. package/lib/module/providers/movies/index.js +3 -1
  33. package/lib/module/providers/movies/index.js.map +1 -1
  34. package/lib/module/providers/movies/netflixmirror.js +240 -0
  35. package/lib/module/providers/movies/netflixmirror.js.map +1 -0
  36. package/lib/module/utils/providers-list.js +1 -1
  37. package/lib/module/utils/providers-list.js.map +1 -1
  38. package/lib/typescript/commonjs/src/NativeConsumet.d.ts +8 -0
  39. package/lib/typescript/commonjs/src/NativeConsumet.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/src/index.d.ts +8 -1
  41. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/src/providers/anime/animepahe.d.ts.map +1 -1
  43. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/src/providers/movies/index.d.ts +2 -0
  45. package/lib/typescript/commonjs/src/providers/movies/index.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/src/providers/movies/netflixmirror.d.ts +38 -0
  47. package/lib/typescript/commonjs/src/providers/movies/netflixmirror.d.ts.map +1 -0
  48. package/lib/typescript/commonjs/src/utils/providers-list.d.ts +1 -1
  49. package/lib/typescript/commonjs/src/utils/providers-list.d.ts.map +1 -1
  50. package/lib/typescript/module/src/NativeConsumet.d.ts +8 -0
  51. package/lib/typescript/module/src/NativeConsumet.d.ts.map +1 -1
  52. package/lib/typescript/module/src/index.d.ts +8 -1
  53. package/lib/typescript/module/src/index.d.ts.map +1 -1
  54. package/lib/typescript/module/src/providers/anime/animepahe.d.ts.map +1 -1
  55. package/lib/typescript/module/src/providers/meta/anilist.d.ts.map +1 -1
  56. package/lib/typescript/module/src/providers/movies/index.d.ts +2 -0
  57. package/lib/typescript/module/src/providers/movies/index.d.ts.map +1 -1
  58. package/lib/typescript/module/src/providers/movies/netflixmirror.d.ts +38 -0
  59. package/lib/typescript/module/src/providers/movies/netflixmirror.d.ts.map +1 -0
  60. package/lib/typescript/module/src/utils/providers-list.d.ts +1 -1
  61. package/lib/typescript/module/src/utils/providers-list.d.ts.map +1 -1
  62. package/package.json +1 -1
  63. package/src/NativeConsumet.ts +9 -0
  64. package/src/index.tsx +1 -1
  65. package/src/providers/anime/animepahe.ts +0 -1
  66. package/src/providers/meta/anilist.ts +28 -18
  67. package/src/providers/movies/index.ts +2 -0
  68. package/src/providers/movies/netflixmirror.ts +287 -0
  69. package/src/utils/providers-list.ts +1 -0
@@ -5,6 +5,15 @@ export interface Spec extends TurboModule {
5
5
  getSources(xrax: string): Promise<string>;
6
6
  bypassDdosGuard(url: string): Promise<{ cookie: string }>;
7
7
  getDdosGuardCookiesWithWebView(url: string): Promise<string>;
8
+ makeGetRequestWithWebView(
9
+ url: string,
10
+ headers: { [key: string]: string }
11
+ ): Promise<{
12
+ url: string;
13
+ response: string;
14
+ cookies: string;
15
+ status: string;
16
+ }>;
8
17
  }
9
18
 
10
19
  export default TurboModuleRegistry.getEnforcing<Spec>('Consumet');
package/src/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'react-native-url-polyfill/auto';
2
2
  import Consumet from './NativeConsumet';
3
3
 
4
- export const { getSources, bypassDdosGuard, getDdosGuardCookiesWithWebView } = Consumet;
4
+ export const { getSources, bypassDdosGuard, getDdosGuardCookiesWithWebView, makeGetRequestWithWebView } = Consumet;
5
5
 
6
6
  import { ANIME, COMICS, LIGHT_NOVELS, MANGA, MOVIES, META, NEWS } from './providers';
7
7
  import { PROVIDERS_LIST } from './utils/providers-list';
@@ -29,7 +29,6 @@ class AnimePahe extends AnimeParser {
29
29
 
30
30
  constructor() {
31
31
  super();
32
- // Initialize the DDoS-Guard cookie when the instance is created
33
32
  this.initDdgCookie();
34
33
  }
35
34
 
@@ -1166,26 +1166,35 @@ class Anilist extends AnimeParser {
1166
1166
  releaseDate: item.airDate ?? item.airdate ?? item.airDateUtc,
1167
1167
  }));
1168
1168
 
1169
- function isDateClose(date1: string, date2: string, maxDaysDiff = 1) {
1170
- const d1 = new Date(date1);
1171
- const d2 = new Date(date2);
1172
- const diffTime = Math.abs(d1.getTime() - d2.getTime());
1173
- const diffDays = diffTime / (1000 * 60 * 60 * 24);
1174
- return diffDays <= maxDaysDiff;
1175
- }
1176
-
1177
1169
  function mergeEpisodes(normalizedEpisodes: any[], providerEpisodes: IAnimeEpisode[]): IAnimeEpisode[] {
1170
+ const numberMap = new Map<number, any>();
1171
+ const dateMap = new Map<number, any>();
1172
+
1173
+ normalizedEpisodes.forEach((ep) => {
1174
+ if (ep.number) numberMap.set(ep.number, ep);
1175
+ if (ep.releaseDate) {
1176
+ const ts = new Date(ep.releaseDate).getTime();
1177
+ dateMap.set(ts, ep);
1178
+ }
1179
+ });
1180
+
1178
1181
  return providerEpisodes.map((providerEp, index) => {
1179
1182
  let normalizedEp: any = null;
1180
1183
 
1181
1184
  if (providerEp.releaseDate) {
1182
- normalizedEp = normalizedEpisodes.find(
1183
- (normEp) => normEp.releaseDate && isDateClose(normEp.releaseDate, providerEp.releaseDate!)
1184
- );
1185
+ const ts = new Date(providerEp.releaseDate).getTime();
1186
+ // Find dates within 1 day range
1187
+ for (let [normTs, normEp] of dateMap) {
1188
+ if (Math.abs(ts - normTs) <= 86400000) {
1189
+ // 1 day in ms
1190
+ normalizedEp = normEp;
1191
+ break;
1192
+ }
1193
+ }
1185
1194
  }
1186
1195
 
1187
- if (!normalizedEp) {
1188
- normalizedEp = normalizedEpisodes.find((normEp) => normEp.number === providerEp.number);
1196
+ if (!normalizedEp && providerEp.number != null) {
1197
+ normalizedEp = numberMap.get(providerEp.number);
1189
1198
  }
1190
1199
 
1191
1200
  if (!normalizedEp && providerEp.title) {
@@ -1202,6 +1211,7 @@ class Anilist extends AnimeParser {
1202
1211
 
1203
1212
  return {
1204
1213
  ...providerEp,
1214
+ number: normalizedEp.number || providerEp.number,
1205
1215
  uniqueId: normalizedEp.uniqueId || providerEp.uniqueId,
1206
1216
  title: normalizedEp.title || providerEp.title,
1207
1217
  description: normalizedEp.description || providerEp.description,
@@ -1212,11 +1222,11 @@ class Anilist extends AnimeParser {
1212
1222
  });
1213
1223
  }
1214
1224
 
1215
- // console.log({
1216
- // normalizedEpisodes,
1217
- // providerEpisodes,
1218
- // merged: mergeEpisodes(normalizedEpisodes, providerEpisodes),
1219
- // });
1225
+ console.log({
1226
+ normalizedEpisodes,
1227
+ providerEpisodes,
1228
+ merged: mergeEpisodes(normalizedEpisodes, providerEpisodes),
1229
+ });
1220
1230
  possibleAnimeEpisodes = mergeEpisodes(normalizedEpisodes, providerEpisodes);
1221
1231
  if (!possibleAnimeEpisodes.length) {
1222
1232
  possibleAnimeEpisodes = await this.fetchDefaultEpisodeList(Media);
@@ -9,6 +9,7 @@ import Turkish from './turkish123';
9
9
  import ViewAsian from './viewAsian';
10
10
  import SFlix from './sflix';
11
11
  import MultiMovies from './multimovies';
12
+ import NetflixMirror from './netflixmirror';
12
13
 
13
14
  export default {
14
15
  DramaCool,
@@ -22,4 +23,5 @@ export default {
22
23
  Turkish,
23
24
  SFlix,
24
25
  MultiMovies,
26
+ NetflixMirror,
25
27
  };
@@ -0,0 +1,287 @@
1
+ import {
2
+ MovieParser,
3
+ TvType,
4
+ type IMovieInfo,
5
+ type IEpisodeServer,
6
+ type ISource,
7
+ type IMovieResult,
8
+ type ISearch,
9
+ type IMovieEpisode,
10
+ } from '../../models';
11
+ import { makeGetRequestWithWebView } from '../../index';
12
+ class NetflixMirror extends MovieParser {
13
+ override readonly name = 'NetflixMirror';
14
+ protected override baseUrl = 'https://netfree2.cc';
15
+ protected override logo = 'https://netfree2.cc//mobile/img/nf2/icon_x192.png';
16
+ protected override classPath = 'MOVIES.NetflixMirror';
17
+ override supportedTypes = new Set([TvType.MOVIE, TvType.TVSERIES]);
18
+ private nfCookie: null | string = 'hd=on;';
19
+
20
+ constructor(customBaseURL?: string) {
21
+ super(...arguments);
22
+ if (customBaseURL) {
23
+ if (customBaseURL.startsWith('http://') || customBaseURL.startsWith('https://')) {
24
+ this.baseUrl = customBaseURL;
25
+ } else {
26
+ this.baseUrl = `http://${customBaseURL}`;
27
+ }
28
+ } else {
29
+ this.baseUrl = this.baseUrl;
30
+ }
31
+ this.initCookie();
32
+ }
33
+
34
+ private async initCookie(): Promise<void> {
35
+ try {
36
+ const { data } = await this.client.get(
37
+ 'https://raw.githubusercontent.com/2004durgesh/nfmirror-cookies/refs/heads/main/captured-cookies.json'
38
+ );
39
+ for (const cookie of data.cookiesByDomain['.netfree2.cc']) {
40
+ this.nfCookie += `${cookie.name}=${cookie.value.replace('%3A%3Asu', '%3A%3Ani')};`;
41
+ }
42
+ } catch (err) {
43
+ console.error('Failed to get cookie:', err);
44
+ }
45
+ }
46
+
47
+ private Headers() {
48
+ const headers: Record<string, string> = {
49
+ 'authority': 'netfree2.cc',
50
+ 'accept': 'application/json, text/javascript, */*; q=0.01',
51
+ 'sec-ch-ua': '"Not A(Brand";v="99", "Microsoft Edge";v="121", "Chromium";v="121"',
52
+ 'sec-ch-ua-mobile': '?0',
53
+ 'sec-ch-ua-platform': '"Windows"',
54
+ 'sec-fetch-dest': 'empty',
55
+ 'sec-fetch-mode': 'cors',
56
+ 'sec-fetch-site': 'same-origin',
57
+ 'x-requested-with': 'XMLHttpRequest',
58
+ 'Referer': `${this.baseUrl}/mobile/home`,
59
+ 'user-agent':
60
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
61
+ };
62
+
63
+ if (this.nfCookie) {
64
+ headers.Cookie = this.nfCookie || '';
65
+ }
66
+
67
+ return headers;
68
+ }
69
+
70
+ /**
71
+ *
72
+ * @param query search query string
73
+ * @param page page number (default 1) (optional)
74
+ */
75
+ override search = async (query: string, page: number = 1): Promise<ISearch<IMovieResult>> => {
76
+ const searchResult: ISearch<IMovieResult> = {
77
+ currentPage: page,
78
+ hasNextPage: false,
79
+ results: [],
80
+ };
81
+ try {
82
+ const { data } = await this.client.get(
83
+ `https://netmirror.8man.me/api/net-proxy?isPrime=false&url=${
84
+ this.baseUrl
85
+ }/mobile/search.php?s=${encodeURI(query)}`,
86
+ {
87
+ headers: this.Headers(),
88
+ }
89
+ );
90
+
91
+ const basicResults = data.searchResult || [];
92
+
93
+ if (basicResults.length === 0) {
94
+ return searchResult;
95
+ }
96
+ const detailedResults = await Promise.all(
97
+ basicResults.map(async (item: any) => {
98
+ try {
99
+ // Fetch additional details for each item
100
+ const detailResponse = await this.client.get(
101
+ `https://netmirror.8man.me/api/net-proxy?isPrime=false&url=${this.baseUrl}/mobile/post.php?id=${item.id}`,
102
+ {
103
+ headers: this.Headers(),
104
+ }
105
+ );
106
+
107
+ return {
108
+ id: item.id,
109
+ title: item.t,
110
+ image: `https://imgcdn.media/poster/v/${item.id}.jpg`,
111
+ type: detailResponse.data.type === 't' ? TvType.TVSERIES : TvType.MOVIE,
112
+ releaseDate: detailResponse.data.year,
113
+ seasons: detailResponse.data.season?.length ?? undefined,
114
+ };
115
+ } catch (error) {
116
+ // If we can't fetch details, just return the basic info
117
+ console.error(`Error fetching details for ${item.id}:`, error);
118
+ return {
119
+ id: item.id,
120
+ title: item.t,
121
+ image: `https://imgcdn.media/poster/v/${item.id}.jpg`,
122
+ };
123
+ }
124
+ })
125
+ );
126
+
127
+ searchResult.results = detailedResults;
128
+
129
+ return searchResult;
130
+ } catch (err) {
131
+ throw new Error((err as Error).message);
132
+ }
133
+ };
134
+
135
+ private async fetchAllEpisodesForSeason(seasonId: string, seriesId: string): Promise<IMovieEpisode[]> {
136
+ let page = 1;
137
+ let episodes: IMovieEpisode[] = [];
138
+
139
+ while (true) {
140
+ const url = `https://netfree2.cc/mobile/episodes.php?s=${seasonId}&series=${seriesId}&page=${page}`;
141
+ const { data } = await this.client.get(url);
142
+
143
+ if (data.episodes?.length) {
144
+ episodes.push(
145
+ ...data.episodes.map((episode: IMovieEpisode) => ({
146
+ id: episode.id,
147
+ title: episode.t as string,
148
+ season: parseInt(String(episode.s).replace('S', '')),
149
+ number: parseInt(String(episode.ep).replace('E', '')),
150
+ image: `https://imgcdn.media/epimg/150/${episode.id}.jpg`,
151
+ }))
152
+ );
153
+ }
154
+
155
+ if (data.nextPageShow !== 1) break; // no more pages
156
+ page++;
157
+ }
158
+
159
+ return episodes;
160
+ }
161
+
162
+ private async fetchAllEpisodesOrdered(seasons: any[], seriesId: string) {
163
+ const allEpisodes: any[] = [];
164
+
165
+ for (const season of seasons.sort((a, b) => Number(a.s) - Number(b.s))) {
166
+ const seasonEpisodes = await this.fetchAllEpisodesForSeason(season.id, seriesId);
167
+ allEpisodes.push(...seasonEpisodes);
168
+ }
169
+
170
+ return allEpisodes;
171
+ }
172
+
173
+ /**
174
+ *
175
+ * @param mediaId media link or id
176
+ */
177
+ override fetchMediaInfo = async (mediaId: string): Promise<IMovieInfo> => {
178
+ const movieInfo: IMovieInfo = {
179
+ id: mediaId!,
180
+ title: '',
181
+ };
182
+ try {
183
+ const { data } = await this.client.get(
184
+ `https://netmirror.8man.me/api/net-proxy?isPrime=false&url=${this.baseUrl}/mobile/post.php?id=${mediaId}`,
185
+ {
186
+ headers: this.Headers(),
187
+ }
188
+ );
189
+
190
+ movieInfo.cover = `https://imgcdn.media/poster/h/${mediaId}.jpg`;
191
+ movieInfo.title = data.title;
192
+ movieInfo.image = `https://imgcdn.media/poster/v/${mediaId}.jpg`;
193
+ movieInfo.description = data.desc?.trim() ?? '';
194
+ movieInfo.type = data.type === 't' ? TvType.TVSERIES : TvType.MOVIE;
195
+ movieInfo.releaseDate = data.year;
196
+ movieInfo.genres = data.genre?.split(',').map((genre: string) => genre?.trim()) ?? [];
197
+ movieInfo.duration = data.runtime;
198
+ if (movieInfo.type === TvType.TVSERIES) {
199
+ movieInfo.episodes = await this.fetchAllEpisodesOrdered(data.season, mediaId);
200
+ } else {
201
+ movieInfo.episodes = [
202
+ {
203
+ id: mediaId,
204
+ title: data.title,
205
+ image: movieInfo.cover || movieInfo.image,
206
+ },
207
+ ];
208
+ }
209
+ return movieInfo;
210
+ } catch (err) {
211
+ throw new Error((err as Error).message);
212
+ }
213
+ };
214
+
215
+ /**
216
+ *
217
+ * @param episodeId episode id
218
+ * @param media media id
219
+ */
220
+ override fetchEpisodeSources = async (
221
+ episodeId: string,
222
+ mediaId?: string //just placeholder for compatibility with tmdb
223
+ ): Promise<ISource> => {
224
+ try {
225
+ if (!this.nfCookie) {
226
+ await this.initCookie();
227
+ }
228
+
229
+ await makeGetRequestWithWebView(
230
+ `https://netfree2.cc/mobile/playlist.php?id=${episodeId}&tm=${Math.round(new Date().getTime() / 1000)}`,
231
+ {
232
+ Cookie: this.nfCookie!,
233
+ }
234
+ );
235
+ const { data } = await this.client.get(
236
+ `https://netmirror.8man.me/api/net-proxy?isPrime=false&url=${this.baseUrl}/mobile/playlist.php?id=${episodeId}`,
237
+ {
238
+ headers: this.Headers(),
239
+ }
240
+ );
241
+ const sources: ISource = {
242
+ sources: [],
243
+ subtitles: [],
244
+ };
245
+ data[0].sources?.map((source: any) => {
246
+ sources.sources.push({
247
+ url: `${this.baseUrl}${source.file.replace(/%3A%3Asu/g, '%3A%3Ani').replace(/::su/g, '::ni')}`,
248
+ quality: source.label === 'Auto' ? source.label.toLowerCase() : source.file.match(/[?&]q=([^&]+)/)?.[1],
249
+ isM3U8: source.file.includes('.m3u8'),
250
+ });
251
+ });
252
+
253
+ data[0].tracks?.map((subtitle: any) => {
254
+ sources.subtitles = sources.subtitles || [];
255
+ sources.subtitles.push({
256
+ url: `https:${subtitle.file}`,
257
+ lang: subtitle.label,
258
+ });
259
+ });
260
+
261
+ return sources;
262
+ } catch (error) {
263
+ throw new Error((error as Error).message);
264
+ }
265
+ };
266
+
267
+ /**
268
+ * @deprecated method not implemented
269
+ * @param episodeId takes episode link or movie id
270
+ */
271
+ override fetchEpisodeServers = async (episodeId: string): Promise<IEpisodeServer[]> => {
272
+ throw new Error('Method not implemented.');
273
+ };
274
+ }
275
+
276
+ // (async () => {
277
+ // const movie = new NetflixMirror();
278
+ // const search = await movie.search('one');
279
+ // // const movieInfo = await movie.fetchMediaInfo(search.results[0]?.id);
280
+ // // const sources = await movie.fetchEpisodeSources(movieInfo.episodes![0]?.id);
281
+ // // const server = await movie.fetchEpisodeServers(search.results[0]?.id);
282
+ // // const recentTv = await movie.fetchPopular();
283
+ // // const genre = await movie.fetchByGenre('action');
284
+ // console.log(search);
285
+ // })();
286
+
287
+ export default NetflixMirror;
@@ -41,6 +41,7 @@ export const PROVIDERS_LIST = {
41
41
  new MOVIES.ViewAsian(),
42
42
  new MOVIES.SFlix(),
43
43
  new MOVIES.MultiMovies(),
44
+ new MOVIES.NetflixMirror(),
44
45
  ],
45
46
  NEWS: [new NEWS.ANN()],
46
47
  META: [new META.Anilist(), new META.TMDB(), new META.Myanimelist()],