react-native-consumet 1.2.1 → 1.2.3
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 +4 -4
- package/lib/commonjs/extractors/megaup.js +1 -1
- package/lib/commonjs/extractors/megaup.js.map +1 -1
- package/lib/commonjs/providers/anime/animekai/create-animekai.js +44 -27
- package/lib/commonjs/providers/anime/animekai/create-animekai.js.map +1 -1
- package/lib/commonjs/providers/anime/animepahe/create-animepahe.js +2 -2
- package/lib/commonjs/providers/anime/animepahe/create-animepahe.js.map +1 -1
- package/lib/commonjs/providers/meta/anilist.js +1 -1
- package/lib/commonjs/providers/meta/anilist.js.map +1 -1
- package/lib/commonjs/providers/meta/tmdb.js +1 -2
- package/lib/commonjs/providers/meta/tmdb.js.map +1 -1
- package/lib/commonjs/providers/movies/index.js +3 -1
- package/lib/commonjs/providers/movies/index.js.map +1 -1
- package/lib/commonjs/providers/movies/multimovies/create-multimovies.js +21 -21
- package/lib/commonjs/providers/movies/multimovies/create-multimovies.js.map +1 -1
- package/lib/commonjs/providers/movies/multistream/index.js +16 -16
- package/lib/commonjs/providers/movies/netflixmirror/create-netflixmirror.js +267 -0
- package/lib/commonjs/providers/movies/netflixmirror/create-netflixmirror.js.map +1 -0
- package/lib/commonjs/providers/movies/netflixmirror/netflixmirror.js +35 -0
- package/lib/commonjs/providers/movies/netflixmirror/netflixmirror.js.map +1 -0
- package/lib/commonjs/utils/utils.js +16 -9
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/module/extension-registry.json +4 -4
- package/lib/module/extractors/megaup.js +1 -1
- package/lib/module/extractors/megaup.js.map +1 -1
- package/lib/module/providers/anime/animekai/create-animekai.js +44 -27
- package/lib/module/providers/anime/animekai/create-animekai.js.map +1 -1
- package/lib/module/providers/anime/animepahe/create-animepahe.js +2 -2
- package/lib/module/providers/anime/animepahe/create-animepahe.js.map +1 -1
- package/lib/module/providers/meta/anilist.js +1 -1
- package/lib/module/providers/meta/anilist.js.map +1 -1
- package/lib/module/providers/meta/tmdb.js +1 -2
- package/lib/module/providers/meta/tmdb.js.map +1 -1
- package/lib/module/providers/movies/index.js +3 -1
- package/lib/module/providers/movies/index.js.map +1 -1
- package/lib/module/providers/movies/multimovies/create-multimovies.js +21 -21
- package/lib/module/providers/movies/multimovies/create-multimovies.js.map +1 -1
- package/lib/module/providers/movies/multistream/index.js +16 -16
- package/lib/module/providers/movies/netflixmirror/create-netflixmirror.js +263 -0
- package/lib/module/providers/movies/netflixmirror/create-netflixmirror.js.map +1 -0
- package/lib/module/providers/movies/netflixmirror/netflixmirror.js +32 -0
- package/lib/module/providers/movies/netflixmirror/netflixmirror.js.map +1 -0
- package/lib/module/utils/utils.js +16 -9
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animekai/create-animekai.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/meta/tmdb.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/movies/index.d.ts +3 -1
- package/lib/typescript/commonjs/src/providers/movies/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/movies/multimovies/create-multimovies.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/movies/netflixmirror/create-netflixmirror.d.ts +23 -0
- package/lib/typescript/commonjs/src/providers/movies/netflixmirror/create-netflixmirror.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/movies/netflixmirror/netflixmirror.d.ts +20 -0
- package/lib/typescript/commonjs/src/providers/movies/netflixmirror/netflixmirror.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/utils.d.ts +5 -0
- package/lib/typescript/commonjs/src/utils/utils.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/animekai/create-animekai.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/meta/tmdb.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/movies/index.d.ts +3 -1
- package/lib/typescript/module/src/providers/movies/index.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/movies/multimovies/create-multimovies.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/movies/netflixmirror/create-netflixmirror.d.ts +23 -0
- package/lib/typescript/module/src/providers/movies/netflixmirror/create-netflixmirror.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/movies/netflixmirror/netflixmirror.d.ts +20 -0
- package/lib/typescript/module/src/providers/movies/netflixmirror/netflixmirror.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/utils.d.ts +5 -0
- package/lib/typescript/module/src/utils/utils.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/extension-registry.json +4 -4
- package/src/extractors/megaup.ts +1 -1
- package/src/providers/anime/animekai/create-animekai.ts +45 -26
- package/src/providers/anime/animepahe/create-animepahe.ts +2 -2
- package/src/providers/meta/anilist.ts +1 -1
- package/src/providers/meta/tmdb.ts +1 -2
- package/src/providers/movies/index.ts +3 -1
- package/src/providers/movies/multimovies/create-multimovies.ts +28 -24
- package/src/providers/movies/multistream/index.ts +232 -232
- package/src/providers/movies/netflixmirror/create-netflixmirror.ts +344 -0
- package/src/providers/movies/netflixmirror/netflixmirror.ts +46 -0
- package/src/utils/utils.ts +48 -20
- package/lib/commonjs/providers/movies/netflixmirror.js +0 -245
- package/lib/commonjs/providers/movies/netflixmirror.js.map +0 -1
- package/lib/module/providers/movies/netflixmirror.js +0 -241
- package/lib/module/providers/movies/netflixmirror.js.map +0 -1
- package/lib/typescript/commonjs/src/providers/movies/netflixmirror.d.ts +0 -38
- package/lib/typescript/commonjs/src/providers/movies/netflixmirror.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/movies/netflixmirror.d.ts +0 -38
- package/lib/typescript/module/src/providers/movies/netflixmirror.d.ts.map +0 -1
- package/src/providers/movies/netflixmirror.ts +0 -288
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type IMovieInfo,
|
|
3
|
+
type IEpisodeServer,
|
|
4
|
+
type ISource,
|
|
5
|
+
type IMovieResult,
|
|
6
|
+
type ISearch,
|
|
7
|
+
type ProviderContext,
|
|
8
|
+
type ProviderConfig,
|
|
9
|
+
} from '../../../models';
|
|
10
|
+
|
|
11
|
+
const OTT_PLATFORMS = [
|
|
12
|
+
{ code: 'nf', label: 'Netflix' },
|
|
13
|
+
{ code: 'pv', label: 'Prime Video' },
|
|
14
|
+
{ code: 'dp', label: 'Disney+' },
|
|
15
|
+
{ code: 'lg', label: 'Lionsgate' },
|
|
16
|
+
] as const;
|
|
17
|
+
|
|
18
|
+
type OttCode = (typeof OTT_PLATFORMS)[number]['code'];
|
|
19
|
+
|
|
20
|
+
interface NetMirrorSearchResult {
|
|
21
|
+
head: string;
|
|
22
|
+
type: number;
|
|
23
|
+
searchResult: Array<{ id: string; t: string }>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface NetMirrorPostData {
|
|
27
|
+
status: string;
|
|
28
|
+
d_lang: string;
|
|
29
|
+
title: string;
|
|
30
|
+
year: string;
|
|
31
|
+
ua: string;
|
|
32
|
+
match: string;
|
|
33
|
+
runtime: string;
|
|
34
|
+
hdsd: string;
|
|
35
|
+
type: string;
|
|
36
|
+
genre: string;
|
|
37
|
+
m_desc: string;
|
|
38
|
+
desc: string;
|
|
39
|
+
season?: Array<{
|
|
40
|
+
s: string;
|
|
41
|
+
id: string;
|
|
42
|
+
ep: string;
|
|
43
|
+
sele: string;
|
|
44
|
+
}>;
|
|
45
|
+
episodes?: Array<{
|
|
46
|
+
complate: string;
|
|
47
|
+
id: string;
|
|
48
|
+
t: string;
|
|
49
|
+
s: string;
|
|
50
|
+
ep: string;
|
|
51
|
+
ep_desc: string;
|
|
52
|
+
time: string;
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface NetMirrorPlaylist {
|
|
57
|
+
title: string;
|
|
58
|
+
image: string;
|
|
59
|
+
sources: Array<{
|
|
60
|
+
file: string;
|
|
61
|
+
label: string;
|
|
62
|
+
type: string;
|
|
63
|
+
default?: string;
|
|
64
|
+
}>;
|
|
65
|
+
tracks: Array<{
|
|
66
|
+
kind: string;
|
|
67
|
+
file: string;
|
|
68
|
+
label: string;
|
|
69
|
+
language?: string;
|
|
70
|
+
}>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type NetflixMirrorProviderInstance = {
|
|
74
|
+
name: string;
|
|
75
|
+
logo: string;
|
|
76
|
+
baseUrl: string;
|
|
77
|
+
classPath: string;
|
|
78
|
+
supportedTypes: Set<any>;
|
|
79
|
+
isNSFW: boolean;
|
|
80
|
+
isWorking?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Searches Netflix, Prime Video, Disney+ and Lionsgate in parallel.
|
|
83
|
+
* Each result's `otherNames` array contains the platform label(s) it was found on.
|
|
84
|
+
* Results are deduplicated by id; if the same id appears on multiple platforms
|
|
85
|
+
* all platform labels are merged into `otherNames`.
|
|
86
|
+
*/
|
|
87
|
+
search: (query: string, page?: number) => Promise<ISearch<IMovieResult>>;
|
|
88
|
+
fetchMediaInfo: (mediaId: string) => Promise<IMovieInfo>;
|
|
89
|
+
fetchEpisodeServers: (episodeId: string, mediaId?: string) => Promise<IEpisodeServer[]>;
|
|
90
|
+
fetchEpisodeSources: (episodeId: string, mediaId?: string) => Promise<ISource>;
|
|
91
|
+
fetchHlsPlaylist: (episodeId: string) => Promise<string>;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export function createNetflixMirror(ctx: ProviderContext, customBaseURL?: string): NetflixMirrorProviderInstance {
|
|
95
|
+
const { enums, axios, createCustomBaseUrl, NativeConsumet } = ctx;
|
|
96
|
+
const { TvType: TvTypeEnum } = enums;
|
|
97
|
+
const { getDdosGuardCookiesWithWebView } = NativeConsumet;
|
|
98
|
+
const baseUrl = createCustomBaseUrl('https://net20.cc', customBaseURL);
|
|
99
|
+
|
|
100
|
+
const config: ProviderConfig = {
|
|
101
|
+
name: 'NetMirror',
|
|
102
|
+
languages: 'all',
|
|
103
|
+
classPath: 'MOVIES.NetMirror',
|
|
104
|
+
logo: 'https://net20.cc/img/nf2/icon_x192.png',
|
|
105
|
+
baseUrl,
|
|
106
|
+
isNSFW: false,
|
|
107
|
+
isWorking: true,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const supportedTypes = new Set([TvTypeEnum.MOVIE, TvTypeEnum.TVSERIES]);
|
|
111
|
+
|
|
112
|
+
const headers = {
|
|
113
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
114
|
+
'Referer': `${config.baseUrl}/home`,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const getCookies = async (ottCode: OttCode = 'nf'): Promise<string> => {
|
|
118
|
+
const res = await fetch(config.baseUrl + '/p.php', {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
121
|
+
body: 'init=1',
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const setCookie = res.headers.get('set-cookie');
|
|
125
|
+
if (!setCookie) throw new Error('No Set-Cookie header found');
|
|
126
|
+
|
|
127
|
+
// Define the hardcoded t_hash_t as requested
|
|
128
|
+
const t_hash_t = '988a734da1152ddea2c25c8904eede20%3A%3A0cb4f3935641c828678b8946867997e5%3A%3A1768993531%3A%3Ani';
|
|
129
|
+
|
|
130
|
+
// Extract t_hash from the p.php response
|
|
131
|
+
const tHashMatch = /t_hash=([^;]+)/.exec(setCookie);
|
|
132
|
+
const t_hash = tHashMatch ? tHashMatch[1] : '';
|
|
133
|
+
|
|
134
|
+
return `t_hash_t=${t_hash_t}; t_hash=${t_hash}; ott=${ottCode}`;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const search = async (query: string, page: number = 1): Promise<ISearch<IMovieResult>> => {
|
|
138
|
+
try {
|
|
139
|
+
const resultSets = await Promise.allSettled(
|
|
140
|
+
OTT_PLATFORMS.map(async ({ code, label }) => {
|
|
141
|
+
const { data } = await axios.get<NetMirrorSearchResult>(
|
|
142
|
+
`${config.baseUrl}/search.php?s=${encodeURIComponent(query)}&t=x`,
|
|
143
|
+
{ headers: { ...headers, Cookie: await getCookies(code) } }
|
|
144
|
+
);
|
|
145
|
+
if (!data.searchResult || !Array.isArray(data.searchResult)) return [];
|
|
146
|
+
return data.searchResult.map((item) => ({ id: item.id, title: item.t, label }));
|
|
147
|
+
})
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
// Merge results: deduplicate by id, collect all platform labels
|
|
151
|
+
const map = new Map<string, IMovieResult>();
|
|
152
|
+
for (const settled of resultSets) {
|
|
153
|
+
if (settled.status !== 'fulfilled') continue;
|
|
154
|
+
for (const item of settled.value) {
|
|
155
|
+
if (map.has(item.id)) {
|
|
156
|
+
(map.get(item.id)!.otherNames as string[]).push(item.label);
|
|
157
|
+
} else {
|
|
158
|
+
map.set(item.id, {
|
|
159
|
+
id: item.id,
|
|
160
|
+
title: item.title,
|
|
161
|
+
image: `https://imgcdn.kim/poster/342/${item.id}.jpg`,
|
|
162
|
+
type: TvTypeEnum.MOVIE,
|
|
163
|
+
otherNames: [item.label],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return { currentPage: page, hasNextPage: false, results: [...map.values()] };
|
|
170
|
+
} catch (err) {
|
|
171
|
+
throw new Error(`NetMirror search failed: ${(err as Error).message}`);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const fetchPostData = async (id: string): Promise<NetMirrorPostData> => {
|
|
176
|
+
try {
|
|
177
|
+
const { data } = await axios.get<NetMirrorPostData>(`${config.baseUrl}/post.php?id=${id}&t=x`, {
|
|
178
|
+
headers: {
|
|
179
|
+
...headers,
|
|
180
|
+
Cookie: await getCookies(),
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
return data;
|
|
184
|
+
} catch (err) {
|
|
185
|
+
throw new Error(`NetMirror fetchPostData failed: ${(err as Error).message}`);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const fetchMediaInfo = async (mediaId: string): Promise<IMovieInfo> => {
|
|
190
|
+
try {
|
|
191
|
+
const postData = await fetchPostData(mediaId);
|
|
192
|
+
const isTvShow = postData.type === 't';
|
|
193
|
+
|
|
194
|
+
const movieInfo: IMovieInfo = {
|
|
195
|
+
id: mediaId,
|
|
196
|
+
title: postData.title || '',
|
|
197
|
+
type: isTvShow ? TvTypeEnum.TVSERIES : TvTypeEnum.MOVIE,
|
|
198
|
+
image: `https://imgcdn.kim/poster/780/${mediaId}.jpg`,
|
|
199
|
+
cover: `https://imgcdn.kim/poster/1920/${mediaId}.jpg`,
|
|
200
|
+
genres: postData.genre?.split(',').map((g) => g.trim()) || [],
|
|
201
|
+
duration: postData.runtime,
|
|
202
|
+
description: postData.desc || postData.m_desc || '',
|
|
203
|
+
// rating is a string in the response, but IMovieInfo expects a number.
|
|
204
|
+
// We'll leave it undefined since we can't convert it reliably.
|
|
205
|
+
rating: undefined,
|
|
206
|
+
year: postData.year || undefined,
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// Handle episodes for TV shows
|
|
210
|
+
if (isTvShow) {
|
|
211
|
+
// Check if episodes array exists and has valid entries
|
|
212
|
+
if (postData.episodes && postData.episodes.length > 0 && postData.episodes[0] !== null) {
|
|
213
|
+
movieInfo.episodes = postData.episodes.map((ep) => ({
|
|
214
|
+
id: ep.id,
|
|
215
|
+
title: ep.t,
|
|
216
|
+
number: parseInt(ep.ep),
|
|
217
|
+
season: parseInt(ep.s.replace('S', '')),
|
|
218
|
+
description: ep.ep_desc,
|
|
219
|
+
duration: ep.time,
|
|
220
|
+
}));
|
|
221
|
+
} else if (postData.season && postData.season.length > 0) {
|
|
222
|
+
// Fallback: Create episodes based on seasons if episodes array is empty
|
|
223
|
+
movieInfo.episodes = postData.season.flatMap((season) => {
|
|
224
|
+
const episodes = [];
|
|
225
|
+
for (let i = 1; i <= parseInt(season.ep); i++) {
|
|
226
|
+
episodes.push({
|
|
227
|
+
id: season.id,
|
|
228
|
+
title: `Season ${season.s} Episode ${i}`,
|
|
229
|
+
number: i,
|
|
230
|
+
season: parseInt(season.s),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return episodes;
|
|
234
|
+
});
|
|
235
|
+
} else {
|
|
236
|
+
// Fallback: Single episode for the entire show
|
|
237
|
+
movieInfo.episodes = [
|
|
238
|
+
{
|
|
239
|
+
id: mediaId,
|
|
240
|
+
title: 'Full Content',
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
// Handle movies
|
|
246
|
+
movieInfo.episodes = [
|
|
247
|
+
{
|
|
248
|
+
id: mediaId,
|
|
249
|
+
title: postData.title || 'Full Movie',
|
|
250
|
+
},
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return movieInfo;
|
|
255
|
+
} catch (err) {
|
|
256
|
+
throw new Error(`NetMirror fetchMediaInfo failed: ${(err as Error).message}`);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const fetchEpisodeServers = async (episodeId: string, mediaId?: string): Promise<IEpisodeServer[]> => {
|
|
261
|
+
return [
|
|
262
|
+
{
|
|
263
|
+
name: 'NetMirror',
|
|
264
|
+
url: `${config.baseUrl}/playlist.php?id=${episodeId}`,
|
|
265
|
+
},
|
|
266
|
+
];
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const fetchEpisodeSources = async (episodeId: string, mediaId?: string): Promise<ISource> => {
|
|
270
|
+
try {
|
|
271
|
+
const { data } = await axios.get<NetMirrorPlaylist[]>(
|
|
272
|
+
`${config.baseUrl}/playlist.php?id=${episodeId}&t=Video&tm=${Date.now()}`,
|
|
273
|
+
{
|
|
274
|
+
headers: {
|
|
275
|
+
...headers,
|
|
276
|
+
Cookie: await getCookies(),
|
|
277
|
+
},
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
if (!data || !Array.isArray(data) || data.length === 0) {
|
|
282
|
+
throw new Error('No playlist data received');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const playlist = data[0];
|
|
286
|
+
|
|
287
|
+
if (!playlist?.sources || !Array.isArray(playlist.sources)) {
|
|
288
|
+
throw new Error('No sources in playlist');
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const sources = playlist.sources.map((s) => {
|
|
292
|
+
let quality = '480p';
|
|
293
|
+
if (s.label === 'Full HD') quality = '1080p';
|
|
294
|
+
else if (s.label === 'Mid HD') quality = '720p';
|
|
295
|
+
else if (s.label === 'Low HD') quality = '480p';
|
|
296
|
+
|
|
297
|
+
return {
|
|
298
|
+
url: `${config.baseUrl}${s.file}`,
|
|
299
|
+
quality,
|
|
300
|
+
isM3U8: true,
|
|
301
|
+
};
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
const subtitles = playlist.tracks
|
|
305
|
+
?.filter((t) => t.kind === 'captions')
|
|
306
|
+
.map((t) => ({
|
|
307
|
+
url: t.file.startsWith('//') ? `https:${t.file}` : t.file,
|
|
308
|
+
lang: t.label || t.language || 'Unknown',
|
|
309
|
+
}));
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
headers: { Referer: `${config.baseUrl}/` },
|
|
313
|
+
sources,
|
|
314
|
+
subtitles,
|
|
315
|
+
};
|
|
316
|
+
} catch (err) {
|
|
317
|
+
throw new Error(`NetMirror fetchEpisodeSources failed: ${(err as Error).message}`);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
const fetchHlsPlaylist = async (episodeId: string): Promise<string> => {
|
|
322
|
+
try {
|
|
323
|
+
const { data } = await axios.get<string>(`${config.baseUrl}/hls/${episodeId}`, {
|
|
324
|
+
headers: {
|
|
325
|
+
...headers,
|
|
326
|
+
Cookie: await getCookies(),
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
return data;
|
|
330
|
+
} catch (err) {
|
|
331
|
+
throw new Error(`NetMirror fetchHlsPlaylist failed: ${(err as Error).message}`);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
return {
|
|
336
|
+
...config,
|
|
337
|
+
supportedTypes,
|
|
338
|
+
search,
|
|
339
|
+
fetchMediaInfo,
|
|
340
|
+
fetchEpisodeServers,
|
|
341
|
+
fetchEpisodeSources,
|
|
342
|
+
fetchHlsPlaylist,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { MovieParser } from '../../../models';
|
|
2
|
+
import { createProviderContext } from '../../../utils';
|
|
3
|
+
import { createNetflixMirror, type NetflixMirrorProviderInstance } from './create-netflixmirror';
|
|
4
|
+
|
|
5
|
+
// Backward compatibility wrapper class
|
|
6
|
+
class NetflixMirror extends MovieParser {
|
|
7
|
+
private instance: NetflixMirrorProviderInstance;
|
|
8
|
+
override logo: string;
|
|
9
|
+
override name: string;
|
|
10
|
+
override baseUrl: string;
|
|
11
|
+
override classPath: string;
|
|
12
|
+
override supportedTypes: Set<any>;
|
|
13
|
+
override isNSFW: boolean;
|
|
14
|
+
override isWorking: boolean;
|
|
15
|
+
|
|
16
|
+
constructor(customBaseURL?: string) {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
// Use the context factory to create a complete context with all defaults
|
|
20
|
+
const defaultContext = createProviderContext();
|
|
21
|
+
|
|
22
|
+
this.instance = createNetflixMirror(defaultContext, customBaseURL);
|
|
23
|
+
this.logo = this.instance.logo;
|
|
24
|
+
this.name = this.instance.name;
|
|
25
|
+
this.baseUrl = this.instance.baseUrl;
|
|
26
|
+
this.classPath = this.instance.classPath;
|
|
27
|
+
this.supportedTypes = this.instance.supportedTypes;
|
|
28
|
+
this.isNSFW = this.instance.isNSFW;
|
|
29
|
+
this.isWorking = this.instance.isWorking ?? true;
|
|
30
|
+
|
|
31
|
+
// Bind all methods to preserve proper typing
|
|
32
|
+
this.search = this.instance.search;
|
|
33
|
+
this.fetchMediaInfo = this.instance.fetchMediaInfo;
|
|
34
|
+
this.fetchEpisodeSources = this.instance.fetchEpisodeSources;
|
|
35
|
+
this.fetchEpisodeServers = this.instance.fetchEpisodeServers;
|
|
36
|
+
this.fetchHlsPlaylist = this.instance.fetchHlsPlaylist;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override search!: NetflixMirrorProviderInstance['search'];
|
|
40
|
+
override fetchMediaInfo!: NetflixMirrorProviderInstance['fetchMediaInfo'];
|
|
41
|
+
override fetchEpisodeSources!: NetflixMirrorProviderInstance['fetchEpisodeSources'];
|
|
42
|
+
override fetchEpisodeServers!: NetflixMirrorProviderInstance['fetchEpisodeServers'];
|
|
43
|
+
fetchHlsPlaylist!: NetflixMirrorProviderInstance['fetchHlsPlaylist'];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default NetflixMirror;
|
package/src/utils/utils.ts
CHANGED
|
@@ -3,6 +3,16 @@ import { compareTwoStrings } from 'string-similarity';
|
|
|
3
3
|
import { load } from 'cheerio';
|
|
4
4
|
// import * as blurhash from 'blurhash';
|
|
5
5
|
|
|
6
|
+
// Polyfill declaration for String.replaceAll (ES2021) when targeting < ES2021
|
|
7
|
+
declare global {
|
|
8
|
+
interface String {
|
|
9
|
+
replaceAll(
|
|
10
|
+
searchValue: string | RegExp,
|
|
11
|
+
replaceValue: string | ((match: string, ...args: any[]) => string)
|
|
12
|
+
): string;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
// Re-export constants from constants.ts to maintain backward compatibility
|
|
7
17
|
export { USER_AGENT, days, ANIFY_URL } from './constants';
|
|
8
18
|
import { days } from './constants';
|
|
@@ -182,22 +192,40 @@ export function findSimilarTitles(inputTitle: string, titles: any[]): any[] {
|
|
|
182
192
|
const results: (any & { similarity: number })[] = [];
|
|
183
193
|
|
|
184
194
|
titles?.forEach((titleObj: any) => {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
.trim() || ''
|
|
195
|
+
const input = cleanTitle(inputTitle?.toLowerCase() || '');
|
|
196
|
+
|
|
197
|
+
const candidateTitles: string[] = [titleObj?.title, titleObj?.japaneseTitle].filter(
|
|
198
|
+
(t): t is string => typeof t === 'string' && t.trim().length > 0
|
|
190
199
|
);
|
|
191
200
|
|
|
192
|
-
|
|
193
|
-
|
|
201
|
+
const bestSimilarity = candidateTitles
|
|
202
|
+
.map((candidate) =>
|
|
203
|
+
compareTwoStrings(
|
|
204
|
+
input,
|
|
205
|
+
cleanTitle(
|
|
206
|
+
candidate
|
|
207
|
+
?.toLowerCase()
|
|
208
|
+
?.replace(/\([^\)]*\)/g, '')
|
|
209
|
+
.trim() || ''
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
)
|
|
213
|
+
.reduce((max, val) => (val > max ? val : max), 0);
|
|
214
|
+
|
|
215
|
+
const similarity = bestSimilarity;
|
|
194
216
|
|
|
195
217
|
if (similarity > 0.6) {
|
|
196
218
|
results.push({ ...titleObj, similarity });
|
|
197
219
|
}
|
|
198
220
|
});
|
|
199
221
|
|
|
200
|
-
const
|
|
222
|
+
const getSubCount = (result: any): number => {
|
|
223
|
+
if (typeof result?.episodes?.sub === 'number') return result.episodes.sub;
|
|
224
|
+
if (typeof result?.sub === 'number') return result.sub;
|
|
225
|
+
return 0;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const isSubAvailable = results.some((result) => getSubCount(result) > 0);
|
|
201
229
|
|
|
202
230
|
// If episodes.sub is available, sort the results
|
|
203
231
|
if (isSubAvailable) {
|
|
@@ -207,7 +235,7 @@ export function findSimilarTitles(inputTitle: string, titles: any[]): any[] {
|
|
|
207
235
|
return b.similarity - a.similarity;
|
|
208
236
|
}
|
|
209
237
|
// If similarity is the same, sort by episodes.sub in descending order
|
|
210
|
-
return (b
|
|
238
|
+
return getSubCount(b) - getSubCount(a);
|
|
211
239
|
});
|
|
212
240
|
}
|
|
213
241
|
|
|
@@ -251,13 +279,13 @@ export function cleanTitle(title: string | undefined | null): string {
|
|
|
251
279
|
return transformSpecificVariations(
|
|
252
280
|
removeSpecialChars(
|
|
253
281
|
title
|
|
254
|
-
.
|
|
255
|
-
.
|
|
256
|
-
.
|
|
257
|
-
.
|
|
258
|
-
.
|
|
259
|
-
.
|
|
260
|
-
.
|
|
282
|
+
.replaceAll(/[^A-Za-z0-9!@#$%^&*() ]/gim, ' ')
|
|
283
|
+
.replaceAll(/(th|rd|nd|st) (Season|season)/gim, '')
|
|
284
|
+
.replaceAll(/\([^\(]*\)$/gim, '')
|
|
285
|
+
.replaceAll('season', '')
|
|
286
|
+
.replaceAll(/\b(IX|IV|V?I{0,3})\b/gi, (match) => romanToArabic(match).toString())
|
|
287
|
+
.replaceAll(' ', ' ')
|
|
288
|
+
.replaceAll('"', '')
|
|
261
289
|
.trimEnd()
|
|
262
290
|
)
|
|
263
291
|
);
|
|
@@ -267,15 +295,15 @@ export function removeSpecialChars(title: string | undefined | null): string {
|
|
|
267
295
|
if (!title) return '';
|
|
268
296
|
|
|
269
297
|
return title
|
|
270
|
-
.
|
|
271
|
-
.
|
|
272
|
-
.
|
|
298
|
+
.replaceAll(/[^A-Za-z0-9!@#$%^&*()\-= ]/gim, ' ')
|
|
299
|
+
.replaceAll(/[^A-Za-z0-9\-= ]/gim, '')
|
|
300
|
+
.replaceAll(' ', ' ');
|
|
273
301
|
}
|
|
274
302
|
|
|
275
303
|
export function transformSpecificVariations(title: string | undefined | null): string {
|
|
276
304
|
if (!title) return '';
|
|
277
305
|
|
|
278
|
-
return title.
|
|
306
|
+
return title.replaceAll('yuu', 'yu').replaceAll(' ou', ' oh');
|
|
279
307
|
}
|
|
280
308
|
|
|
281
309
|
export function sanitizeTitle(title: string): string {
|