react-native-consumet 1.2.1 → 1.2.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.
- package/lib/commonjs/providers/meta/tmdb.js +1 -2
- package/lib/commonjs/providers/meta/tmdb.js.map +1 -1
- package/lib/commonjs/providers/movies/multistream/index.js +16 -16
- package/lib/commonjs/providers/movies/netflixmirror.js +14 -14
- package/lib/module/providers/meta/tmdb.js +1 -2
- package/lib/module/providers/meta/tmdb.js.map +1 -1
- package/lib/module/providers/movies/multistream/index.js +16 -16
- package/lib/module/providers/movies/netflixmirror.js +14 -14
- package/lib/typescript/commonjs/src/providers/meta/tmdb.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/meta/tmdb.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/providers/meta/tmdb.ts +1 -2
- package/src/providers/movies/multimovies/create-multimovies.ts +520 -520
- package/src/providers/movies/multistream/index.ts +232 -232
- package/src/providers/movies/netflixmirror.ts +288 -288
|
@@ -1,520 +1,520 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IMovieInfo,
|
|
3
|
-
type IEpisodeServer,
|
|
4
|
-
type StreamingServers,
|
|
5
|
-
type ISource,
|
|
6
|
-
type IMovieResult,
|
|
7
|
-
type ISearch,
|
|
8
|
-
type ProviderContext,
|
|
9
|
-
type ProviderConfig,
|
|
10
|
-
} from '../../../models';
|
|
11
|
-
|
|
12
|
-
export function createMultiMovies(ctx: ProviderContext, customBaseURL?: string) {
|
|
13
|
-
const { load, extractors, enums, axios, createCustomBaseUrl, PolyURL, USER_AGENT, NativeConsumet } = ctx;
|
|
14
|
-
const { StreamWish, VidHide } = extractors;
|
|
15
|
-
const { StreamingServers: StreamingServersEnum, TvType: TvTypeEnum } = enums;
|
|
16
|
-
const { makePostRequest } = NativeConsumet;
|
|
17
|
-
|
|
18
|
-
const baseUrl = createCustomBaseUrl('https://multimovies.center', customBaseURL);
|
|
19
|
-
|
|
20
|
-
const config: ProviderConfig = {
|
|
21
|
-
name: 'MultiMovies',
|
|
22
|
-
languages: 'all',
|
|
23
|
-
classPath: 'MOVIES.MultiMovies',
|
|
24
|
-
logo: `${baseUrl}/wp-content/uploads/2024/01/cropped-CompressJPEG.online_512x512_image.png`,
|
|
25
|
-
baseUrl,
|
|
26
|
-
isNSFW: false,
|
|
27
|
-
isWorking: true,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const supportedTypes = new Set([TvTypeEnum.MOVIE, TvTypeEnum.TVSERIES]);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Search for movies/TV shows
|
|
34
|
-
* @param query search query string
|
|
35
|
-
* @param page page number (default 1) (optional)
|
|
36
|
-
*/
|
|
37
|
-
const search = async (query: string, page: number = 1): Promise<ISearch<IMovieResult>> => {
|
|
38
|
-
const searchResult: ISearch<IMovieResult> = {
|
|
39
|
-
currentPage: page,
|
|
40
|
-
hasNextPage: false,
|
|
41
|
-
results: [],
|
|
42
|
-
};
|
|
43
|
-
try {
|
|
44
|
-
let url;
|
|
45
|
-
if (page === 1) {
|
|
46
|
-
url = `${config.baseUrl}/?s=${query.replace(/[\W_]+/g, '+')}`;
|
|
47
|
-
} else {
|
|
48
|
-
url = `${config.baseUrl}/page/${page}/?s=${query.replace(/[\W_]+/g, '+')}`;
|
|
49
|
-
}
|
|
50
|
-
const { data } = await axios.get(url);
|
|
51
|
-
const $ = load(data);
|
|
52
|
-
|
|
53
|
-
const navSelector = 'div.pagination';
|
|
54
|
-
searchResult.hasNextPage = $(navSelector).find('#nextpagination').length > 0;
|
|
55
|
-
const articles = $('.search-page .result-item article').toArray();
|
|
56
|
-
|
|
57
|
-
await Promise.all(
|
|
58
|
-
articles.map(async (el) => {
|
|
59
|
-
const seasonSet = new Set<number>();
|
|
60
|
-
|
|
61
|
-
const href =
|
|
62
|
-
$(el)
|
|
63
|
-
.find('.thumbnail a')
|
|
64
|
-
.attr('href')
|
|
65
|
-
?.replace(/^https?:\/\/[^/]+\//, '')
|
|
66
|
-
.replace(/^\/|\/$/g, '') ?? '';
|
|
67
|
-
|
|
68
|
-
const episodesInfo = await fetchMediaInfo(href);
|
|
69
|
-
const episodes = episodesInfo?.episodes || [];
|
|
70
|
-
|
|
71
|
-
for (const episode of episodes) {
|
|
72
|
-
if (episode.season != null) {
|
|
73
|
-
seasonSet.add(episode.season);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
searchResult.results.push({
|
|
77
|
-
id: href,
|
|
78
|
-
title: $(el).find('.details .title a').text().trim(),
|
|
79
|
-
url: $(el).find('.thumbnail a').attr('href') ?? '',
|
|
80
|
-
image: $(el).find('.thumbnail img').attr('src') ?? '',
|
|
81
|
-
rating: parseFloat($(el).find('.meta .rating').text().replace('IMDb ', '')) || 0,
|
|
82
|
-
releaseDate: $(el).find('.meta .year').text().trim(),
|
|
83
|
-
seasons: seasonSet.size,
|
|
84
|
-
description: $(el).find('.contenido p').text().trim(),
|
|
85
|
-
type: $(el).find('.thumbnail a').attr('href')?.includes('/movies/')
|
|
86
|
-
? TvTypeEnum.MOVIE
|
|
87
|
-
: TvTypeEnum.TVSERIES,
|
|
88
|
-
});
|
|
89
|
-
})
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
return searchResult;
|
|
93
|
-
} catch (err) {
|
|
94
|
-
throw new Error((err as Error).message);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Fetch media information
|
|
100
|
-
* @param mediaId media link or id
|
|
101
|
-
*/
|
|
102
|
-
const fetchMediaInfo = async (mediaId: string): Promise<IMovieInfo> => {
|
|
103
|
-
if (!mediaId.startsWith(config.baseUrl)) {
|
|
104
|
-
mediaId = `${config.baseUrl}/${mediaId}`;
|
|
105
|
-
}
|
|
106
|
-
const movieInfo: IMovieInfo = {
|
|
107
|
-
id: mediaId.replace(/^https?:\/\/[^/]+\//, '').replace(/^\/|\/$/g, '')!,
|
|
108
|
-
title: '',
|
|
109
|
-
url: mediaId,
|
|
110
|
-
};
|
|
111
|
-
try {
|
|
112
|
-
const { data } = await axios.get(mediaId);
|
|
113
|
-
const $ = load(data);
|
|
114
|
-
const recommendationsArray: IMovieResult[] = [];
|
|
115
|
-
|
|
116
|
-
$('div#single_relacionados article').each((i, el) => {
|
|
117
|
-
recommendationsArray.push({
|
|
118
|
-
id: $(el)
|
|
119
|
-
.find('a')
|
|
120
|
-
.attr('href')
|
|
121
|
-
?.replace(/^https?:\/\/[^/]+\//, '')
|
|
122
|
-
.replace(/^\/|\/$/g, '')!,
|
|
123
|
-
title: $(el).find('a img').attr('alt')!,
|
|
124
|
-
image: $(el).find('a img').attr('data-src') ?? $(el).find('a img').attr('src'),
|
|
125
|
-
type: $(el).find('.thumbnail a').attr('href')?.includes('/movies/')
|
|
126
|
-
? TvTypeEnum.TVSERIES
|
|
127
|
-
: (TvTypeEnum.MOVIE ?? null),
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
movieInfo.cover = $('div#info .galeria').first().find('.g-item a').attr('href')?.trim() ?? '';
|
|
131
|
-
movieInfo.title = $('.sheader > .data > h1').text();
|
|
132
|
-
movieInfo.image = $('.sheader > .poster > img').attr('src') ?? $('.sheader > .poster > img').attr('data-src');
|
|
133
|
-
movieInfo.description = $('div#info div[itemprop="description"] p').text();
|
|
134
|
-
movieInfo.type = movieInfo.id.split('/')[0] === 'tvshows' ? TvTypeEnum.TVSERIES : TvTypeEnum.MOVIE;
|
|
135
|
-
movieInfo.releaseDate = $('.sheader > .data > .extra > span.date').text().trim();
|
|
136
|
-
movieInfo.trailer = {
|
|
137
|
-
id:
|
|
138
|
-
$('div#trailer .embed iframe').attr('data-litespeed-src')?.split('embed/')[1]?.split('?')[0] ??
|
|
139
|
-
$('div#trailer .embed iframe').attr('src')?.split('embed/')[1]?.split('?')[0]!,
|
|
140
|
-
url: $('div#trailer .embed iframe').attr('data-litespeed-src') ?? $('div#trailer .embed iframe').attr('src'),
|
|
141
|
-
};
|
|
142
|
-
movieInfo.genres = $('.sgeneros a')
|
|
143
|
-
.map((i, el) => $(el).text())
|
|
144
|
-
.get()
|
|
145
|
-
.map((v) => v.trim());
|
|
146
|
-
movieInfo.characters = [];
|
|
147
|
-
$('div#cast .persons .person').each((i, el) => {
|
|
148
|
-
const url = $(el).find('.img > a').attr('href');
|
|
149
|
-
const image = $(el).find('.img > a > img').attr('data-src') ?? $(el).find('.img > a > img').attr('src');
|
|
150
|
-
const name = $(el).find('.data > .name > a').text();
|
|
151
|
-
const character = $(el).find('.data > .caracter').text();
|
|
152
|
-
|
|
153
|
-
(movieInfo.characters as any[]).push({
|
|
154
|
-
url,
|
|
155
|
-
image,
|
|
156
|
-
name,
|
|
157
|
-
character,
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
movieInfo.country = $('.sheader > .data > .extra > span.country').text();
|
|
161
|
-
movieInfo.duration = $('.sheader > .data > .extra > span.runtime').text();
|
|
162
|
-
movieInfo.rating = parseFloat($('.starstruck-rating span.dt_rating_vgs[itemprop="ratingValue"]').text());
|
|
163
|
-
movieInfo.recommendations = recommendationsArray as any;
|
|
164
|
-
|
|
165
|
-
if (movieInfo.type === TvTypeEnum.TVSERIES) {
|
|
166
|
-
movieInfo.episodes = [];
|
|
167
|
-
$('#seasons .se-c').each((i, el) => {
|
|
168
|
-
const seasonNumber = parseInt($(el).find('.se-t').text().trim());
|
|
169
|
-
$(el)
|
|
170
|
-
.find('.episodios li')
|
|
171
|
-
.each((j, ep) => {
|
|
172
|
-
const episode = {
|
|
173
|
-
id: $(ep)
|
|
174
|
-
.find('.episodiotitle a')
|
|
175
|
-
.attr('href')
|
|
176
|
-
?.replace(/^https?:\/\/[^/]+\//, '')
|
|
177
|
-
.replace(/^\/|\/$/g, '')!,
|
|
178
|
-
season: seasonNumber,
|
|
179
|
-
number: parseInt($(ep).find('.numerando').text().trim().split('-')[1]!),
|
|
180
|
-
title: $(ep).find('.episodiotitle a').text().trim(),
|
|
181
|
-
url: $(ep).find('.episodiotitle a').attr('href')?.trim() ?? '',
|
|
182
|
-
releaseDate: String(new Date($(ep).find('.episodiotitle .date').text().trim()).getFullYear()),
|
|
183
|
-
image:
|
|
184
|
-
$(ep).find('.imagen img').attr('data-src')?.trim() ?? $(ep).find('.imagen img').attr('src')?.trim(),
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
movieInfo.episodes?.push(episode);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
} else {
|
|
191
|
-
movieInfo.episodes = [
|
|
192
|
-
{
|
|
193
|
-
id: movieInfo.id,
|
|
194
|
-
title: movieInfo.title,
|
|
195
|
-
url: movieInfo.url,
|
|
196
|
-
image: movieInfo.cover || movieInfo.image,
|
|
197
|
-
},
|
|
198
|
-
];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return movieInfo;
|
|
202
|
-
} catch (err) {
|
|
203
|
-
throw new Error((err as Error).message);
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Fetch episode sources
|
|
209
|
-
* @param episodeId episode id
|
|
210
|
-
* @param mediaId media id
|
|
211
|
-
* @param server server type (default `StreamWish`) (optional)
|
|
212
|
-
*/
|
|
213
|
-
const fetchEpisodeSources = async (
|
|
214
|
-
episodeId: string,
|
|
215
|
-
mediaId?: string,
|
|
216
|
-
server: StreamingServers = StreamingServersEnum.StreamWish,
|
|
217
|
-
fileId?: string
|
|
218
|
-
): Promise<ISource> => {
|
|
219
|
-
if (episodeId.startsWith('http')) {
|
|
220
|
-
const serverUrl = new PolyURL(episodeId);
|
|
221
|
-
const referer = serverUrl.origin;
|
|
222
|
-
const downloadUrl = fileId ? `${serverUrl.href.toString().replace('/e/', '/f/')}/${fileId}` : '';
|
|
223
|
-
|
|
224
|
-
switch (server) {
|
|
225
|
-
case StreamingServersEnum.StreamWish:
|
|
226
|
-
return {
|
|
227
|
-
headers: { Referer: referer },
|
|
228
|
-
...(await StreamWish().extract(serverUrl, referer)),
|
|
229
|
-
download: downloadUrl,
|
|
230
|
-
};
|
|
231
|
-
case StreamingServersEnum.VidHide:
|
|
232
|
-
return {
|
|
233
|
-
headers: { Referer: referer },
|
|
234
|
-
...(await VidHide().extract(serverUrl)),
|
|
235
|
-
download: fileId ? `https://gdmirrorbot.nl/file/${fileId}` : '',
|
|
236
|
-
};
|
|
237
|
-
default:
|
|
238
|
-
return {
|
|
239
|
-
headers: { Referer: referer },
|
|
240
|
-
...(await StreamWish().extract(serverUrl, referer)),
|
|
241
|
-
download: downloadUrl,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
try {
|
|
247
|
-
const servers = await fetchEpisodeServers(episodeId, episodeId);
|
|
248
|
-
const i = servers.findIndex((s) => s.name.toLowerCase() === server.toLowerCase());
|
|
249
|
-
if (i === -1) {
|
|
250
|
-
throw new Error(`Server ${server} not found`);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const serverUrl: URL = new URL(servers[i]!.url);
|
|
254
|
-
let fId = '';
|
|
255
|
-
|
|
256
|
-
if (!episodeId.startsWith('http')) {
|
|
257
|
-
const { fileId: id } = await getServer(`${config.baseUrl}/${episodeId}`);
|
|
258
|
-
fId = id ?? '';
|
|
259
|
-
}
|
|
260
|
-
// fileId to be used for download link
|
|
261
|
-
return await fetchEpisodeSources(serverUrl.href, mediaId, server, fId);
|
|
262
|
-
} catch (err) {
|
|
263
|
-
throw new Error((err as Error).message);
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Fetch episode servers
|
|
269
|
-
* @param episodeId takes episode link or movie id
|
|
270
|
-
* @param mediaId takes movie link or id (found on movie info object, this is just a placeholder for compatibility)
|
|
271
|
-
*/
|
|
272
|
-
const fetchEpisodeServers = async (episodeId: string, mediaId: string): Promise<IEpisodeServer[]> => {
|
|
273
|
-
if (!episodeId.startsWith(config.baseUrl)) {
|
|
274
|
-
episodeId = `${config.baseUrl}/${episodeId}`;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
try {
|
|
278
|
-
const { servers } = await getServer(episodeId);
|
|
279
|
-
return servers;
|
|
280
|
-
} catch (err) {
|
|
281
|
-
throw new Error((err as Error).message);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Fetch popular movies
|
|
287
|
-
* @param page page number (default 1)
|
|
288
|
-
*/
|
|
289
|
-
const fetchPopular = async (page: number = 1): Promise<ISearch<IMovieResult>> => {
|
|
290
|
-
const result: ISearch<IMovieResult> = {
|
|
291
|
-
currentPage: page,
|
|
292
|
-
hasNextPage: false,
|
|
293
|
-
results: [],
|
|
294
|
-
};
|
|
295
|
-
try {
|
|
296
|
-
const { data } = await axios.get(`${config.baseUrl}/trending/page/${page}/`);
|
|
297
|
-
const $ = load(data);
|
|
298
|
-
const navSelector = 'div.pagination';
|
|
299
|
-
|
|
300
|
-
result.hasNextPage = $(navSelector).find('#nextpagination').length > 0;
|
|
301
|
-
$('.items > article')
|
|
302
|
-
.each((i, el) => {
|
|
303
|
-
const resultItem: IMovieResult = {
|
|
304
|
-
id: $(el).attr('id')!,
|
|
305
|
-
title: $(el).find('div.data > h3').text() ?? '',
|
|
306
|
-
url: $(el).find('div.poster > a').attr('href'),
|
|
307
|
-
image: $(el).find('div.poster > img').attr('data-src') ?? '',
|
|
308
|
-
type: $(el).find('div.poster > a').attr('href')?.includes('/movies/')
|
|
309
|
-
? TvTypeEnum.MOVIE
|
|
310
|
-
: TvTypeEnum.TVSERIES,
|
|
311
|
-
rating: $(el).find('div.poster > div.rating').text() ?? '',
|
|
312
|
-
releaseDate: $(el).find('div.data > span').text() ?? '',
|
|
313
|
-
};
|
|
314
|
-
result.results.push(resultItem);
|
|
315
|
-
})
|
|
316
|
-
.get();
|
|
317
|
-
|
|
318
|
-
return result;
|
|
319
|
-
} catch (err) {
|
|
320
|
-
throw new Error((err as Error).message);
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Fetch by genre
|
|
326
|
-
* @param genre genre name
|
|
327
|
-
* @param page page number (default 1)
|
|
328
|
-
*/
|
|
329
|
-
const fetchByGenre = async (genre: string, page: number = 1): Promise<ISearch<IMovieResult>> => {
|
|
330
|
-
const result: ISearch<IMovieResult> = {
|
|
331
|
-
currentPage: page,
|
|
332
|
-
hasNextPage: false,
|
|
333
|
-
results: [],
|
|
334
|
-
};
|
|
335
|
-
try {
|
|
336
|
-
const { data } = await axios.get(`${config.baseUrl}/genre/${genre}/page/${page}`);
|
|
337
|
-
|
|
338
|
-
const $ = load(data);
|
|
339
|
-
const navSelector = 'div.pagination';
|
|
340
|
-
|
|
341
|
-
result.hasNextPage = $(navSelector).find('#nextpagination').length > 0;
|
|
342
|
-
$('.items > article')
|
|
343
|
-
.each((i, el) => {
|
|
344
|
-
const resultItem: IMovieResult = {
|
|
345
|
-
id: $(el).attr('id')!,
|
|
346
|
-
title: $(el).find('div.data > h3').text() ?? '',
|
|
347
|
-
url: $(el).find('div.poster > a').attr('href'),
|
|
348
|
-
image: $(el).find('div.poster > img').attr('data-src') ?? '',
|
|
349
|
-
type: $(el).find('div.poster > a').attr('href')?.includes('/movies/')
|
|
350
|
-
? TvTypeEnum.MOVIE
|
|
351
|
-
: TvTypeEnum.TVSERIES,
|
|
352
|
-
rating: $(el).find('div.poster > div.rating').text() ?? '',
|
|
353
|
-
releaseDate: $(el).find('div.data > span').text() ?? '',
|
|
354
|
-
};
|
|
355
|
-
result.results.push(resultItem);
|
|
356
|
-
})
|
|
357
|
-
.get();
|
|
358
|
-
|
|
359
|
-
return result;
|
|
360
|
-
} catch (err) {
|
|
361
|
-
throw new Error((err as Error).message);
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Get server information
|
|
367
|
-
* @param url episode url
|
|
368
|
-
*/
|
|
369
|
-
const getServer = async (url: string): Promise<{ servers: IEpisodeServer[]; fileId: string }> => {
|
|
370
|
-
try {
|
|
371
|
-
const { data } = await axios.get(url);
|
|
372
|
-
const $ = load(data);
|
|
373
|
-
// Extract player config
|
|
374
|
-
const playerConfig = {
|
|
375
|
-
postId: $('#player-option-1').attr('data-post'),
|
|
376
|
-
nume: $('#player-option-1').attr('data-nume'),
|
|
377
|
-
type: $('#player-option-1').attr('data-type'),
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
if (!playerConfig.postId || !playerConfig.nume || !playerConfig.type) {
|
|
381
|
-
throw new Error('Missing player configuration');
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const formData = new FormData();
|
|
385
|
-
formData.append('action', 'doo_player_ajax');
|
|
386
|
-
formData.append('post', playerConfig.postId);
|
|
387
|
-
formData.append('nume', playerConfig.nume);
|
|
388
|
-
formData.append('type', playerConfig.type);
|
|
389
|
-
|
|
390
|
-
const headers = {
|
|
391
|
-
'User-Agent': USER_AGENT,
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
// const { data: playerRes } = await axios.post(`${baseUrl}/wp-admin/admin-ajax.php`, formData, {
|
|
395
|
-
// headers,
|
|
396
|
-
// });
|
|
397
|
-
console.log(`${baseUrl}/wp-admin/admin-ajax.php`);
|
|
398
|
-
const res = await fetch(`${baseUrl}/wp-admin/admin-ajax.php`, {
|
|
399
|
-
method: 'POST',
|
|
400
|
-
headers: {
|
|
401
|
-
...headers,
|
|
402
|
-
//'Content-Type':'multipart/form-data',
|
|
403
|
-
},
|
|
404
|
-
body: formData as any,
|
|
405
|
-
});
|
|
406
|
-
const postTestOkHttp = await makePostRequest(
|
|
407
|
-
`${baseUrl}/wp-admin/admin-ajax.php`,
|
|
408
|
-
{
|
|
409
|
-
...headers,
|
|
410
|
-
//'Content-Type':'multipart/form-data',
|
|
411
|
-
},
|
|
412
|
-
formData as any
|
|
413
|
-
);
|
|
414
|
-
console.timeEnd('POST Request - OkHttp');
|
|
415
|
-
console.log('POST Response (OkHttp):', {
|
|
416
|
-
statusCode: postTestOkHttp.statusCode,
|
|
417
|
-
body: postTestOkHttp.body, // Full response body
|
|
418
|
-
headers: postTestOkHttp.headers,
|
|
419
|
-
});
|
|
420
|
-
const playerRes = await res.json();
|
|
421
|
-
console.log({ playerRes });
|
|
422
|
-
const iframeUrl = playerRes.embed_url?.match(/<iframe[^>]+src="([^"]+)"[^>]*>/i)?.[1] || playerRes.embed_url;
|
|
423
|
-
|
|
424
|
-
// Handle non-multimovies case
|
|
425
|
-
if (!iframeUrl.includes('multimovies')) {
|
|
426
|
-
if (iframeUrl.includes('dhcplay')) {
|
|
427
|
-
return {
|
|
428
|
-
servers: [{ name: 'StreamWish', url: iframeUrl }],
|
|
429
|
-
fileId: iframeUrl.split('/').pop() ?? '',
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
// let playerBaseUrl = iframeUrl.split('/').slice(0, 3).join('/');
|
|
433
|
-
// const redirectResponse = await axios.head(playerBaseUrl, {
|
|
434
|
-
// headers: headers,
|
|
435
|
-
// maxRedirects: 5,
|
|
436
|
-
// validateStatus: () => true,
|
|
437
|
-
// });
|
|
438
|
-
// const redirectResponse = await fetch(playerBaseUrl, {
|
|
439
|
-
// method: 'HEAD',
|
|
440
|
-
// headers: headers,
|
|
441
|
-
// redirect: 'follow',
|
|
442
|
-
// });
|
|
443
|
-
|
|
444
|
-
// const isRedirected = redirectResponse.request._redirectable._isRedirect ? redirectResponse : null;
|
|
445
|
-
// const finalResponse = true ? redirectResponse : null;
|
|
446
|
-
|
|
447
|
-
// // Update base URL if redirect occurred
|
|
448
|
-
// if (finalResponse) {
|
|
449
|
-
// playerBaseUrl = finalResponse?.url;
|
|
450
|
-
// }
|
|
451
|
-
|
|
452
|
-
const fileId = iframeUrl.split('/').pop();
|
|
453
|
-
if (!fileId) {
|
|
454
|
-
throw new Error('No player ID found');
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
const streamRequestData = new FormData();
|
|
458
|
-
streamRequestData.append('sid', fileId);
|
|
459
|
-
|
|
460
|
-
// const streamResponse = await axios.post(`https://pro.gtxgamer.site/embedhelper.php`, streamRequestData, {
|
|
461
|
-
// headers,
|
|
462
|
-
// });
|
|
463
|
-
const streamRes = await fetch(`https://pro.gtxgamer.site/embedhelper.php`, {
|
|
464
|
-
method: 'POST',
|
|
465
|
-
headers: {
|
|
466
|
-
...headers,
|
|
467
|
-
// 'Content-Type':'multipart/form-data',
|
|
468
|
-
},
|
|
469
|
-
body: streamRequestData as any,
|
|
470
|
-
});
|
|
471
|
-
const streamResponse = await streamRes.json();
|
|
472
|
-
if (!streamResponse) {
|
|
473
|
-
throw new Error('No stream data found');
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// Decode and parse mresult
|
|
477
|
-
const decodedMresult = JSON.parse(atob(streamResponse.mresult));
|
|
478
|
-
const mresultKeys = Object.keys(decodedMresult);
|
|
479
|
-
// Find common keys
|
|
480
|
-
const commonKeys = mresultKeys.filter((key) => streamResponse.siteUrls.hasOwnProperty(key));
|
|
481
|
-
|
|
482
|
-
// Convert to a Set (if needed)
|
|
483
|
-
const commonStreamSites = new Set(commonKeys);
|
|
484
|
-
const servers = Array.from(commonStreamSites).map((site) => {
|
|
485
|
-
return {
|
|
486
|
-
name:
|
|
487
|
-
streamResponse.siteFriendlyNames[site] === 'StreamHG'
|
|
488
|
-
? 'StreamWish'
|
|
489
|
-
: streamResponse.siteFriendlyNames[site] === 'EarnVids'
|
|
490
|
-
? 'VidHide'
|
|
491
|
-
: streamResponse.siteFriendlyNames[site],
|
|
492
|
-
url: streamResponse.siteUrls[site] + JSON.parse(atob(streamResponse.mresult))[site],
|
|
493
|
-
};
|
|
494
|
-
});
|
|
495
|
-
return { servers, fileId };
|
|
496
|
-
} else {
|
|
497
|
-
return {
|
|
498
|
-
servers: [{ name: 'StreamWish', url: iframeUrl }],
|
|
499
|
-
fileId: iframeUrl.split('/').pop() ?? '',
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
} catch (err) {
|
|
503
|
-
console.log(err);
|
|
504
|
-
throw new Error((err as Error).message);
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
return {
|
|
509
|
-
...config,
|
|
510
|
-
supportedTypes,
|
|
511
|
-
search,
|
|
512
|
-
fetchMediaInfo,
|
|
513
|
-
fetchEpisodeSources,
|
|
514
|
-
fetchEpisodeServers,
|
|
515
|
-
fetchPopular,
|
|
516
|
-
fetchByGenre,
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
export type MultiMoviesProviderInstance = ReturnType<typeof createMultiMovies>;
|
|
1
|
+
import {
|
|
2
|
+
type IMovieInfo,
|
|
3
|
+
type IEpisodeServer,
|
|
4
|
+
type StreamingServers,
|
|
5
|
+
type ISource,
|
|
6
|
+
type IMovieResult,
|
|
7
|
+
type ISearch,
|
|
8
|
+
type ProviderContext,
|
|
9
|
+
type ProviderConfig,
|
|
10
|
+
} from '../../../models';
|
|
11
|
+
|
|
12
|
+
export function createMultiMovies(ctx: ProviderContext, customBaseURL?: string) {
|
|
13
|
+
const { load, extractors, enums, axios, createCustomBaseUrl, PolyURL, USER_AGENT, NativeConsumet } = ctx;
|
|
14
|
+
const { StreamWish, VidHide } = extractors;
|
|
15
|
+
const { StreamingServers: StreamingServersEnum, TvType: TvTypeEnum } = enums;
|
|
16
|
+
const { makePostRequest } = NativeConsumet;
|
|
17
|
+
|
|
18
|
+
const baseUrl = createCustomBaseUrl('https://multimovies.center', customBaseURL);
|
|
19
|
+
|
|
20
|
+
const config: ProviderConfig = {
|
|
21
|
+
name: 'MultiMovies',
|
|
22
|
+
languages: 'all',
|
|
23
|
+
classPath: 'MOVIES.MultiMovies',
|
|
24
|
+
logo: `${baseUrl}/wp-content/uploads/2024/01/cropped-CompressJPEG.online_512x512_image.png`,
|
|
25
|
+
baseUrl,
|
|
26
|
+
isNSFW: false,
|
|
27
|
+
isWorking: true,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const supportedTypes = new Set([TvTypeEnum.MOVIE, TvTypeEnum.TVSERIES]);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Search for movies/TV shows
|
|
34
|
+
* @param query search query string
|
|
35
|
+
* @param page page number (default 1) (optional)
|
|
36
|
+
*/
|
|
37
|
+
const search = async (query: string, page: number = 1): Promise<ISearch<IMovieResult>> => {
|
|
38
|
+
const searchResult: ISearch<IMovieResult> = {
|
|
39
|
+
currentPage: page,
|
|
40
|
+
hasNextPage: false,
|
|
41
|
+
results: [],
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
let url;
|
|
45
|
+
if (page === 1) {
|
|
46
|
+
url = `${config.baseUrl}/?s=${query.replace(/[\W_]+/g, '+')}`;
|
|
47
|
+
} else {
|
|
48
|
+
url = `${config.baseUrl}/page/${page}/?s=${query.replace(/[\W_]+/g, '+')}`;
|
|
49
|
+
}
|
|
50
|
+
const { data } = await axios.get(url);
|
|
51
|
+
const $ = load(data);
|
|
52
|
+
|
|
53
|
+
const navSelector = 'div.pagination';
|
|
54
|
+
searchResult.hasNextPage = $(navSelector).find('#nextpagination').length > 0;
|
|
55
|
+
const articles = $('.search-page .result-item article').toArray();
|
|
56
|
+
|
|
57
|
+
await Promise.all(
|
|
58
|
+
articles.map(async (el) => {
|
|
59
|
+
const seasonSet = new Set<number>();
|
|
60
|
+
|
|
61
|
+
const href =
|
|
62
|
+
$(el)
|
|
63
|
+
.find('.thumbnail a')
|
|
64
|
+
.attr('href')
|
|
65
|
+
?.replace(/^https?:\/\/[^/]+\//, '')
|
|
66
|
+
.replace(/^\/|\/$/g, '') ?? '';
|
|
67
|
+
|
|
68
|
+
const episodesInfo = await fetchMediaInfo(href);
|
|
69
|
+
const episodes = episodesInfo?.episodes || [];
|
|
70
|
+
|
|
71
|
+
for (const episode of episodes) {
|
|
72
|
+
if (episode.season != null) {
|
|
73
|
+
seasonSet.add(episode.season);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
searchResult.results.push({
|
|
77
|
+
id: href,
|
|
78
|
+
title: $(el).find('.details .title a').text().trim(),
|
|
79
|
+
url: $(el).find('.thumbnail a').attr('href') ?? '',
|
|
80
|
+
image: $(el).find('.thumbnail img').attr('src') ?? '',
|
|
81
|
+
rating: parseFloat($(el).find('.meta .rating').text().replace('IMDb ', '')) || 0,
|
|
82
|
+
releaseDate: $(el).find('.meta .year').text().trim(),
|
|
83
|
+
seasons: seasonSet.size,
|
|
84
|
+
description: $(el).find('.contenido p').text().trim(),
|
|
85
|
+
type: $(el).find('.thumbnail a').attr('href')?.includes('/movies/')
|
|
86
|
+
? TvTypeEnum.MOVIE
|
|
87
|
+
: TvTypeEnum.TVSERIES,
|
|
88
|
+
});
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
return searchResult;
|
|
93
|
+
} catch (err) {
|
|
94
|
+
throw new Error((err as Error).message);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Fetch media information
|
|
100
|
+
* @param mediaId media link or id
|
|
101
|
+
*/
|
|
102
|
+
const fetchMediaInfo = async (mediaId: string): Promise<IMovieInfo> => {
|
|
103
|
+
if (!mediaId.startsWith(config.baseUrl)) {
|
|
104
|
+
mediaId = `${config.baseUrl}/${mediaId}`;
|
|
105
|
+
}
|
|
106
|
+
const movieInfo: IMovieInfo = {
|
|
107
|
+
id: mediaId.replace(/^https?:\/\/[^/]+\//, '').replace(/^\/|\/$/g, '')!,
|
|
108
|
+
title: '',
|
|
109
|
+
url: mediaId,
|
|
110
|
+
};
|
|
111
|
+
try {
|
|
112
|
+
const { data } = await axios.get(mediaId);
|
|
113
|
+
const $ = load(data);
|
|
114
|
+
const recommendationsArray: IMovieResult[] = [];
|
|
115
|
+
|
|
116
|
+
$('div#single_relacionados article').each((i, el) => {
|
|
117
|
+
recommendationsArray.push({
|
|
118
|
+
id: $(el)
|
|
119
|
+
.find('a')
|
|
120
|
+
.attr('href')
|
|
121
|
+
?.replace(/^https?:\/\/[^/]+\//, '')
|
|
122
|
+
.replace(/^\/|\/$/g, '')!,
|
|
123
|
+
title: $(el).find('a img').attr('alt')!,
|
|
124
|
+
image: $(el).find('a img').attr('data-src') ?? $(el).find('a img').attr('src'),
|
|
125
|
+
type: $(el).find('.thumbnail a').attr('href')?.includes('/movies/')
|
|
126
|
+
? TvTypeEnum.TVSERIES
|
|
127
|
+
: (TvTypeEnum.MOVIE ?? null),
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
movieInfo.cover = $('div#info .galeria').first().find('.g-item a').attr('href')?.trim() ?? '';
|
|
131
|
+
movieInfo.title = $('.sheader > .data > h1').text();
|
|
132
|
+
movieInfo.image = $('.sheader > .poster > img').attr('src') ?? $('.sheader > .poster > img').attr('data-src');
|
|
133
|
+
movieInfo.description = $('div#info div[itemprop="description"] p').text();
|
|
134
|
+
movieInfo.type = movieInfo.id.split('/')[0] === 'tvshows' ? TvTypeEnum.TVSERIES : TvTypeEnum.MOVIE;
|
|
135
|
+
movieInfo.releaseDate = $('.sheader > .data > .extra > span.date').text().trim();
|
|
136
|
+
movieInfo.trailer = {
|
|
137
|
+
id:
|
|
138
|
+
$('div#trailer .embed iframe').attr('data-litespeed-src')?.split('embed/')[1]?.split('?')[0] ??
|
|
139
|
+
$('div#trailer .embed iframe').attr('src')?.split('embed/')[1]?.split('?')[0]!,
|
|
140
|
+
url: $('div#trailer .embed iframe').attr('data-litespeed-src') ?? $('div#trailer .embed iframe').attr('src'),
|
|
141
|
+
};
|
|
142
|
+
movieInfo.genres = $('.sgeneros a')
|
|
143
|
+
.map((i, el) => $(el).text())
|
|
144
|
+
.get()
|
|
145
|
+
.map((v) => v.trim());
|
|
146
|
+
movieInfo.characters = [];
|
|
147
|
+
$('div#cast .persons .person').each((i, el) => {
|
|
148
|
+
const url = $(el).find('.img > a').attr('href');
|
|
149
|
+
const image = $(el).find('.img > a > img').attr('data-src') ?? $(el).find('.img > a > img').attr('src');
|
|
150
|
+
const name = $(el).find('.data > .name > a').text();
|
|
151
|
+
const character = $(el).find('.data > .caracter').text();
|
|
152
|
+
|
|
153
|
+
(movieInfo.characters as any[]).push({
|
|
154
|
+
url,
|
|
155
|
+
image,
|
|
156
|
+
name,
|
|
157
|
+
character,
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
movieInfo.country = $('.sheader > .data > .extra > span.country').text();
|
|
161
|
+
movieInfo.duration = $('.sheader > .data > .extra > span.runtime').text();
|
|
162
|
+
movieInfo.rating = parseFloat($('.starstruck-rating span.dt_rating_vgs[itemprop="ratingValue"]').text());
|
|
163
|
+
movieInfo.recommendations = recommendationsArray as any;
|
|
164
|
+
|
|
165
|
+
if (movieInfo.type === TvTypeEnum.TVSERIES) {
|
|
166
|
+
movieInfo.episodes = [];
|
|
167
|
+
$('#seasons .se-c').each((i, el) => {
|
|
168
|
+
const seasonNumber = parseInt($(el).find('.se-t').text().trim());
|
|
169
|
+
$(el)
|
|
170
|
+
.find('.episodios li')
|
|
171
|
+
.each((j, ep) => {
|
|
172
|
+
const episode = {
|
|
173
|
+
id: $(ep)
|
|
174
|
+
.find('.episodiotitle a')
|
|
175
|
+
.attr('href')
|
|
176
|
+
?.replace(/^https?:\/\/[^/]+\//, '')
|
|
177
|
+
.replace(/^\/|\/$/g, '')!,
|
|
178
|
+
season: seasonNumber,
|
|
179
|
+
number: parseInt($(ep).find('.numerando').text().trim().split('-')[1]!),
|
|
180
|
+
title: $(ep).find('.episodiotitle a').text().trim(),
|
|
181
|
+
url: $(ep).find('.episodiotitle a').attr('href')?.trim() ?? '',
|
|
182
|
+
releaseDate: String(new Date($(ep).find('.episodiotitle .date').text().trim()).getFullYear()),
|
|
183
|
+
image:
|
|
184
|
+
$(ep).find('.imagen img').attr('data-src')?.trim() ?? $(ep).find('.imagen img').attr('src')?.trim(),
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
movieInfo.episodes?.push(episode);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
movieInfo.episodes = [
|
|
192
|
+
{
|
|
193
|
+
id: movieInfo.id,
|
|
194
|
+
title: movieInfo.title,
|
|
195
|
+
url: movieInfo.url,
|
|
196
|
+
image: movieInfo.cover || movieInfo.image,
|
|
197
|
+
},
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return movieInfo;
|
|
202
|
+
} catch (err) {
|
|
203
|
+
throw new Error((err as Error).message);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Fetch episode sources
|
|
209
|
+
* @param episodeId episode id
|
|
210
|
+
* @param mediaId media id
|
|
211
|
+
* @param server server type (default `StreamWish`) (optional)
|
|
212
|
+
*/
|
|
213
|
+
const fetchEpisodeSources = async (
|
|
214
|
+
episodeId: string,
|
|
215
|
+
mediaId?: string,
|
|
216
|
+
server: StreamingServers = StreamingServersEnum.StreamWish,
|
|
217
|
+
fileId?: string
|
|
218
|
+
): Promise<ISource> => {
|
|
219
|
+
if (episodeId.startsWith('http')) {
|
|
220
|
+
const serverUrl = new PolyURL(episodeId);
|
|
221
|
+
const referer = serverUrl.origin;
|
|
222
|
+
const downloadUrl = fileId ? `${serverUrl.href.toString().replace('/e/', '/f/')}/${fileId}` : '';
|
|
223
|
+
|
|
224
|
+
switch (server) {
|
|
225
|
+
case StreamingServersEnum.StreamWish:
|
|
226
|
+
return {
|
|
227
|
+
headers: { Referer: referer },
|
|
228
|
+
...(await StreamWish().extract(serverUrl, referer)),
|
|
229
|
+
download: downloadUrl,
|
|
230
|
+
};
|
|
231
|
+
case StreamingServersEnum.VidHide:
|
|
232
|
+
return {
|
|
233
|
+
headers: { Referer: referer },
|
|
234
|
+
...(await VidHide().extract(serverUrl)),
|
|
235
|
+
download: fileId ? `https://gdmirrorbot.nl/file/${fileId}` : '',
|
|
236
|
+
};
|
|
237
|
+
default:
|
|
238
|
+
return {
|
|
239
|
+
headers: { Referer: referer },
|
|
240
|
+
...(await StreamWish().extract(serverUrl, referer)),
|
|
241
|
+
download: downloadUrl,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
try {
|
|
247
|
+
const servers = await fetchEpisodeServers(episodeId, episodeId);
|
|
248
|
+
const i = servers.findIndex((s) => s.name.toLowerCase() === server.toLowerCase());
|
|
249
|
+
if (i === -1) {
|
|
250
|
+
throw new Error(`Server ${server} not found`);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const serverUrl: URL = new URL(servers[i]!.url);
|
|
254
|
+
let fId = '';
|
|
255
|
+
|
|
256
|
+
if (!episodeId.startsWith('http')) {
|
|
257
|
+
const { fileId: id } = await getServer(`${config.baseUrl}/${episodeId}`);
|
|
258
|
+
fId = id ?? '';
|
|
259
|
+
}
|
|
260
|
+
// fileId to be used for download link
|
|
261
|
+
return await fetchEpisodeSources(serverUrl.href, mediaId, server, fId);
|
|
262
|
+
} catch (err) {
|
|
263
|
+
throw new Error((err as Error).message);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Fetch episode servers
|
|
269
|
+
* @param episodeId takes episode link or movie id
|
|
270
|
+
* @param mediaId takes movie link or id (found on movie info object, this is just a placeholder for compatibility)
|
|
271
|
+
*/
|
|
272
|
+
const fetchEpisodeServers = async (episodeId: string, mediaId: string): Promise<IEpisodeServer[]> => {
|
|
273
|
+
if (!episodeId.startsWith(config.baseUrl)) {
|
|
274
|
+
episodeId = `${config.baseUrl}/${episodeId}`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
const { servers } = await getServer(episodeId);
|
|
279
|
+
return servers;
|
|
280
|
+
} catch (err) {
|
|
281
|
+
throw new Error((err as Error).message);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Fetch popular movies
|
|
287
|
+
* @param page page number (default 1)
|
|
288
|
+
*/
|
|
289
|
+
const fetchPopular = async (page: number = 1): Promise<ISearch<IMovieResult>> => {
|
|
290
|
+
const result: ISearch<IMovieResult> = {
|
|
291
|
+
currentPage: page,
|
|
292
|
+
hasNextPage: false,
|
|
293
|
+
results: [],
|
|
294
|
+
};
|
|
295
|
+
try {
|
|
296
|
+
const { data } = await axios.get(`${config.baseUrl}/trending/page/${page}/`);
|
|
297
|
+
const $ = load(data);
|
|
298
|
+
const navSelector = 'div.pagination';
|
|
299
|
+
|
|
300
|
+
result.hasNextPage = $(navSelector).find('#nextpagination').length > 0;
|
|
301
|
+
$('.items > article')
|
|
302
|
+
.each((i, el) => {
|
|
303
|
+
const resultItem: IMovieResult = {
|
|
304
|
+
id: $(el).attr('id')!,
|
|
305
|
+
title: $(el).find('div.data > h3').text() ?? '',
|
|
306
|
+
url: $(el).find('div.poster > a').attr('href'),
|
|
307
|
+
image: $(el).find('div.poster > img').attr('data-src') ?? '',
|
|
308
|
+
type: $(el).find('div.poster > a').attr('href')?.includes('/movies/')
|
|
309
|
+
? TvTypeEnum.MOVIE
|
|
310
|
+
: TvTypeEnum.TVSERIES,
|
|
311
|
+
rating: $(el).find('div.poster > div.rating').text() ?? '',
|
|
312
|
+
releaseDate: $(el).find('div.data > span').text() ?? '',
|
|
313
|
+
};
|
|
314
|
+
result.results.push(resultItem);
|
|
315
|
+
})
|
|
316
|
+
.get();
|
|
317
|
+
|
|
318
|
+
return result;
|
|
319
|
+
} catch (err) {
|
|
320
|
+
throw new Error((err as Error).message);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Fetch by genre
|
|
326
|
+
* @param genre genre name
|
|
327
|
+
* @param page page number (default 1)
|
|
328
|
+
*/
|
|
329
|
+
const fetchByGenre = async (genre: string, page: number = 1): Promise<ISearch<IMovieResult>> => {
|
|
330
|
+
const result: ISearch<IMovieResult> = {
|
|
331
|
+
currentPage: page,
|
|
332
|
+
hasNextPage: false,
|
|
333
|
+
results: [],
|
|
334
|
+
};
|
|
335
|
+
try {
|
|
336
|
+
const { data } = await axios.get(`${config.baseUrl}/genre/${genre}/page/${page}`);
|
|
337
|
+
|
|
338
|
+
const $ = load(data);
|
|
339
|
+
const navSelector = 'div.pagination';
|
|
340
|
+
|
|
341
|
+
result.hasNextPage = $(navSelector).find('#nextpagination').length > 0;
|
|
342
|
+
$('.items > article')
|
|
343
|
+
.each((i, el) => {
|
|
344
|
+
const resultItem: IMovieResult = {
|
|
345
|
+
id: $(el).attr('id')!,
|
|
346
|
+
title: $(el).find('div.data > h3').text() ?? '',
|
|
347
|
+
url: $(el).find('div.poster > a').attr('href'),
|
|
348
|
+
image: $(el).find('div.poster > img').attr('data-src') ?? '',
|
|
349
|
+
type: $(el).find('div.poster > a').attr('href')?.includes('/movies/')
|
|
350
|
+
? TvTypeEnum.MOVIE
|
|
351
|
+
: TvTypeEnum.TVSERIES,
|
|
352
|
+
rating: $(el).find('div.poster > div.rating').text() ?? '',
|
|
353
|
+
releaseDate: $(el).find('div.data > span').text() ?? '',
|
|
354
|
+
};
|
|
355
|
+
result.results.push(resultItem);
|
|
356
|
+
})
|
|
357
|
+
.get();
|
|
358
|
+
|
|
359
|
+
return result;
|
|
360
|
+
} catch (err) {
|
|
361
|
+
throw new Error((err as Error).message);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Get server information
|
|
367
|
+
* @param url episode url
|
|
368
|
+
*/
|
|
369
|
+
const getServer = async (url: string): Promise<{ servers: IEpisodeServer[]; fileId: string }> => {
|
|
370
|
+
try {
|
|
371
|
+
const { data } = await axios.get(url);
|
|
372
|
+
const $ = load(data);
|
|
373
|
+
// Extract player config
|
|
374
|
+
const playerConfig = {
|
|
375
|
+
postId: $('#player-option-1').attr('data-post'),
|
|
376
|
+
nume: $('#player-option-1').attr('data-nume'),
|
|
377
|
+
type: $('#player-option-1').attr('data-type'),
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
if (!playerConfig.postId || !playerConfig.nume || !playerConfig.type) {
|
|
381
|
+
throw new Error('Missing player configuration');
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const formData = new FormData();
|
|
385
|
+
formData.append('action', 'doo_player_ajax');
|
|
386
|
+
formData.append('post', playerConfig.postId);
|
|
387
|
+
formData.append('nume', playerConfig.nume);
|
|
388
|
+
formData.append('type', playerConfig.type);
|
|
389
|
+
|
|
390
|
+
const headers = {
|
|
391
|
+
'User-Agent': USER_AGENT,
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
// const { data: playerRes } = await axios.post(`${baseUrl}/wp-admin/admin-ajax.php`, formData, {
|
|
395
|
+
// headers,
|
|
396
|
+
// });
|
|
397
|
+
console.log(`${baseUrl}/wp-admin/admin-ajax.php`);
|
|
398
|
+
const res = await fetch(`${baseUrl}/wp-admin/admin-ajax.php`, {
|
|
399
|
+
method: 'POST',
|
|
400
|
+
headers: {
|
|
401
|
+
...headers,
|
|
402
|
+
//'Content-Type':'multipart/form-data',
|
|
403
|
+
},
|
|
404
|
+
body: formData as any,
|
|
405
|
+
});
|
|
406
|
+
const postTestOkHttp = await makePostRequest(
|
|
407
|
+
`${baseUrl}/wp-admin/admin-ajax.php`,
|
|
408
|
+
{
|
|
409
|
+
...headers,
|
|
410
|
+
//'Content-Type':'multipart/form-data',
|
|
411
|
+
},
|
|
412
|
+
formData as any
|
|
413
|
+
);
|
|
414
|
+
console.timeEnd('POST Request - OkHttp');
|
|
415
|
+
console.log('POST Response (OkHttp):', {
|
|
416
|
+
statusCode: postTestOkHttp.statusCode,
|
|
417
|
+
body: postTestOkHttp.body, // Full response body
|
|
418
|
+
headers: postTestOkHttp.headers,
|
|
419
|
+
});
|
|
420
|
+
const playerRes = await res.json();
|
|
421
|
+
console.log({ playerRes });
|
|
422
|
+
const iframeUrl = playerRes.embed_url?.match(/<iframe[^>]+src="([^"]+)"[^>]*>/i)?.[1] || playerRes.embed_url;
|
|
423
|
+
|
|
424
|
+
// Handle non-multimovies case
|
|
425
|
+
if (!iframeUrl.includes('multimovies')) {
|
|
426
|
+
if (iframeUrl.includes('dhcplay')) {
|
|
427
|
+
return {
|
|
428
|
+
servers: [{ name: 'StreamWish', url: iframeUrl }],
|
|
429
|
+
fileId: iframeUrl.split('/').pop() ?? '',
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
// let playerBaseUrl = iframeUrl.split('/').slice(0, 3).join('/');
|
|
433
|
+
// const redirectResponse = await axios.head(playerBaseUrl, {
|
|
434
|
+
// headers: headers,
|
|
435
|
+
// maxRedirects: 5,
|
|
436
|
+
// validateStatus: () => true,
|
|
437
|
+
// });
|
|
438
|
+
// const redirectResponse = await fetch(playerBaseUrl, {
|
|
439
|
+
// method: 'HEAD',
|
|
440
|
+
// headers: headers,
|
|
441
|
+
// redirect: 'follow',
|
|
442
|
+
// });
|
|
443
|
+
|
|
444
|
+
// const isRedirected = redirectResponse.request._redirectable._isRedirect ? redirectResponse : null;
|
|
445
|
+
// const finalResponse = true ? redirectResponse : null;
|
|
446
|
+
|
|
447
|
+
// // Update base URL if redirect occurred
|
|
448
|
+
// if (finalResponse) {
|
|
449
|
+
// playerBaseUrl = finalResponse?.url;
|
|
450
|
+
// }
|
|
451
|
+
|
|
452
|
+
const fileId = iframeUrl.split('/').pop();
|
|
453
|
+
if (!fileId) {
|
|
454
|
+
throw new Error('No player ID found');
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const streamRequestData = new FormData();
|
|
458
|
+
streamRequestData.append('sid', fileId);
|
|
459
|
+
|
|
460
|
+
// const streamResponse = await axios.post(`https://pro.gtxgamer.site/embedhelper.php`, streamRequestData, {
|
|
461
|
+
// headers,
|
|
462
|
+
// });
|
|
463
|
+
const streamRes = await fetch(`https://pro.gtxgamer.site/embedhelper.php`, {
|
|
464
|
+
method: 'POST',
|
|
465
|
+
headers: {
|
|
466
|
+
...headers,
|
|
467
|
+
// 'Content-Type':'multipart/form-data',
|
|
468
|
+
},
|
|
469
|
+
body: streamRequestData as any,
|
|
470
|
+
});
|
|
471
|
+
const streamResponse = await streamRes.json();
|
|
472
|
+
if (!streamResponse) {
|
|
473
|
+
throw new Error('No stream data found');
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// Decode and parse mresult
|
|
477
|
+
const decodedMresult = JSON.parse(atob(streamResponse.mresult));
|
|
478
|
+
const mresultKeys = Object.keys(decodedMresult);
|
|
479
|
+
// Find common keys
|
|
480
|
+
const commonKeys = mresultKeys.filter((key) => streamResponse.siteUrls.hasOwnProperty(key));
|
|
481
|
+
|
|
482
|
+
// Convert to a Set (if needed)
|
|
483
|
+
const commonStreamSites = new Set(commonKeys);
|
|
484
|
+
const servers = Array.from(commonStreamSites).map((site) => {
|
|
485
|
+
return {
|
|
486
|
+
name:
|
|
487
|
+
streamResponse.siteFriendlyNames[site] === 'StreamHG'
|
|
488
|
+
? 'StreamWish'
|
|
489
|
+
: streamResponse.siteFriendlyNames[site] === 'EarnVids'
|
|
490
|
+
? 'VidHide'
|
|
491
|
+
: streamResponse.siteFriendlyNames[site],
|
|
492
|
+
url: streamResponse.siteUrls[site] + JSON.parse(atob(streamResponse.mresult))[site],
|
|
493
|
+
};
|
|
494
|
+
});
|
|
495
|
+
return { servers, fileId };
|
|
496
|
+
} else {
|
|
497
|
+
return {
|
|
498
|
+
servers: [{ name: 'StreamWish', url: iframeUrl }],
|
|
499
|
+
fileId: iframeUrl.split('/').pop() ?? '',
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
} catch (err) {
|
|
503
|
+
console.log(err);
|
|
504
|
+
throw new Error((err as Error).message);
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
return {
|
|
509
|
+
...config,
|
|
510
|
+
supportedTypes,
|
|
511
|
+
search,
|
|
512
|
+
fetchMediaInfo,
|
|
513
|
+
fetchEpisodeSources,
|
|
514
|
+
fetchEpisodeServers,
|
|
515
|
+
fetchPopular,
|
|
516
|
+
fetchByGenre,
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export type MultiMoviesProviderInstance = ReturnType<typeof createMultiMovies>;
|