@vyla-entertainment/sdk 1.20.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/package.json +3 -2
  2. package/src/config.js +99 -67
  3. package/src/health.js +60 -20
  4. package/src/sdk.d.ts +94 -121
  5. package/src/sdk.js +82 -78
  6. package/src/sources/111477.js +88 -100
  7. package/src/sources/123anime.js +120 -56
  8. package/src/sources/3eyedraven.js +82 -135
  9. package/src/sources/4movies.js +77 -0
  10. package/src/sources/aether.js +99 -0
  11. package/src/sources/castle.js +415 -0
  12. package/src/sources/cinecat.js +37 -18
  13. package/src/sources/cinemaarmy.js +179 -180
  14. package/src/sources/cinesrc.js +401 -397
  15. package/src/sources/cno.js +101 -94
  16. package/src/sources/dulo.js +134 -149
  17. package/src/sources/flaxmovies.js +114 -105
  18. package/src/sources/framextv.js +126 -0
  19. package/src/sources/frost.js +38 -29
  20. package/src/sources/fsonline.js +95 -47
  21. package/src/sources/hdhub.js +43 -36
  22. package/src/sources/hexa.js +60 -53
  23. package/src/sources/hyper.js +42 -35
  24. package/src/sources/kickassanime.js +117 -124
  25. package/src/sources/kisskh.js +114 -59
  26. package/src/sources/lmscript.js +72 -70
  27. package/src/sources/lookmovie.js +80 -79
  28. package/src/sources/meowtv.js +140 -0
  29. package/src/sources/movenerds.js +74 -124
  30. package/src/sources/movy.js +197 -209
  31. package/src/sources/net79.js +59 -55
  32. package/src/sources/peestream.js +126 -138
  33. package/src/sources/pengu.js +46 -49
  34. package/src/sources/pstream.js +73 -67
  35. package/src/sources/purstream.js +96 -104
  36. package/src/sources/rivestream.js +182 -176
  37. package/src/sources/rivo.js +58 -53
  38. package/src/sources/streamaggregator.js +114 -128
  39. package/src/sources/thugtv.js +70 -62
  40. package/src/sources/vidapi.js +122 -114
  41. package/src/sources/vidcore.js +14 -122
  42. package/src/sources/vidfast.js +14 -122
  43. package/src/sources/vidlink.js +78 -27
  44. package/src/sources/vidora.js +74 -42
  45. package/src/sources/vidup.js +14 -122
  46. package/src/sources/vidvault.js +133 -187
  47. package/src/sources/vidy.js +192 -187
  48. package/src/sources/vidzee.js +189 -183
  49. package/src/sources/vixsrc.js +123 -113
  50. package/src/sources/watchout.js +60 -46
  51. package/src/sources/xdownloader.js +127 -128
  52. package/src/sources/yapgrid.js +68 -62
  53. package/src/sources/yastream.js +35 -29
  54. package/src/subtitles.js +105 -122
  55. package/src/utils/helpers.js +586 -247
  56. package/src/sources/bcine.js +0 -202
  57. package/src/sources/cinezo.js +0 -55
  58. package/src/sources/vidrock.js +0 -145
