react-native-consumet 0.8.0 → 0.9.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.
- package/Consumet.podspec +26 -26
- package/LICENSE +673 -673
- package/README.md +49 -49
- package/android/build.gradle +106 -106
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +4 -4
- package/android/src/main/AndroidManifestNew.xml +3 -3
- package/android/src/main/java/com/consumet/ConsumetModule.kt +49 -49
- package/android/src/main/java/com/consumet/ConsumetPackage.kt +33 -33
- package/ios/Consumet.h +6 -6
- package/ios/Consumet.mm +18 -18
- package/lib/commonjs/extractors/megacloud/index.js +5 -0
- package/lib/commonjs/extractors/megacloud/index.js.map +1 -1
- package/lib/commonjs/extractors/megacloud/megacloud.getsrcs.js +73 -42
- package/lib/commonjs/extractors/megacloud/megacloud.getsrcs.js.map +1 -1
- package/lib/commonjs/extractors/vidcloud.js +37 -26
- package/lib/commonjs/extractors/vidcloud.js.map +1 -1
- package/lib/commonjs/models/types.js +1 -0
- package/lib/commonjs/models/types.js.map +1 -1
- package/lib/commonjs/providers/meta/anilist.js +22 -7
- package/lib/commonjs/providers/meta/anilist.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/multistream/index.js +208 -0
- package/lib/commonjs/providers/movies/multistream/index.js.map +1 -0
- package/lib/commonjs/providers/movies/multistream/utils.js +267 -0
- package/lib/commonjs/providers/movies/multistream/utils.js.map +1 -0
- package/lib/commonjs/providers/movies/netflixmirror.js +2 -2
- package/lib/commonjs/providers/movies/netflixmirror.js.map +1 -1
- package/lib/commonjs/utils/utils.js +58 -34
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/module/extractors/megacloud/index.js +5 -0
- package/lib/module/extractors/megacloud/index.js.map +1 -1
- package/lib/module/extractors/megacloud/megacloud.getsrcs.js +73 -42
- package/lib/module/extractors/megacloud/megacloud.getsrcs.js.map +1 -1
- package/lib/module/extractors/vidcloud.js +36 -26
- package/lib/module/extractors/vidcloud.js.map +1 -1
- package/lib/module/models/types.js +1 -0
- package/lib/module/models/types.js.map +1 -1
- package/lib/module/providers/meta/anilist.js +22 -7
- package/lib/module/providers/meta/anilist.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/multistream/index.js +205 -0
- package/lib/module/providers/movies/multistream/index.js.map +1 -0
- package/lib/module/providers/movies/multistream/utils.js +259 -0
- package/lib/module/providers/movies/multistream/utils.js.map +1 -0
- package/lib/module/providers/movies/netflixmirror.js +2 -2
- package/lib/module/providers/movies/netflixmirror.js.map +1 -1
- package/lib/module/utils/utils.js +55 -30
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/typescript/commonjs/src/extractors/megacloud/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/megacloud/megacloud.getsrcs.d.ts +3 -4
- package/lib/typescript/commonjs/src/extractors/megacloud/megacloud.getsrcs.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/vidcloud.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/types.d.ts +2 -1
- package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/movies/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/providers/movies/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/movies/multistream/index.d.ts +37 -0
- package/lib/typescript/commonjs/src/providers/movies/multistream/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/movies/multistream/utils.d.ts +10 -0
- package/lib/typescript/commonjs/src/providers/movies/multistream/utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/movies/netflixmirror.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/utils.d.ts +8 -8
- package/lib/typescript/commonjs/src/utils/utils.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/megacloud/index.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/megacloud/megacloud.getsrcs.d.ts +3 -4
- package/lib/typescript/module/src/extractors/megacloud/megacloud.getsrcs.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/vidcloud.d.ts.map +1 -1
- package/lib/typescript/module/src/models/types.d.ts +2 -1
- package/lib/typescript/module/src/models/types.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/meta/anilist.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/movies/index.d.ts +2 -0
- package/lib/typescript/module/src/providers/movies/index.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/movies/multistream/index.d.ts +37 -0
- package/lib/typescript/module/src/providers/movies/multistream/index.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/movies/multistream/utils.d.ts +10 -0
- package/lib/typescript/module/src/providers/movies/multistream/utils.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/movies/netflixmirror.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/utils.d.ts +8 -8
- package/lib/typescript/module/src/utils/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/react-native.config.js +12 -12
- package/src/extractors/megacloud/index.ts +7 -0
- package/src/extractors/megacloud/megacloud.getsrcs.ts +80 -39
- package/src/extractors/vidcloud.ts +37 -26
- package/src/models/types.ts +1 -0
- package/src/providers/meta/anilist.ts +20 -7
- package/src/providers/movies/index.ts +2 -0
- package/src/providers/movies/multistream/index.ts +232 -0
- package/src/providers/movies/multistream/utils.ts +393 -0
- package/src/providers/movies/netflixmirror.ts +2 -2
- package/src/utils/utils.ts +66 -31
|
@@ -1,63 +1,104 @@
|
|
|
1
1
|
import CryptoJS from 'crypto-js';
|
|
2
2
|
import { USER_AGENT } from '../../utils/utils';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
+
import { load } from 'cheerio';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* Thanks to https://github.com/yogesh-hacker for the
|
|
7
|
-
* Thanks to https://github.com/illusionTBA for the key's api
|
|
7
|
+
* Thanks to https://github.com/yogesh-hacker for the original implementation.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export async function getSources(embed_url: URL, site: string) {
|
|
11
11
|
const regex = /\/([^\/?]+)(?=\?)/;
|
|
12
12
|
const xrax = embed_url.toString().match(regex)?.[1];
|
|
13
13
|
const basePath = embed_url.pathname.split('/').slice(0, 4).join('/');
|
|
14
|
-
const url = `${embed_url.origin}${basePath}/getSources?id=${xrax}`;
|
|
15
14
|
|
|
15
|
+
const url = `${embed_url.origin}${basePath}/getSources?id=${xrax}}`;
|
|
16
16
|
const getKeyType = url.includes('mega') ? 'mega' : url.includes('videostr') ? 'vidstr' : 'rabbit';
|
|
17
|
-
|
|
17
|
+
// console.log(`🔗 Fetching sources from: ${url} with key type: ${getKeyType}`);
|
|
18
18
|
//gets the base64 encoded string from the URL and key in parallel
|
|
19
19
|
let key;
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
const headers = {
|
|
22
|
+
'Accept': '*/*',
|
|
23
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
24
|
+
'Referer': site,
|
|
25
|
+
'User-Agent': USER_AGENT,
|
|
26
|
+
};
|
|
21
27
|
|
|
22
28
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
'Referer': site,
|
|
28
|
-
'X-Requested-With': 'XMLHttpRequest',
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
axios.get('https://raw.githubusercontent.com/yogesh-hacker/MegacloudKeys/refs/heads/main/keys.json'),
|
|
32
|
-
]);
|
|
29
|
+
const { data: keyData } = await axios.get(
|
|
30
|
+
'https://raw.githubusercontent.com/yogesh-hacker/MegacloudKeys/refs/heads/main/keys.json'
|
|
31
|
+
);
|
|
32
|
+
key = keyData;
|
|
33
33
|
} catch (err) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
34
|
+
console.error('❌ Error fetching key:', err);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// console.log(`🔗 Fetched data: ${key[getKeyType]}`);
|
|
38
|
+
let videoTag;
|
|
39
|
+
let embedRes;
|
|
40
|
+
try {
|
|
41
|
+
embedRes = await axios.get(embed_url.href, { headers });
|
|
42
|
+
const $ = load(embedRes.data);
|
|
43
|
+
videoTag = $('#megacloud-player');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('❌ Error fetching embed URL:', error);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!videoTag.length) {
|
|
50
|
+
console.error('❌ Looks like URL expired!');
|
|
51
|
+
return;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
const
|
|
54
|
+
const rawText = embedRes.data;
|
|
56
55
|
|
|
56
|
+
let nonceMatch = rawText.match(/\b[a-zA-Z0-9]{48}\b/);
|
|
57
|
+
if (!nonceMatch) {
|
|
58
|
+
const altMatch = rawText.match(/\b([a-zA-Z0-9]{16})\b.*?\b([a-zA-Z0-9]{16})\b.*?\b([a-zA-Z0-9]{16})\b/);
|
|
59
|
+
if (altMatch) nonceMatch = [altMatch.slice(1).join('')];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const nonce = nonceMatch?.[0];
|
|
63
|
+
if (!nonce) return console.error('❌ Nonce not found!');
|
|
64
|
+
const fileId = videoTag.attr('data-id');
|
|
65
|
+
|
|
66
|
+
const { data: encryptedResData } = await axios.get(
|
|
67
|
+
`${embed_url.origin}${basePath}/getSources?id=${fileId}&_k=${nonce}`,
|
|
68
|
+
{
|
|
69
|
+
headers,
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
// console.log(
|
|
73
|
+
// `🔗 Encrypted response:`,
|
|
74
|
+
// encryptedResData,
|
|
75
|
+
// `${embed_url.origin}${basePath}/getSources?id=${xrax}&_k=${nonce}`
|
|
76
|
+
// );
|
|
77
|
+
const encrypted = encryptedResData.encrypted;
|
|
78
|
+
const sources = encryptedResData.sources;
|
|
79
|
+
let videoUrl = '';
|
|
80
|
+
|
|
81
|
+
if (encrypted) {
|
|
82
|
+
const decodeUrl =
|
|
83
|
+
'https://script.google.com/macros/s/AKfycbx-yHTwupis_JD0lNzoOnxYcEYeXmJZrg7JeMxYnEZnLBy5V0--UxEvP-y9txHyy1TX9Q/exec';
|
|
84
|
+
|
|
85
|
+
const params = new URLSearchParams({
|
|
86
|
+
encrypted_data: sources,
|
|
87
|
+
nonce: nonce,
|
|
88
|
+
secret: key[getKeyType],
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const decodeRes = await axios.get(`${decodeUrl}?${params.toString()}`);
|
|
92
|
+
videoUrl = decodeRes.data.match(/"file":"(.*?)"/)?.[1]?.replace(/\\\//g, '/') || '';
|
|
93
|
+
// console.log(`🔗 Video URL: ${videoUrl}`, decodeRes.data.match(/"file":"(.*?)"/));
|
|
94
|
+
} else {
|
|
95
|
+
videoUrl = sources[0]?.file;
|
|
96
|
+
// console.log(`🔗 Video URL: ${videoUrl}`, sources);
|
|
97
|
+
}
|
|
57
98
|
return {
|
|
58
|
-
sources,
|
|
59
|
-
tracks:
|
|
60
|
-
intro:
|
|
61
|
-
outro:
|
|
99
|
+
sources: videoUrl,
|
|
100
|
+
tracks: encryptedResData.tracks,
|
|
101
|
+
intro: encryptedResData?.intro,
|
|
102
|
+
outro: encryptedResData?.outro,
|
|
62
103
|
};
|
|
63
104
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import { VideoExtractor, type IVideo, type ISubtitle, type Intro } from '../models';
|
|
2
3
|
import { USER_AGENT } from '../utils';
|
|
3
4
|
import { getSources } from './megacloud/megacloud.getsrcs';
|
|
@@ -26,40 +27,50 @@ class VidCloud extends VideoExtractor {
|
|
|
26
27
|
|
|
27
28
|
const resp = await getSources(videoUrl, referer);
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.split('\n')
|
|
33
|
-
.filter((line: string) => line.includes('.m3u8') || line.endsWith('m3u8')) as string[];
|
|
34
|
-
const qualities = data.split('\n').filter((line: string) => line.includes('RESOLUTION=')) as string[];
|
|
30
|
+
if (!resp) {
|
|
31
|
+
throw new Error('Failed to get sources from getSources function');
|
|
32
|
+
}
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
34
|
+
if (Array.isArray(resp.sources)) {
|
|
35
|
+
for (const source of resp.sources) {
|
|
36
|
+
const { data } = await this.client.get(source.file, options);
|
|
37
|
+
const urls = data
|
|
38
|
+
.split('\n')
|
|
39
|
+
.filter((line: string) => line.includes('.m3u8') || line.endsWith('m3u8')) as string[];
|
|
40
|
+
const qualities = data.split('\n').filter((line: string) => line.includes('RESOLUTION=')) as string[];
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const TdArray = qualities.map((s, i) => {
|
|
43
|
+
const f1 = s.split('x')[1];
|
|
44
|
+
const f2 = urls[i];
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
this.sources.push({
|
|
45
|
-
url: f2!,
|
|
46
|
-
quality: f1,
|
|
47
|
-
isM3U8: f2!.includes('.m3u8') || f2!.endsWith('m3u8'),
|
|
46
|
+
return [f1, f2];
|
|
48
47
|
});
|
|
48
|
+
|
|
49
|
+
for (const [f1, f2] of TdArray) {
|
|
50
|
+
this.sources.push({
|
|
51
|
+
url: f2!,
|
|
52
|
+
quality: f1,
|
|
53
|
+
isM3U8: f2!.includes('.m3u8') || f2!.endsWith('m3u8'),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
result.sources.push(...this.sources);
|
|
49
57
|
}
|
|
50
|
-
result.sources.push(...this.sources);
|
|
51
58
|
}
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
if (resp.sources && typeof resp.sources === 'string') {
|
|
61
|
+
result.sources.push({
|
|
62
|
+
url: resp.sources,
|
|
63
|
+
isM3U8: resp.sources.includes('.m3u8') || resp.sources.endsWith('m3u8'),
|
|
64
|
+
quality: 'auto',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
58
67
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
if (resp.tracks && Array.isArray(resp.tracks)) {
|
|
69
|
+
result.subtitles = resp.tracks.map((s: any) => ({
|
|
70
|
+
url: s.file,
|
|
71
|
+
lang: s.label ? s.label : 'Default (maybe)',
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
63
74
|
|
|
64
75
|
return result;
|
|
65
76
|
} catch (err) {
|
package/src/models/types.ts
CHANGED
|
@@ -40,6 +40,7 @@ import Zoro from '../anime/zoro';
|
|
|
40
40
|
import AnimeKai from '../anime/animekai';
|
|
41
41
|
import AnimePahe from '../anime/animepahe';
|
|
42
42
|
import Mangasee123 from '../manga/mangasee123';
|
|
43
|
+
import AnimeOwl from '../anime/animeowl';
|
|
43
44
|
import { ANIFY_URL, findSimilarTitles, getHashFromImage } from '../../utils/utils';
|
|
44
45
|
|
|
45
46
|
class Anilist extends AnimeParser {
|
|
@@ -1144,7 +1145,8 @@ class Anilist extends AnimeParser {
|
|
|
1144
1145
|
this.provider instanceof Zoro ||
|
|
1145
1146
|
this.provider instanceof Gogoanime ||
|
|
1146
1147
|
this.provider instanceof AnimeKai ||
|
|
1147
|
-
this.provider instanceof AnimePahe
|
|
1148
|
+
this.provider instanceof AnimePahe ||
|
|
1149
|
+
this.provider instanceof AnimeOwl
|
|
1148
1150
|
) {
|
|
1149
1151
|
try {
|
|
1150
1152
|
// console.time('fetchEpisodesListById');
|
|
@@ -1169,6 +1171,7 @@ class Anilist extends AnimeParser {
|
|
|
1169
1171
|
function mergeEpisodes(normalizedEpisodes: any[], providerEpisodes: IAnimeEpisode[]): IAnimeEpisode[] {
|
|
1170
1172
|
const numberMap = new Map<number, any>();
|
|
1171
1173
|
const dateMap = new Map<number, any>();
|
|
1174
|
+
const usedNormalized = new Set<string>();
|
|
1172
1175
|
|
|
1173
1176
|
normalizedEpisodes.forEach((ep) => {
|
|
1174
1177
|
if (ep.number) numberMap.set(ep.number, ep);
|
|
@@ -1181,32 +1184,42 @@ class Anilist extends AnimeParser {
|
|
|
1181
1184
|
return providerEpisodes.map((providerEp, index) => {
|
|
1182
1185
|
let normalizedEp: any = null;
|
|
1183
1186
|
|
|
1187
|
+
const matchIfNotUsed = (ep: any) => ep && !usedNormalized.has(ep.uniqueId);
|
|
1188
|
+
|
|
1189
|
+
// Match by release date (within ±1 day)
|
|
1184
1190
|
if (providerEp.releaseDate) {
|
|
1185
1191
|
const ts = new Date(providerEp.releaseDate).getTime();
|
|
1186
|
-
// Find dates within 1 day range
|
|
1187
1192
|
for (let [normTs, normEp] of dateMap) {
|
|
1188
|
-
if (Math.abs(ts - normTs) <= 86400000) {
|
|
1189
|
-
// 1 day in ms
|
|
1193
|
+
if (Math.abs(ts - normTs) <= 86400000 && matchIfNotUsed(normEp)) {
|
|
1190
1194
|
normalizedEp = normEp;
|
|
1191
1195
|
break;
|
|
1192
1196
|
}
|
|
1193
1197
|
}
|
|
1194
1198
|
}
|
|
1195
1199
|
|
|
1200
|
+
// Match by episode number
|
|
1196
1201
|
if (!normalizedEp && providerEp.number != null) {
|
|
1197
|
-
|
|
1202
|
+
const ep = numberMap.get(providerEp.number);
|
|
1203
|
+
if (matchIfNotUsed(ep)) normalizedEp = ep;
|
|
1198
1204
|
}
|
|
1199
1205
|
|
|
1206
|
+
// Match by title similarity
|
|
1200
1207
|
if (!normalizedEp && providerEp.title) {
|
|
1201
1208
|
normalizedEp = normalizedEpisodes.find(
|
|
1202
|
-
(normEp) => normEp
|
|
1209
|
+
(normEp) => matchIfNotUsed(normEp) && normEp.title?.includes(providerEp.title)
|
|
1203
1210
|
);
|
|
1204
1211
|
}
|
|
1205
1212
|
|
|
1206
|
-
|
|
1213
|
+
// Fallback to same index
|
|
1214
|
+
if (!normalizedEp && matchIfNotUsed(normalizedEpisodes[index])) {
|
|
1207
1215
|
normalizedEp = normalizedEpisodes[index];
|
|
1208
1216
|
}
|
|
1209
1217
|
|
|
1218
|
+
// Mark this normalized episode as used
|
|
1219
|
+
if (normalizedEp) {
|
|
1220
|
+
usedNormalized.add(normalizedEp.uniqueId);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1210
1223
|
if (!normalizedEp) return providerEp;
|
|
1211
1224
|
|
|
1212
1225
|
return {
|
|
@@ -11,6 +11,7 @@ import SFlix from './sflix';
|
|
|
11
11
|
import MultiMovies from './multimovies';
|
|
12
12
|
import NetflixMirror from './netflixmirror';
|
|
13
13
|
import HiMovies from './himovies';
|
|
14
|
+
import MultiStream from './multistream';
|
|
14
15
|
|
|
15
16
|
export default {
|
|
16
17
|
DramaCool,
|
|
@@ -26,4 +27,5 @@ export default {
|
|
|
26
27
|
MultiMovies,
|
|
27
28
|
NetflixMirror,
|
|
28
29
|
HiMovies,
|
|
30
|
+
MultiStream,
|
|
29
31
|
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { load } from 'cheerio';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
MovieParser,
|
|
5
|
+
TvType,
|
|
6
|
+
type IMovieInfo,
|
|
7
|
+
type IEpisodeServer,
|
|
8
|
+
StreamingServers,
|
|
9
|
+
type ISource,
|
|
10
|
+
type IMovieResult,
|
|
11
|
+
type ISearch,
|
|
12
|
+
} from '../../../models';
|
|
13
|
+
import { MegaCloud, MixDrop, VidCloud } from '../../../extractors';
|
|
14
|
+
import { getMultiServers, getMultiSources } from './utils';
|
|
15
|
+
|
|
16
|
+
class MultiStream extends MovieParser {
|
|
17
|
+
override readonly name = 'MultiStream';
|
|
18
|
+
protected override baseUrl = 'https://rivestream.org';
|
|
19
|
+
protected apiUrl = 'https://api.themoviedb.org/3';
|
|
20
|
+
private apiKey: string = '5201b54eb0968700e693a30576d7d4dc';
|
|
21
|
+
protected override logo = 'https://himovies.sx/images/group_1/theme_1/favicon.png';
|
|
22
|
+
protected override classPath = 'MOVIES.MultiStream';
|
|
23
|
+
override supportedTypes = new Set([TvType.MOVIE, TvType.TVSERIES]);
|
|
24
|
+
constructor(customBaseURL?: string) {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
if (customBaseURL) {
|
|
27
|
+
if (customBaseURL.startsWith('http://') || customBaseURL.startsWith('https://')) {
|
|
28
|
+
this.baseUrl = customBaseURL;
|
|
29
|
+
} else {
|
|
30
|
+
this.baseUrl = `http://${customBaseURL}`;
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
this.baseUrl = this.baseUrl;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param query search query string
|
|
40
|
+
* @param page page number (default 1) (optional)
|
|
41
|
+
*/
|
|
42
|
+
override search = async (query: string, page: number = 1): Promise<ISearch<IMovieResult>> => {
|
|
43
|
+
const searchUrl = `${this.apiUrl}/search/multi?api_key=${this.apiKey}&language=en-US&page=${page}&include_adult=false&query=${query}`;
|
|
44
|
+
|
|
45
|
+
const search: ISearch<IMovieResult> = {
|
|
46
|
+
currentPage: page,
|
|
47
|
+
hasNextPage: false,
|
|
48
|
+
results: [],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const { data } = await this.client.get(searchUrl);
|
|
53
|
+
|
|
54
|
+
if (data.results.length < 1) return search;
|
|
55
|
+
|
|
56
|
+
search.hasNextPage = page + 1 <= data.total_pages;
|
|
57
|
+
search.currentPage = page;
|
|
58
|
+
search.totalResults = data.total_results;
|
|
59
|
+
search.totalPages = data.total_pages;
|
|
60
|
+
|
|
61
|
+
const moviePromises = data.results.map(async (result: any) => {
|
|
62
|
+
const date = new Date(result?.release_date || result?.first_air_date);
|
|
63
|
+
|
|
64
|
+
let totalSeasons = undefined;
|
|
65
|
+
if (result.media_type === 'tv') {
|
|
66
|
+
try {
|
|
67
|
+
const { data: tvData } = await this.client.get(
|
|
68
|
+
`${this.apiUrl}/tv/${result.id}?api_key=${this.apiKey}&language=en-US`
|
|
69
|
+
);
|
|
70
|
+
totalSeasons = tvData.number_of_seasons;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
// Continue without seasons data if request fails
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const movie: IMovieResult = {
|
|
77
|
+
id: `${result.id}$${result.media_type}`,
|
|
78
|
+
title: result?.title || result?.name,
|
|
79
|
+
image: `https://image.tmdb.org/t/p/original${result?.poster_path}`,
|
|
80
|
+
type: result.media_type === 'movie' ? TvType.MOVIE : TvType.TVSERIES,
|
|
81
|
+
rating: result?.vote_average || 0,
|
|
82
|
+
releaseDate: `${date.getFullYear()}` || '0',
|
|
83
|
+
seasons: totalSeasons,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return movie;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
search.results = await Promise.all(moviePromises);
|
|
90
|
+
|
|
91
|
+
return search;
|
|
92
|
+
} catch (err) {
|
|
93
|
+
throw new Error((err as Error).message);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param mediaId - The media identifier (TMDB ID with type, e.g., "1071585$movie")
|
|
100
|
+
*/
|
|
101
|
+
override fetchMediaInfo = async (mediaId: string): Promise<IMovieInfo> => {
|
|
102
|
+
const movieInfo: IMovieInfo = {
|
|
103
|
+
id: mediaId,
|
|
104
|
+
title: '',
|
|
105
|
+
};
|
|
106
|
+
const parts = mediaId.split('$');
|
|
107
|
+
const type = parts[1];
|
|
108
|
+
mediaId = parts[0]!;
|
|
109
|
+
const infoUrl = `${this.apiUrl}/${type}/${parts[0]}?api_key=${this.apiKey}&language=en-US&append_to_response=release_dates,images,recommendations,credits,videos`;
|
|
110
|
+
try {
|
|
111
|
+
const { data } = await this.client.get(infoUrl);
|
|
112
|
+
movieInfo.title = data?.title || data?.name;
|
|
113
|
+
movieInfo.image = `https://image.tmdb.org/t/p/original${data?.poster_path}`;
|
|
114
|
+
movieInfo.cover = `https://image.tmdb.org/t/p/original${data?.backdrop_path}`;
|
|
115
|
+
movieInfo.type = type === 'movie' ? TvType.MOVIE : TvType.TVSERIES;
|
|
116
|
+
movieInfo.rating = data?.vote_average || 0;
|
|
117
|
+
movieInfo.releaseDate = data?.release_date || data?.first_air_date;
|
|
118
|
+
movieInfo.description = data?.overview;
|
|
119
|
+
movieInfo.genres = data?.genres.map((genre: { name: string }) => genre.name);
|
|
120
|
+
movieInfo.duration = data?.runtime || data?.episode_run_time[0];
|
|
121
|
+
movieInfo.totalEpisodes = data?.number_of_episodes;
|
|
122
|
+
movieInfo.totalSeasons = data?.number_of_seasons as number;
|
|
123
|
+
|
|
124
|
+
movieInfo.characters = data?.credits?.cast.map((cast: any) => ({
|
|
125
|
+
id: cast.id,
|
|
126
|
+
name: cast.name,
|
|
127
|
+
url: `https://www.themoviedb.org/person/${cast.id}`,
|
|
128
|
+
character: cast.character,
|
|
129
|
+
image: `https://image.tmdb.org/t/p/original${cast.profile_path}`,
|
|
130
|
+
}));
|
|
131
|
+
movieInfo.trailer = {
|
|
132
|
+
id: data?.videos?.results[0]?.key,
|
|
133
|
+
site: data?.videos?.results[0]?.site,
|
|
134
|
+
url: `https://www.youtube.com/watch?v=${data?.videos?.results[0]?.key}`,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
movieInfo.recommendations =
|
|
138
|
+
data?.recommendations?.results?.length <= 0
|
|
139
|
+
? undefined
|
|
140
|
+
: data?.recommendations?.results.map((result: any) => {
|
|
141
|
+
return {
|
|
142
|
+
id: result.id,
|
|
143
|
+
title: result.title || result.name,
|
|
144
|
+
image: `https://image.tmdb.org/t/p/original${result.poster_path}`,
|
|
145
|
+
type: type === 'movie' ? TvType.MOVIE : TvType.TVSERIES,
|
|
146
|
+
rating: result.vote_average || 0,
|
|
147
|
+
releaseDate: result.release_date || result.first_air_date,
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (movieInfo.type === TvType.TVSERIES) {
|
|
152
|
+
movieInfo.episodes = [];
|
|
153
|
+
for (let i = 1; i <= data?.number_of_seasons; i++) {
|
|
154
|
+
const { data } = await this.client.get(`${this.apiUrl}/tv/${mediaId}/season/${i}?api_key=${this.apiKey}`);
|
|
155
|
+
data.episodes.map((item: any) => {
|
|
156
|
+
const episode = {
|
|
157
|
+
id: `${mediaId}$tv$${item.episode_number}$${item.season_number}$${item.id}`,
|
|
158
|
+
//first part is mediaId, second is episode number, third is season number, fourth is episode id(to avoid conflicts just in case)
|
|
159
|
+
title: item.name,
|
|
160
|
+
number: item.episode_number,
|
|
161
|
+
season: item.season_number || i,
|
|
162
|
+
description: item.overview,
|
|
163
|
+
image: `https://image.tmdb.org/t/p/original${item.still_path}`,
|
|
164
|
+
};
|
|
165
|
+
movieInfo.episodes?.push(episode);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
movieInfo.episodes = [
|
|
170
|
+
{
|
|
171
|
+
id: `${mediaId}$movie`,
|
|
172
|
+
title: movieInfo.title as string,
|
|
173
|
+
description: movieInfo.description,
|
|
174
|
+
image: movieInfo.image,
|
|
175
|
+
number: 1,
|
|
176
|
+
},
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return movieInfo;
|
|
181
|
+
} catch (err) {
|
|
182
|
+
console.log(err);
|
|
183
|
+
throw new Error((err as Error).message);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
* @param episodeId episode id
|
|
190
|
+
* @param mediaId media id
|
|
191
|
+
* @param server server type (defaults to the first from `fetchEpisodeServers`) (optional)
|
|
192
|
+
*/
|
|
193
|
+
override fetchEpisodeSources = async (
|
|
194
|
+
episodeId: string,
|
|
195
|
+
mediaId: string,
|
|
196
|
+
server: StreamingServers | string
|
|
197
|
+
): Promise<ISource> => {
|
|
198
|
+
const firstServer = (await this.fetchEpisodeServers(episodeId, mediaId))[0]!.name as StreamingServers;
|
|
199
|
+
return await getMultiSources(episodeId, server ? server : firstServer);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
*
|
|
204
|
+
* @param episodeId takes episode link or movie id
|
|
205
|
+
* @param mediaId takes movie link or id (found on movie movieInfo object)
|
|
206
|
+
*/
|
|
207
|
+
override fetchEpisodeServers = async (episodeId: string, mediaId?: string): Promise<IEpisodeServer[]> => {
|
|
208
|
+
try {
|
|
209
|
+
const servers = await getMultiServers(episodeId);
|
|
210
|
+
return servers;
|
|
211
|
+
} catch (err) {
|
|
212
|
+
throw new Error((err as Error).message);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// (async () => {
|
|
218
|
+
// const movie = new MultiStream();
|
|
219
|
+
// const search = await movie.search('jujutsu');
|
|
220
|
+
// const movieInfo = await movie.fetchMediaInfo(search.results[0].id);
|
|
221
|
+
// // const recentTv = await movie.fetchTrendingTvShows();
|
|
222
|
+
// const servers = await movie.fetchEpisodeServers(movieInfo.episodes![0].id, movieInfo.id);
|
|
223
|
+
// console.log(servers);
|
|
224
|
+
// const genre = await movie.fetchEpisodeSources(
|
|
225
|
+
// movieInfo.episodes![0].id,
|
|
226
|
+
// movieInfo.id,
|
|
227
|
+
// servers[0].name as StreamingServers
|
|
228
|
+
// );
|
|
229
|
+
// console.log(genre);
|
|
230
|
+
// })();
|
|
231
|
+
|
|
232
|
+
export default MultiStream;
|