@@ -1,115 +1,123 @@
1
- import { fetchJson, USER_AGENT } from '../utils/helpers.js';
2
-
3
- const API_BASE = 'https://streamdata.vaplayer.ru/api.php';
4
- const EMBED_ORIGIN = 'https://nextgencloudfabric.com';
5
-
6
- export const VERIFY_HEADERS = {
7
- 'User-Agent': USER_AGENT,
8
- 'Referer': `${EMBED_ORIGIN}/`,
9
- 'Origin': EMBED_ORIGIN
10
- };
11
-
12
- function extractStreamUrls(obj, urls = new Set()) {
13
- if (!obj) return urls;
14
- if (typeof obj === 'string') {
15
- if (obj.startsWith('http') && (obj.includes('.m3u8') || obj.includes('.mp4') || obj.includes('.mpd'))) {
16
- urls.add(obj);
17
- }
18
- } else if (Array.isArray(obj)) {
19
- for (const item of obj) extractStreamUrls(item, urls);
20
- } else if (typeof obj === 'object') {
21
- for (const val of Object.values(obj)) {
22
- extractStreamUrls(val, urls);
23
- }
24
- }
25
- return urls;
26
- }
27
-
28
- export async function getStream({ id, s, e }) {
29
- try {
30
- const isTv = s != null && e != null;
31
- const type = isTv ? 'tv' : 'movie';
32
-
33
- const url = `${API_BASE}?tmdb=${id}&type=${type}${isTv ? `&season=${s}&episode=${e}` : ''}`;
34
-
35
- const data = await fetchJson(url, {
36
- headers: {
37
- 'Accept': '*/*',
38
- 'Origin': EMBED_ORIGIN,
39
- 'Referer': `${EMBED_ORIGIN}/`,
40
- 'User-Agent': USER_AGENT
41
- },
42
- signal: AbortSignal.timeout(10000)
43
- });
44
-
45
- const streamUrls = Array.from(extractStreamUrls(data));
46
- if (!streamUrls.length) return null;
47
-
48
- let subs = [];
49
- if (data.subtitles && Array.isArray(data.subtitles)) {
50
- subs = data.subtitles;
51
- } else if (data.captions && Array.isArray(data.captions)) {
52
- subs = data.captions;
53
- }
54
-
55
- const subtitles = subs.map(sub => ({
56
- url: sub.url || sub.file || sub.src,
57
- lang: sub.display || sub.label || sub.language || sub.lang || 'Unknown'
58
- })).filter(s => s.url);
59
-
60
- const allUrls = streamUrls.map(streamUrl => {
61
- let type = 'mp4';
62
- if (streamUrl.includes('.mpd')) type = 'dash';
63
- else if (streamUrl.includes('.m3u8')) type = 'hls';
64
-
65
- return {
66
- url: streamUrl,
67
- server: 'VidAPI',
68
- quality: 'Auto',
69
- type,
70
- headers: VERIFY_HEADERS,
71
- subtitles: subtitles.length > 0 ? subtitles : undefined,
72
- skipProxy: false
73
- };
74
- });
75
-
76
- return allUrls.length ? { allUrls } : null;
77
- } catch {
78
- return null;
79
- }
80
- }
81
-
82
- export async function getSources() {
83
- return ['VidAPI'];
84
- }
85
-
86
- export async function proxyStream({ url, res, proxyUtils: { fetchUpstream, rewriteM3u8 } }) {
87
- try {
88
- const upstream = await fetchUpstream(url, 0, VERIFY_HEADERS);
89
- if (!upstream) return res.end();
90
-
91
- const ct = (upstream.headers?.['content-type'] || '').toLowerCase();
92
- const isM3u8 = ct.includes('mpegurl') || ct.includes('m3u8') || /\.m3u8?(\?|$)/i.test(url);
93
-
94
- if (isM3u8) {
95
- const chunks = [];
96
- for await (const c of upstream) chunks.push(c);
97
- let body = Buffer.concat(chunks).toString('utf8');
98
-
99
- res.setHeader('Content-Type', 'application/vnd.apple.mpegurl');
100
- res.setHeader('Access-Control-Allow-Origin', '*');
101
-
102
- return res.end(rewriteM3u8(body, url, '&va=1&tt=1'));
103
- }
104
-
105
- res.setHeader('Content-Type', ct || 'application/octet-stream');
106
- res.setHeader('Access-Control-Allow-Origin', '*');
107
- res.setHeader('Cache-Control', 'public, max-age=3600');
108
- upstream.pipe(res);
109
- } catch {
110
- if (!res.headersSent) {
111
- res.statusCode = 502;
112
- res.end();
113
- }
114
- }
1
+ import { fetchJson, USER_AGENT } from '../utils/helpers.js';
2
+
3
+ const API_BASE = 'https://streamdata.vaplayer.ru/api.php';
4
+ const EMBED_ORIGIN = 'https://nextgencloudfabric.com';
5
+
6
+ export const VERIFY_HEADERS = {
7
+ 'User-Agent': USER_AGENT,
8
+ Referer: `${EMBED_ORIGIN}/`,
9
+ Origin: EMBED_ORIGIN,
10
+ };
11
+
12
+ function extractStreamUrls(obj, urls = new Set()) {
13
+ if (!obj) return urls;
14
+ if (typeof obj === 'string') {
15
+ if (obj.startsWith('http') && (obj.includes('.m3u8') || obj.includes('.mp4') || obj.includes('.mpd'))) {
16
+ urls.add(obj);
17
+ }
18
+ } else if (Array.isArray(obj)) {
19
+ for (const item of obj) extractStreamUrls(item, urls);
20
+ } else if (typeof obj === 'object') {
21
+ for (const val of Object.values(obj)) {
22
+ extractStreamUrls(val, urls);
23
+ }
24
+ }
25
+ return urls;
26
+ }
27
+
28
+ export async function getStream(args) {
29
+ const { id, s, e } = args || {};
30
+ const isTv = s != null && e != null;
31
+ const type = isTv ? 'tv' : 'movie';
32
+
33
+ const url = `${API_BASE}?tmdb=${id}&type=${type}${isTv ? `&season=${s}&episode=${e}` : ''}`;
34
+
35
+ try {
36
+ const data = await fetchJson(url, {
37
+ headers: {
38
+ Accept: '*/*',
39
+ Origin: EMBED_ORIGIN,
40
+ Referer: `${EMBED_ORIGIN}/`,
41
+ 'User-Agent': USER_AGENT,
42
+ },
43
+ signal: AbortSignal.timeout(10000),
44
+ });
45
+
46
+ const streamUrls = Array.from(extractStreamUrls(data));
47
+ if (!streamUrls.length) return null;
48
+
49
+ let subs = [];
50
+ if (data.subtitles && Array.isArray(data.subtitles)) {
51
+ subs = data.subtitles;
52
+ } else if (data.captions && Array.isArray(data.captions)) {
53
+ subs = data.captions;
54
+ }
55
+
56
+ const subtitles = subs.map(sub => ({
57
+ url: sub.url || sub.file || sub.src,
58
+ lang: sub.display || sub.label || sub.language || sub.lang || 'Unknown',
59
+ })).filter(subItem => subItem.url);
60
+
61
+ const allUrls = streamUrls.map(streamUrl => {
62
+ let type = 'mp4';
63
+ if (streamUrl.includes('.mpd')) type = 'dash';
64
+ else if (streamUrl.includes('.m3u8')) type = 'hls';
65
+
66
+ return {
67
+ url: streamUrl,
68
+ server: 'VidAPI',
69
+ quality: 'Auto',
70
+ type,
71
+ headers: VERIFY_HEADERS,
72
+ subtitles: subtitles.length > 0 ? subtitles : undefined,
73
+ skipProxy: false,
74
+ };
75
+ });
76
+
77
+ if (!allUrls.length) return null;
78
+
79
+ return {
80
+ url: allUrls[0].url,
81
+ headers: allUrls[0].headers,
82
+ allUrls,
83
+ ...(subtitles.length > 0 ? { subtitles } : {}),
84
+ };
85
+ } catch {
86
+ return null;
87
+ }
88
+ }
89
+
90
+ export async function getSources() {
91
+ return ['VidAPI'];
92
+ }
93
+
94
+ export async function proxyStream({ url, res, proxyUtils: { fetchUpstream, rewriteM3u8 } }) {
95
+ try {
96
+ const upstream = await fetchUpstream(url, 0, VERIFY_HEADERS);
97
+ if (!upstream) return res.end();
98
+
99
+ const ct = (upstream.headers?.['content-type'] || '').toLowerCase();
100
+ const isM3u8 = ct.includes('mpegurl') || ct.includes('m3u8') || /\.m3u8?(\?|$)/i.test(url);
101
+
102
+ if (isM3u8) {
103
+ const chunks = [];
104
+ for await (const c of upstream) chunks.push(c);
105
+ let body = Buffer.concat(chunks).toString('utf8');
106
+
107
+ res.setHeader('Content-Type', 'application/vnd.apple.mpegurl');
108
+ res.setHeader('Access-Control-Allow-Origin', '*');
109
+
110
+ return res.end(rewriteM3u8(body, url, '&va=1&tt=1'));
111
+ }
112
+
113
+ res.setHeader('Content-Type', ct || 'application/octet-stream');
114
+ res.setHeader('Access-Control-Allow-Origin', '*');
115
+ res.setHeader('Cache-Control', 'public, max-age=3600');
116
+ upstream.pipe(res);
117
+ } catch {
118
+ if (!res.headersSent) {
119
+ res.statusCode = 502;
120
+ res.end();
121
+ }
122
+ }
115
123
  }
@@ -1,123 +1,15 @@
1
- import { getUA } from '../utils/helpers.js';
2
-
3
- const BASE_URL = 'https://vidcore.io';
4
- const API = 'https://enc-dec.app/api';
5
-
6
- export async function getStream({ id, s, e }) {
7
- const isTv = Boolean(s && e);
8
- const targetUrl = isTv
9
- ? `${BASE_URL}/tv/${id}/${s}/${e}/`
10
- : `${BASE_URL}/movie/${id}`;
11
-
12
- const ua = getUA();
13
- const baseHeaders = {
14
- 'User-Agent': ua,
15
- 'Referer': `${BASE_URL}/`,
16
- 'X-Requested-With': 'XMLHttpRequest',
17
- };
18
-
19
- try {
20
- const pageRes = await fetch(targetUrl, {
21
- headers: { 'User-Agent': ua },
22
- signal: AbortSignal.timeout(10000),
23
- });
24
- if (!pageRes.ok) return null;
25
- const html = await pageRes.text();
26
-
27
- const match = html.match(/\\"(?:en|token)\\":\\"(.*?)\\"/);
28
- if (!match || !match[1]) return null;
29
- const enToken = match[1];
30
-
31
- const s1Res = await fetch(`${API}/enc-vidcore?text=${encodeURIComponent(enToken)}&stage=1`, {
32
- signal: AbortSignal.timeout(8000),
33
- });
34
- const s1Data = await s1Res.json();
35
- if (s1Data?.status !== 200 || !s1Data?.result?.stage1) return null;
36
-
37
- const token1 = s1Data.result.token;
38
- const stage1Url = s1Data.result.stage1;
39
-
40
- const post1Res = await fetch(stage1Url, {
41
- method: 'POST',
42
- headers: { ...baseHeaders, 'X-CSRF-Token': token1 },
43
- signal: AbortSignal.timeout(10000),
44
- });
45
- if (!post1Res.ok) return null;
46
- const stage1Text = await post1Res.text();
47
-
48
- const s2Res = await fetch(`${API}/enc-vidcore?text=${encodeURIComponent(stage1Text)}&stage=2`, {
49
- signal: AbortSignal.timeout(8000),
50
- });
51
- const s2Data = await s2Res.json();
52
- if (s2Data?.status !== 200 || !s2Data?.result?.servers) return null;
53
-
54
- const { servers: serversUrl, stream: streamBaseUrl, token: token2 } = s2Data.result;
55
- const currentHeaders = { ...baseHeaders, 'X-CSRF-Token': token2 };
56
-
57
- const serversRes = await fetch(serversUrl, {
58
- method: 'POST',
59
- headers: currentHeaders,
60
- signal: AbortSignal.timeout(10000),
61
- });
62
- if (!serversRes.ok) return null;
63
- const serversEncrypted = await serversRes.text();
64
-
65
- const decServersRes = await fetch(`${API}/dec-vidcore`, {
66
- method: 'POST',
67
- headers: { 'Content-Type': 'application/json' },
68
- body: JSON.stringify({ text: serversEncrypted }),
69
- signal: AbortSignal.timeout(8000),
70
- });
71
- const decServersData = await decServersRes.json();
72
- if (decServersData?.status !== 200 || !Array.isArray(decServersData.result)) return null;
73
-
74
- const allUrls = [];
75
-
76
- for (const server of decServersData.result) {
77
- if (!server?.data) continue;
78
- try {
79
- const streamUrl = `${streamBaseUrl}/${server.data}`;
80
- const streamEncRes = await fetch(streamUrl, {
81
- method: 'POST',
82
- headers: currentHeaders,
83
- signal: AbortSignal.timeout(8000),
84
- });
85
- if (!streamEncRes.ok) continue;
86
- const streamEncText = await streamEncRes.text();
87
-
88
- const decStreamRes = await fetch(`${API}/dec-vidcore`, {
89
- method: 'POST',
90
- headers: { 'Content-Type': 'application/json' },
91
- body: JSON.stringify({ text: streamEncText }),
92
- signal: AbortSignal.timeout(8000),
93
- });
94
- const decStreamData = await decStreamRes.json();
95
- if (decStreamData?.status !== 200 || !decStreamData.result) continue;
96
-
97
- const streamResult = decStreamData.result;
98
- const resultUrl = typeof streamResult === 'string' ? streamResult : streamResult?.url || streamResult?.file;
99
-
100
- if (typeof resultUrl === 'string' && resultUrl.startsWith('http')) {
101
- allUrls.push({
102
- url: resultUrl,
103
- label: server.name || server.title || 'VidCore',
104
- headers: {
105
- 'User-Agent': ua,
106
- 'Referer': `${BASE_URL}/`,
107
- },
108
- });
109
- }
110
- } catch { }
111
- }
112
-
113
- if (allUrls.length === 0) return null;
114
-
115
- return {
116
- url: allUrls[0].url,
117
- allUrls,
118
- headers: allUrls[0].headers,
119
- };
120
- } catch {
121
- return null;
122
- }
1
+ import { scrapeVidcoreFamily } from '../utils/helpers.js';
2
+
3
+ const BASE_URL = 'https://vidcore.io';
4
+
5
+ export async function getStream(args) {
6
+ const { id, s, e } = args || {};
7
+ return await scrapeVidcoreFamily({
8
+ id,
9
+ s,
10
+ e,
11
+ baseUrl: BASE_URL,
12
+ apiName: 'vidcore',
13
+ serverLabel: 'VidCore',
14
+ });
123
15
  }
@@ -1,123 +1,15 @@
1
- import { getUA } from '../utils/helpers.js';
2
-
3
- const BASE_URL = 'https://vidfast.vc';
4
- const API = 'https://enc-dec.app/api';
5
-
6
- export async function getStream({ id, s, e }) {
7
- const isTv = Boolean(s && e);
8
- const targetUrl = isTv
9
- ? `${BASE_URL}/tv/${id}/${s}/${e}/`
10
- : `${BASE_URL}/movie/${id}`;
11
-
12
- const ua = getUA();
13
- const baseHeaders = {
14
- 'User-Agent': ua,
15
- 'Referer': `${BASE_URL}/`,
16
- 'X-Requested-With': 'XMLHttpRequest',
17
- };
18
-
19
- try {
20
- const pageRes = await fetch(targetUrl, {
21
- headers: { 'User-Agent': ua },
22
- signal: AbortSignal.timeout(10000),
23
- });
24
- if (!pageRes.ok) return null;
25
- const html = await pageRes.text();
26
-
27
- const match = html.match(/\\"(?:en|token)\\":\\"(.*?)\\"/);
28
- if (!match || !match[1]) return null;
29
- const enToken = match[1];
30
-
31
- const s1Res = await fetch(`${API}/enc-vidfast?text=${encodeURIComponent(enToken)}&stage=1`, {
32
- signal: AbortSignal.timeout(8000),
33
- });
34
- const s1Data = await s1Res.json();
35
- if (s1Data?.status !== 200 || !s1Data?.result?.stage1) return null;
36
-
37
- const token1 = s1Data.result.token;
38
- const stage1Url = s1Data.result.stage1;
39
-
40
- const post1Res = await fetch(stage1Url, {
41
- method: 'POST',
42
- headers: { ...baseHeaders, 'X-CSRF-Token': token1 },
43
- signal: AbortSignal.timeout(10000),
44
- });
45
- if (!post1Res.ok) return null;
46
- const stage1Text = await post1Res.text();
47
-
48
- const s2Res = await fetch(`${API}/enc-vidfast?text=${encodeURIComponent(stage1Text)}&stage=2`, {
49
- signal: AbortSignal.timeout(8000),
50
- });
51
- const s2Data = await s2Res.json();
52
- if (s2Data?.status !== 200 || !s2Data?.result?.servers) return null;
53
-
54
- const { servers: serversUrl, stream: streamBaseUrl, token: token2 } = s2Data.result;
55
- const currentHeaders = { ...baseHeaders, 'X-CSRF-Token': token2 };
56
-
57
- const serversRes = await fetch(serversUrl, {
58
- method: 'POST',
59
- headers: currentHeaders,
60
- signal: AbortSignal.timeout(10000),
61
- });
62
- if (!serversRes.ok) return null;
63
- const serversEncrypted = await serversRes.text();
64
-
65
- const decServersRes = await fetch(`${API}/dec-vidfast`, {
66
- method: 'POST',
67
- headers: { 'Content-Type': 'application/json' },
68
- body: JSON.stringify({ text: serversEncrypted }),
69
- signal: AbortSignal.timeout(8000),
70
- });
71
- const decServersData = await decServersRes.json();
72
- if (decServersData?.status !== 200 || !Array.isArray(decServersData.result)) return null;
73
-
74
- const allUrls = [];
75
-
76
- for (const server of decServersData.result) {
77
- if (!server?.data) continue;
78
- try {
79
- const streamUrl = `${streamBaseUrl}/${server.data}`;
80
- const streamEncRes = await fetch(streamUrl, {
81
- method: 'POST',
82
- headers: currentHeaders,
83
- signal: AbortSignal.timeout(8000),
84
- });
85
- if (!streamEncRes.ok) continue;
86
- const streamEncText = await streamEncRes.text();
87
-
88
- const decStreamRes = await fetch(`${API}/dec-vidfast`, {
89
- method: 'POST',
90
- headers: { 'Content-Type': 'application/json' },
91
- body: JSON.stringify({ text: streamEncText }),
92
- signal: AbortSignal.timeout(8000),
93
- });
94
- const decStreamData = await decStreamRes.json();
95
- if (decStreamData?.status !== 200 || !decStreamData.result) continue;
96
-
97
- const streamResult = decStreamData.result;
98
- const resultUrl = typeof streamResult === 'string' ? streamResult : streamResult?.url || streamResult?.file;
99
-
100
- if (typeof resultUrl === 'string' && resultUrl.startsWith('http')) {
101
- allUrls.push({
102
- url: resultUrl,
103
- label: server.name || server.title || 'VidFast',
104
- headers: {
105
- 'User-Agent': ua,
106
- 'Referer': `${BASE_URL}/`,
107
- },
108
- });
109
- }
110
- } catch { }
111
- }
112
-
113
- if (allUrls.length === 0) return null;
114
-
115
- return {
116
- url: allUrls[0].url,
117
- allUrls,
118
- headers: allUrls[0].headers,
119
- };
120
- } catch {
121
- return null;
122
- }
1
+ import { scrapeVidcoreFamily } from '../utils/helpers.js';
2
+
3
+ const BASE_URL = 'https://vidfast.vc';
4
+
5
+ export async function getStream(args) {
6
+ const { id, s, e } = args || {};
7
+ return await scrapeVidcoreFamily({
8
+ id,
9
+ s,
10
+ e,
11
+ baseUrl: BASE_URL,
12
+ apiName: 'vidfast',
13
+ serverLabel: 'VidFast',
14
+ });
123
15
  }
@@ -1,28 +1,79 @@
1
- import { fetchJson, USER_AGENT } from '../utils/helpers.js';
2
-
3
- const BASE = "https://vidlink.pro";
4
- const HEADERS = { 'User-Agent': USER_AGENT, Origin: BASE, Referer: `${BASE}/` };
5
-
6
- export async function getStream({ id, s, e }) {
7
- try {
8
- const encData = await fetchJson(`https://enc-dec.app/api/enc-vidlink?text=${id}`, { signal: AbortSignal.timeout(6000) });
9
- if (encData?.status !== 200 || !encData?.result) return null;
10
- const data = await fetchJson(s ? `${BASE}/api/b/tv/${encData.result}/${s}/${e || 1}` : `${BASE}/api/b/movie/${encData.result}`, { headers: HEADERS, signal: AbortSignal.timeout(10000) });
11
- const stream = data?.stream;
12
- if (!stream) return null;
13
- if (stream.type === 'file' && stream.qualities) {
14
- let picked = null;
15
- for (const q of ['1080', '720', '480', '360']) if (stream.qualities[q]?.url) { picked = stream.qualities[q].url; break; }
16
- if (!picked) picked = stream.qualities[Object.keys(stream.qualities)[0]]?.url;
17
- if (picked) return { allUrls: [{ url: picked, type: 'mp4', audio: 'sub', server: 'Vidlink', skipHlsCheck: true, skipCache: true }] };
18
- } else if (stream.playlist) {
19
- return { allUrls: [{ url: stream.playlist, type: 'hls', audio: 'sub', server: 'Vidlink', skipHlsCheck: true, skipCache: true }] };
20
- }
21
- return null;
22
- } catch { return null; }
23
- }
24
-
25
- export async function getSources(args) {
26
- const stream = await getStream(args);
27
- return stream?.allUrls ? [...new Set(stream.allUrls.map(u => u.server))] : [];
1
+ import { fetchJson, USER_AGENT } from '../utils/helpers.js';
2
+
3
+ const BASE_URL = 'https://vidlink.pro';
4
+ const HEADERS = { 'User-Agent': USER_AGENT, Origin: BASE_URL, Referer: `${BASE_URL}/` };
5
+
6
+ export async function getStream(args) {
7
+ const { id, s, e } = args || {};
8
+
9
+ try {
10
+ const encData = await fetchJson(`https://enc-dec.app/api/enc-vidlink?text=${id}`, { signal: AbortSignal.timeout(6000) });
11
+ if (encData?.status !== 200 || !encData?.result) return null;
12
+
13
+ const basePath = s ? `${BASE_URL}/api/b/tv/${encData.result}/${s}/${e || 1}` : `${BASE_URL}/api/b/movie/${encData.result}`;
14
+ const responses = await Promise.allSettled([
15
+ fetchJson(basePath, { headers: HEADERS, signal: AbortSignal.timeout(10000) }),
16
+ fetchJson(`${basePath}?multiLang=0`, { headers: HEADERS, signal: AbortSignal.timeout(10000) }),
17
+ ]);
18
+
19
+ const streamList = [];
20
+ const seenUrls = new Set();
21
+
22
+ for (const res of responses) {
23
+ if (res.status !== 'fulfilled' || !res.value?.stream) continue;
24
+ const stream = res.value.stream;
25
+
26
+ if (stream.playlist && !seenUrls.has(stream.playlist)) {
27
+ seenUrls.add(stream.playlist);
28
+ const isDash = stream.type === 'dash' || stream.deliveryType === 'dash' || stream.playlist.includes('.mpd');
29
+ streamList.push({
30
+ url: stream.playlist,
31
+ quality: stream.playbackMetadata?.resolutions?.[0] ? `${stream.playbackMetadata.resolutions[0]}p` : 'Auto',
32
+ label: `Vidlink ${isDash ? 'DASH' : 'HLS'}`,
33
+ name: `Vidlink ${isDash ? 'DASH' : 'HLS'}`,
34
+ server: 'Vidlink',
35
+ type: isDash ? 'dash' : 'hls',
36
+ headers: stream.playlistHeaders || {},
37
+ });
38
+ }
39
+
40
+ if (stream.qualities && typeof stream.qualities === 'object') {
41
+ const qualityOrder = ['1080', '720', '480', '360', ...Object.keys(stream.qualities)];
42
+ const seenQualities = new Set();
43
+
44
+ for (const q of qualityOrder) {
45
+ if (seenQualities.has(q)) continue;
46
+ seenQualities.add(q);
47
+ const qData = stream.qualities[q];
48
+ if (!qData?.url || seenUrls.has(qData.url)) continue;
49
+ seenUrls.add(qData.url);
50
+ streamList.push({
51
+ url: qData.url,
52
+ quality: `${q}p`,
53
+ label: `Vidlink ${q}p`,
54
+ name: `Vidlink ${q}p`,
55
+ server: 'Vidlink',
56
+ type: qData.type || 'mp4',
57
+ headers: qData.headers || {},
58
+ });
59
+ }
60
+ }
61
+ }
62
+
63
+ if (!streamList.length) return null;
64
+
65
+ return {
66
+ url: streamList[0].url,
67
+ headers: streamList[0].headers,
68
+ allUrls: streamList,
69
+ streams: streamList,
70
+ };
71
+ } catch {
72
+ return null;
73
+ }
74
+ }
75
+
76
+ export async function getSources(args) {
77
+ const stream = await getStream(args);
78
+ return stream?.allUrls ? [...new Set(stream.allUrls.map(u => u.server || 'Vidlink'))] : [];
28
79
  }